firmware wip - drop support for DHT11/22, we use now BME280 I2C
This commit is contained in:
parent
fb68dee829
commit
efd62a43a1
5 changed files with 249 additions and 17 deletions
|
@ -24,16 +24,22 @@
|
||||||
#include <Adafruit_GFX.h>
|
#include <Adafruit_GFX.h>
|
||||||
// https://github.com/adafruit/Adafruit_SSD1306
|
// https://github.com/adafruit/Adafruit_SSD1306
|
||||||
#include <Adafruit_SSD1306.h>
|
#include <Adafruit_SSD1306.h>
|
||||||
// https://github.com/adafruit/DHT-sensor-library
|
// https://github.com/adafruit/Adafruit_BME280_Library/
|
||||||
#include "DHT.h"
|
#include <Adafruit_Sensor.h>
|
||||||
|
#include <Adafruit_BME280.h>
|
||||||
// https://github.com/bblanchon/ArduinoJson
|
// https://github.com/bblanchon/ArduinoJson
|
||||||
#include <ArduinoJson.h>
|
#include <ArduinoJson.h>
|
||||||
// https://github.com/arduino-libraries/NTPClient
|
// https://github.com/arduino-libraries/NTPClient
|
||||||
#include <NTPClient.h>
|
#include <NTPClient.h>
|
||||||
// https://github.com/PaulStoffregen/Time
|
// https://github.com/PaulStoffregen/Time
|
||||||
#include <TimeLib.h>
|
#include <TimeLib.h>
|
||||||
|
// 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_PinAssignments.h"
|
||||||
#include "CanGrow_Init.h"
|
#include "CanGrow_Init.h"
|
||||||
|
@ -54,7 +60,7 @@ void setup() {
|
||||||
|
|
||||||
// setup pins
|
// setup pins
|
||||||
pinMode(PinFAN, OUTPUT);
|
pinMode(PinFAN, OUTPUT);
|
||||||
pinMode(PINdht, INPUT);
|
//pinMode(PINdht, INPUT);
|
||||||
pinMode(PINwaterlevel, OUTPUT);
|
pinMode(PINwaterlevel, OUTPUT);
|
||||||
pinMode(PINsoilmoisture, OUTPUT);
|
pinMode(PINsoilmoisture, OUTPUT);
|
||||||
pinMode(PinLED, OUTPUT);
|
pinMode(PinLED, OUTPUT);
|
||||||
|
@ -89,9 +95,11 @@ void setup() {
|
||||||
Serial.println("420");
|
Serial.println("420");
|
||||||
Serial.println(".:: CanGrow Start ::.");
|
Serial.println(".:: CanGrow Start ::.");
|
||||||
|
|
||||||
|
Serial.println(":: initialise I2C ::");
|
||||||
// initialise Wire for I2C
|
// initialise Wire for I2C
|
||||||
Wire.begin();
|
Wire.begin();
|
||||||
|
|
||||||
|
Serial.println(":: initialise display ::");
|
||||||
// initialise I2C display
|
// initialise I2C display
|
||||||
display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // Address 0x3C for 128x64
|
display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // Address 0x3C for 128x64
|
||||||
display.clearDisplay();
|
display.clearDisplay();
|
||||||
|
@ -105,11 +113,20 @@ void setup() {
|
||||||
display.drawBitmap(0, 0, bmpCanGrow_Logo, 128, 32, WHITE);
|
display.drawBitmap(0, 0, bmpCanGrow_Logo, 128, 32, WHITE);
|
||||||
display.display();
|
display.display();
|
||||||
|
|
||||||
|
Serial.println(":: initialise chirp sensor if present ::");
|
||||||
// reset chirp
|
// reset chirp
|
||||||
writeI2CRegister8bit(0x20, 6); //TODO: Do only, when configured
|
writeI2CRegister8bit(0x20, 6); //TODO: Do only, when configured
|
||||||
|
|
||||||
// initialise DHT11
|
// 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)");
|
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
|
// wait a few seconds to let the user pull D4 down to wipe EEPROM
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
// D0 is HIGH at boot, no PWM
|
// D0 is HIGH at boot, no PWM
|
||||||
const uint8_t PinPUMP = D0;
|
const uint8_t PinPUMP = D0;
|
||||||
// If D3 is pulled to LOW, boot fails
|
// 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
|
// 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
|
// 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
|
// DO NOT PULL D4 DOWN AT WHEN POWERING ON !!! BOOT WILL FAIL
|
||||||
|
|
|
@ -2,8 +2,17 @@
|
||||||
* DHT Stuff
|
* DHT Stuff
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#define DHTTYPE DHT11
|
// DHT support dropped to get a free pin for fan PWM
|
||||||
DHT dht(PINdht, DHTTYPE);
|
//#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) {
|
switch(tempSensor) {
|
||||||
case 1:
|
case 1:
|
||||||
|
// read temperature from BME280
|
||||||
|
temperature = bme.readTemperature();
|
||||||
// read temperature from DHT11
|
// read temperature from DHT11
|
||||||
temperature = dht.readTemperature();
|
// dht support dropped
|
||||||
|
// temperature = dht.readTemperature();
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
// read temperature from chrip I2C
|
// read temperature from chrip I2C
|
||||||
|
@ -110,7 +122,9 @@ float getTemperature(byte tempSensor) {
|
||||||
}
|
}
|
||||||
|
|
||||||
float getHumidity() {
|
float getHumidity() {
|
||||||
return dht.readHumidity();
|
// dht support dropped
|
||||||
|
// return dht.readHumidity();
|
||||||
|
return bme.readHumidity();
|
||||||
}
|
}
|
||||||
|
|
||||||
int getSoilmoisture(byte moistureSensor, bool returnRAW = false) {
|
int getSoilmoisture(byte moistureSensor, bool returnRAW = false) {
|
||||||
|
|
|
@ -550,7 +550,7 @@ void WEBsystemSettings() {
|
||||||
body += "<option disabled value='' selected hidden>---</option>\n";
|
body += "<option disabled value='' selected hidden>---</option>\n";
|
||||||
}
|
}
|
||||||
body += "<option value='1'" + returnStrSelected(MoistureSensor_Type, 1) + ">Analog capacitive</option>\n";
|
body += "<option value='1'" + returnStrSelected(MoistureSensor_Type, 1) + ">Analog capacitive</option>\n";
|
||||||
body += "<option value='2'" + returnStrSelected(MoistureSensor_Type, 2) + ">I2C chirp</option>\n";
|
body += "<option value='2'" + returnStrSelected(MoistureSensor_Type, 2) + ">I2C Chirp</option>\n";
|
||||||
body += "</select><br>\n";
|
body += "</select><br>\n";
|
||||||
|
|
||||||
// SoilmoistureLow byte
|
// SoilmoistureLow byte
|
||||||
|
@ -563,8 +563,8 @@ void WEBsystemSettings() {
|
||||||
if(configured == false) {
|
if(configured == false) {
|
||||||
body += "<option disabled value='' selected hidden>---</option>\n";
|
body += "<option disabled value='' selected hidden>---</option>\n";
|
||||||
}
|
}
|
||||||
body += "<option value='1'" + returnStrSelected(TemperatureSensor_Type, 1) + ">DHT11/22</option>\n";
|
body += "<option value='1'" + returnStrSelected(TemperatureSensor_Type, 1) + ">I2C BME280</option>\n";
|
||||||
body += "<option value='2'" + returnStrSelected(TemperatureSensor_Type, 2) + ">I2C chirp</option>\n";
|
body += "<option value='2'" + returnStrSelected(TemperatureSensor_Type, 2) + ">I2C Chirp</option>\n";
|
||||||
body += "</select><br>\n";
|
body += "</select><br>\n";
|
||||||
|
|
||||||
// NtpOffset int
|
// NtpOffset int
|
||||||
|
@ -1018,9 +1018,11 @@ void APIgetDebug() {
|
||||||
objSensors["chirp"]["soilmoistureRAW"] = getSoilmoisture(2, true);
|
objSensors["chirp"]["soilmoistureRAW"] = getSoilmoisture(2, true);
|
||||||
objSensors["chirp"]["light"] = getLightchirp();
|
objSensors["chirp"]["light"] = getLightchirp();
|
||||||
|
|
||||||
// DHT11/22
|
// BME280
|
||||||
objSensors["dht"]["temperature"] = getTemperature(1);
|
objSensors["bme280"]["temperature"] = getTemperature(1);
|
||||||
objSensors["dht"]["humidity"] = getHumidity();
|
objSensors["bme280"]["humidity"] = getHumidity();
|
||||||
|
objSensors["bme280"]["preassure"] = bme.readPressure() / 100.0F;
|
||||||
|
objSensors["bme280"]["appAltitude"] = bme.readAltitude(SEALEVELPRESSURE_HPA);
|
||||||
|
|
||||||
// Analog
|
// Analog
|
||||||
objSensors["analog"]["soilmoisture"] = getSoilmoisture(1);
|
objSensors["analog"]["soilmoisture"] = getSoilmoisture(1);
|
||||||
|
|
199
playground/html/systemSettings/index.html
Normal file
199
playground/html/systemSettings/index.html
Normal file
|
@ -0,0 +1,199 @@
|
||||||
|
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset='UTF-8'>
|
||||||
|
<meta name='viewport' content='width=device-width, initial-scale=1.0'>
|
||||||
|
<title>CanGrow - Ruderalis Indica</title>
|
||||||
|
|
||||||
|
<link rel='icon' href='data:;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABmJLR0QAAAAAAAD5Q7t/AAAACXBIWXMAAAsTAAALEwEAmpwYAAABcElEQVQ4y42TzU/bQBDFf7Nx1qGuAYVgQSuo2khBggPhyIH//9AiJAQ9tEeLqCKiUD6sxF52OMSEBCdW57aa9968fTsr3V5XWVLPO6sANNL7ZRAMNeU6Ea4T1UEI6pr55kcAwhpMrYOpk2/r/yEQmKWkIonf+TZVgex4Fw0bIEtIAALF3gbZ8U5VwKa3PJ18JT9IpiLvyflBwuhLG5veVUM0/0aoCONPa2hQjWZ8uEVeupJnXSBwO8YOH8iTeAKc2Q4Xt2C1VZL93F7MjbK/bxDnp5Zn7b+So+9pdQ+K/Q5qJlrRj5Ts6DM+rK7Ih7Mr3HaM7jYQVZqXQ6Tb6yqBYdTfomhHiFfUyMI3f+01/z7RHNzTGDyWGThP63SA2d8EEfIkrgQpzmOvH0AV+3M4zegNpUwagAYG8Yp4BS0nl4Kz5Mpf0JXJMby6w/66Aa+M+9uE53/Iexsggq4ESOYWC0jmsBfX8xdXhcJjL4cLc3kBl8uJGQ/CrpAAAAAASUVORK5CYII='>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
color: #cae0d0;
|
||||||
|
background-color: #1d211e;
|
||||||
|
font-family: helvetica;
|
||||||
|
}
|
||||||
|
|
||||||
|
.center {
|
||||||
|
width: 100%;
|
||||||
|
margin: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1, h2, h3, h4, h5 {
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
a:link, a:visited {
|
||||||
|
color: #04AA6D;
|
||||||
|
}
|
||||||
|
a:hover {
|
||||||
|
color: #64AA6D;
|
||||||
|
}
|
||||||
|
a:active {
|
||||||
|
color: #04AA6D;
|
||||||
|
}
|
||||||
|
.infomsg , .warnmsg {
|
||||||
|
color: #fff;
|
||||||
|
border-radius: 3px;
|
||||||
|
padding: 4px;
|
||||||
|
width: fit-content; min-width: 200px; max-width: 420px;
|
||||||
|
margin: auto;
|
||||||
|
margin-bottom: 5px;
|
||||||
|
font-weight: bold;
|
||||||
|
text-align: center;
|
||||||
|
text-decoration: none;
|
||||||
|
text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.5);
|
||||||
|
}
|
||||||
|
.infomsg {
|
||||||
|
background: #04AA6D;
|
||||||
|
}
|
||||||
|
.warnmsg {
|
||||||
|
background: #aa4204;
|
||||||
|
}
|
||||||
|
.inputShort {
|
||||||
|
width: 42px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav {
|
||||||
|
background: #333;
|
||||||
|
width: 100%;
|
||||||
|
margin: auto;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
padding: 0;
|
||||||
|
position: relative;
|
||||||
|
border-radius: 3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav li {
|
||||||
|
display: inline-block;
|
||||||
|
list-style: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav li:first-of-type {
|
||||||
|
background: #026b45;
|
||||||
|
border-top-left-radius: 3px;
|
||||||
|
border-bottom-left-radius: 3px;
|
||||||
|
}
|
||||||
|
.nav li a , .nav span, .button, .button:link, input[type=button], input[type=submit], input[type=reset] {
|
||||||
|
color: #ddd;
|
||||||
|
display: block;
|
||||||
|
font-family: 'Lucida Sans Unicode', 'Lucida Grande', sans-serif;
|
||||||
|
font-size:0.8em;
|
||||||
|
padding: 10px 20px;
|
||||||
|
text-decoration: none;
|
||||||
|
text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.5);
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav li a:hover , .activeMenu, .button:link:hover, .button:visited:hover, input[type=button]:hover, input[type=submit]:hover, input[type=reset]:hover {
|
||||||
|
background: #04AA6D;
|
||||||
|
color: #fff;
|
||||||
|
border-radius: 3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav li a:active {
|
||||||
|
background: #026b45;
|
||||||
|
color: #cae0d0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.activeMenu {
|
||||||
|
background: #444;
|
||||||
|
}
|
||||||
|
|
||||||
|
.MenuTime {
|
||||||
|
background: #292929;
|
||||||
|
}
|
||||||
|
|
||||||
|
.button, .button:link, .button:visited, input[type=button], input[type=submit], input[type=reset] {
|
||||||
|
background: #026b45;
|
||||||
|
color: #fff;
|
||||||
|
border-radius: 3px;
|
||||||
|
padding: 6px 12px;
|
||||||
|
text-align: center;
|
||||||
|
text-decoration: none;
|
||||||
|
display: inline-block;
|
||||||
|
border: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.button:link:active, .button:visited:active, input[type=button]:active, input[type=submit]:active, input[type=reset]:active {
|
||||||
|
background: #026b45;
|
||||||
|
color: #cae0d0;
|
||||||
|
}
|
||||||
|
|
||||||
|
input[type=text], input[type=date], input[type=number], input[type=password], select {
|
||||||
|
background: #cae0d0;
|
||||||
|
color: #1d211e;
|
||||||
|
border: 1px solid #026b45;
|
||||||
|
border-radius: 3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media only screen and (min-width: 1280px) {
|
||||||
|
.center, .nav {
|
||||||
|
width: 60%; min-width: 420px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<ul class='nav'><li><a href='/'>🌱 Ruderalis Indica</a></li>
|
||||||
|
<li><a href='/growSettings' >🔆 Grow settings</a></li>
|
||||||
|
<li><a href='/systemSettings' class='activeMenu'>⚙ System settings</a></li>
|
||||||
|
<li><a href='/wifiSettings' >📡 WiFi settings</a></li>
|
||||||
|
<li><a href='/help' >❓ Help</a></li>
|
||||||
|
<li><span class='MenuTime'>00:03:39</span></li>
|
||||||
|
<li><a href='https://git.la10cy.net/DeltaLima/CanGrow' target='_blank'>CanGrow v0.1</a></li>
|
||||||
|
</ul><div class='center'><h2>⚙ System settings</h2><p>here you can set which features and sensors you use<br></p><form method='post' action='/systemSettings/save'>
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<td>Use FAN: </td>
|
||||||
|
<td>
|
||||||
|
<select id='UseFan' name='UseFan' required>
|
||||||
|
<option value='1' selected >Yes</option>
|
||||||
|
<option value='0'>No</option>
|
||||||
|
</select>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Use PUMP: </td>
|
||||||
|
<td><select id='UsePump' name='UsePump' required>
|
||||||
|
<option value='1' selected >Yes</option>
|
||||||
|
<option value='0'>No</option>
|
||||||
|
</select>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td>Use relais for LED:
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<select id='UseLEDrelais' name='UseLEDrelais' required>
|
||||||
|
<option value='1'>Yes</option>
|
||||||
|
<option value='0' selected >No</option>
|
||||||
|
</select>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td></td>Use relais for FAN: </td>
|
||||||
|
<select id='UseFANrelais' name='UseFANrelais' required>
|
||||||
|
<option value='1'>Yes</option>
|
||||||
|
<option value='0' selected >No</option>
|
||||||
|
</select>
|
||||||
|
</tr>
|
||||||
|
PUMP ON time: <input class='inputShort' type='number' name='PumpOnTime' min='0' max='255' value='3' required> Seconds<br>
|
||||||
|
Soilmoisture sensor: <select id='MoistureSensor_Type' name='MoistureSensor_Type' required>
|
||||||
|
<option value='1' selected >Analog capacitive</option>
|
||||||
|
<option value='2'>I2C chirp</option>
|
||||||
|
</select><br>
|
||||||
|
Soilmoisture low: <input class='inputShort' type='number' name='SoilmoistureLow' min='0' value='20' required> %<br>
|
||||||
|
Temperature sensor: <select id='TemperatureSensor_Type' name='TemperatureSensor_Type' required>
|
||||||
|
<option value='1' selected >DHT11/22</option>
|
||||||
|
<option value='2'>I2C chirp</option>
|
||||||
|
</select><br>
|
||||||
|
NTP offset: <input class='inputShort' type='number' name='NtpOffset' min='-12' max='14' value='2' required> Hours<br>
|
||||||
|
Maintenance Duration: <input class='inputShort' type='number' name='MaintenanceDuration' min='0' max='900' value='300' required> Seconds<br>
|
||||||
|
<input type='submit' value='Save'>
|
||||||
|
|
||||||
|
</table>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
Loading…
Reference in a new issue