diff --git a/Arduino/CanGrow/CanGrow.ino b/Arduino/CanGrow/CanGrow.ino index 26bae8e..c4ceff4 100644 --- a/Arduino/CanGrow/CanGrow.ino +++ b/Arduino/CanGrow/CanGrow.ino @@ -24,16 +24,22 @@ #include // https://github.com/adafruit/Adafruit_SSD1306 #include -// https://github.com/adafruit/DHT-sensor-library -#include "DHT.h" +// https://github.com/adafruit/Adafruit_BME280_Library/ +#include +#include // https://github.com/bblanchon/ArduinoJson #include // https://github.com/arduino-libraries/NTPClient #include // https://github.com/PaulStoffregen/Time #include +// DHT support dropped +// https://github.com/adafruit/DHT-sensor-library +// #include "DHT.h" -// CanGrow header files +/* + * CanGrow header files + */ #include "CanGrow_PinAssignments.h" #include "CanGrow_Init.h" @@ -54,7 +60,7 @@ void setup() { // setup pins pinMode(PinFAN, OUTPUT); - pinMode(PINdht, INPUT); + //pinMode(PINdht, INPUT); pinMode(PINwaterlevel, OUTPUT); pinMode(PINsoilmoisture, OUTPUT); pinMode(PinLED, OUTPUT); @@ -88,10 +94,12 @@ void setup() { // whats get the cursor somewhere over the place Serial.println("420"); Serial.println(".:: CanGrow Start ::."); - + + Serial.println(":: initialise I2C ::"); // initialise Wire for I2C Wire.begin(); + Serial.println(":: initialise display ::"); // initialise I2C display display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // Address 0x3C for 128x64 display.clearDisplay(); @@ -105,11 +113,20 @@ void setup() { display.drawBitmap(0, 0, bmpCanGrow_Logo, 128, 32, WHITE); display.display(); + Serial.println(":: initialise chirp sensor if present ::"); // reset chirp writeI2CRegister8bit(0x20, 6); //TODO: Do only, when configured // initialise DHT11 - dht.begin(); //TODO: Do only, when configured + // dht support dropped + // dht.begin(); //TODO: Do only, when configured + + // initialise BME280 + Serial.println(":: initialise BME280 sensor ::"); + // ToDo: let the user configure somewhere the ID of the BME280 sensor + if(!bme.begin(0x76)) { + Serial.println("!! Cannot find BME280 on I2C bus. Please check connection or ID"); + } Serial.println("To wipe the EEPROM saved data, set D4 (PinWIPE) to LOW - NOW! (2 seconds left)"); // wait a few seconds to let the user pull D4 down to wipe EEPROM diff --git a/Arduino/CanGrow/CanGrow_PinAssignments.h b/Arduino/CanGrow/CanGrow_PinAssignments.h index 5d59c03..2c274a6 100644 --- a/Arduino/CanGrow/CanGrow_PinAssignments.h +++ b/Arduino/CanGrow/CanGrow_PinAssignments.h @@ -18,7 +18,7 @@ // D0 is HIGH at boot, no PWM const uint8_t PinPUMP = D0; // If D3 is pulled to LOW, boot fails -const uint8_t PINdht = D3; +//const uint8_t PINdht = D3; // D4 is HIGH at boot, boot fail if pulled to LOW // During Start Screen you can pull D4 to LOW to wipe saved data in EEPROM // DO NOT PULL D4 DOWN AT WHEN POWERING ON !!! BOOT WILL FAIL diff --git a/Arduino/CanGrow/CanGrow_Sensors.h b/Arduino/CanGrow/CanGrow_Sensors.h index 8c54700..d0c58aa 100644 --- a/Arduino/CanGrow/CanGrow_Sensors.h +++ b/Arduino/CanGrow/CanGrow_Sensors.h @@ -2,8 +2,17 @@ * DHT Stuff * */ -#define DHTTYPE DHT11 -DHT dht(PINdht, DHTTYPE); +// DHT support dropped to get a free pin for fan PWM +//#define DHTTYPE DHT11 +//DHT dht(PINdht, DHTTYPE); + +/* + * BME280 Stuff + * + */ + +#define SEALEVELPRESSURE_HPA (1013.25) +Adafruit_BME280 bme; /* @@ -94,8 +103,11 @@ float getTemperature(byte tempSensor) { switch(tempSensor) { case 1: + // read temperature from BME280 + temperature = bme.readTemperature(); // read temperature from DHT11 - temperature = dht.readTemperature(); + // dht support dropped + // temperature = dht.readTemperature(); break; case 2: // read temperature from chrip I2C @@ -110,7 +122,9 @@ float getTemperature(byte tempSensor) { } float getHumidity() { - return dht.readHumidity(); + // dht support dropped + // return dht.readHumidity(); + return bme.readHumidity(); } int getSoilmoisture(byte moistureSensor, bool returnRAW = false) { diff --git a/Arduino/CanGrow/CanGrow_WebFunctions.h b/Arduino/CanGrow/CanGrow_WebFunctions.h index 657edea..0a6990b 100644 --- a/Arduino/CanGrow/CanGrow_WebFunctions.h +++ b/Arduino/CanGrow/CanGrow_WebFunctions.h @@ -550,7 +550,7 @@ void WEBsystemSettings() { body += "\n"; } body += "\n"; - body += "\n"; + body += "\n"; body += "
\n"; // SoilmoistureLow byte @@ -563,8 +563,8 @@ void WEBsystemSettings() { if(configured == false) { body += "\n"; } - body += "\n"; - body += "\n"; + body += "\n"; + body += "\n"; body += "
\n"; // NtpOffset int @@ -1018,9 +1018,11 @@ void APIgetDebug() { objSensors["chirp"]["soilmoistureRAW"] = getSoilmoisture(2, true); objSensors["chirp"]["light"] = getLightchirp(); - // DHT11/22 - objSensors["dht"]["temperature"] = getTemperature(1); - objSensors["dht"]["humidity"] = getHumidity(); + // BME280 + objSensors["bme280"]["temperature"] = getTemperature(1); + objSensors["bme280"]["humidity"] = getHumidity(); + objSensors["bme280"]["preassure"] = bme.readPressure() / 100.0F; + objSensors["bme280"]["appAltitude"] = bme.readAltitude(SEALEVELPRESSURE_HPA); // Analog objSensors["analog"]["soilmoisture"] = getSoilmoisture(1); diff --git a/playground/html/systemSettings/index.html b/playground/html/systemSettings/index.html new file mode 100644 index 0000000..35c474f --- /dev/null +++ b/playground/html/systemSettings/index.html @@ -0,0 +1,199 @@ + + + + + + +CanGrow - Ruderalis Indica + + + + + +

⚙ System settings

here you can set which features and sensors you use

+ + + + + + + + + + + + + + + + Use relais for FAN: + + + PUMP ON time: Seconds
+ Soilmoisture sensor:
+ Soilmoisture low: %
+ Temperature sensor:
+ NTP offset: Hours
+ Maintenance Duration: Seconds
+ + +
Use FAN: + +
Use PUMP: +
Use relais for LED: + + +
+
+ +
+ +