Compare commits

..

No commits in common. "2acaa92a6ac2b5dc08a94c546926ad0c66fcf031" and "2cdfdb68c520f682f9307e80499c774b7ad6ff5a" have entirely different histories.

View file

@ -1,33 +1,9 @@
/*
* CanGrow - simply DIY automatic plant grow system (for cannabis).
*
* Pin assignment
* ==============
*
* D0 - DHT11
* D1, D2 - I2C
* D3 - MOSFET Fan
* D4 - MOSFET Pump
* D5 - MOSFET Grow LED, PWM
*
*/
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include "DHT.h"
uint8_t PINdht = D3;
uint8_t PINfan = 3;
uint8_t PINpump = 4;
uint8_t PINled = 5;
#define WIRE Wire
#define DHTTYPE DHT11
Adafruit_SSD1306 display = Adafruit_SSD1306(128, 32, &WIRE);
// 'CanGrow_Logo', 128x32px
@ -73,22 +49,15 @@ const unsigned char* bmpallArray[1] = {
};
// I2C moisture sensor measurements
// soil moisture value
int chirpMoisture;
int chirpMoistureOld = 0 ;
int soilMoisture;
int soilMoistureOld = 0 ;
// temp value from i2c sensor
int chirpTemp;
int chirpTempOld = 0;
int temp1Val;
int temp1ValOld = 0;
// light intensity value
int chirpLight;
int chirpLightOld = 0;
// DHT measurements
float dhtTemp;
float dhtHumidity;
DHT dht(PINdht, DHTTYPE);
int lightVal;
int lightValOld = 0;
void writeI2CRegister8bit(int addr, int value) {
Wire.beginTransmission(addr);
@ -113,28 +82,23 @@ void setup() {
writeI2CRegister8bit(0x20, 6); //reset
display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // Address 0x3C for 128x32
pinMode(PINdht, INPUT);
dht.begin();
display.display();
delay(1000);
display.clearDisplay();
display.display();
display.drawBitmap(0, 0, bmpCanGrow_Logo, 128, 32, WHITE);
display.display();
delay(2500);
display.clearDisplay();
display.display();
delay(5000);
display.setTextSize(1);
display.setTextColor(SSD1306_WHITE, SSD1306_BLACK);
display.setTextColor(SSD1306_WHITE);
}
void loop() {
chirpMoisture = readI2CRegister16bit(0x20, 0);
soilMoisture = readI2CRegister16bit(0x20, 0);
/*
* Test for refresh one value. Test read i2c values
Serial.print(readI2CRegister16bit(0x20, 0)); //read capacitance register
Serial.print(", ");
Serial.print(readI2CRegister16bit(0x20, 5)); //temperature register
@ -147,33 +111,16 @@ void loop() {
display.setCursor(73,0);
display.setTextColor(SSD1306_BLACK);
display.print(chirpMoistureOld);
display.print(soilMoistureOld);
display.display();
delay(800);
display.setCursor(73,0);
display.setTextColor(SSD1306_WHITE);
display.println(chirpMoisture);
float chirpMoistureF = chirpMoisture / 10;
display.print(chirpMoisture);
chirpMoistureOld = chirpMoisture;
*/
display.print(soilMoisture);
soilMoistureOld = soilMoisture;
display.setCursor(0,0);
display.print("I2C: ");
display.print(readI2CRegister16bit(0x20, 0));
display.print(", ");
display.print(readI2CRegister16bit(0x20, 5));
display.print(", ");
display.print(readI2CRegister16bit(0x20, 5));
writeI2CRegister8bit(0x20, 3); //request light measurement
display.println(readI2CRegister16bit(0x20, 4));
display.print("DHT11: ");
display.print(dht.readTemperature());
display.print(", ");
display.print(dht.readHumidity());
//display.println(readI2CRegister16bit(0x20, 0));
display.display();