firmware wip - fine tune soilmoisture values, add esp32-cam support

This commit is contained in:
Marcus 2024-05-23 02:09:19 +02:00
parent 9022743127
commit 6454a090d1
7 changed files with 64 additions and 22 deletions

View file

@ -75,7 +75,7 @@ void setup() {
digitalWrite(PinPUMP, LOW); digitalWrite(PinPUMP, LOW);
// except PINsoilmoisture // except PINsoilmoisture
// PINsoilmoisture is always HIGH and gets LOW in moment of waterlevel measurement // PINsoilmoisture is always HIGH and gets LOW in moment of waterlevel measurement
digitalWrite(PINsoilmoisture, HIGH); digitalWrite(PINsoilmoisture, LOW);
// set PWM frequency lower to avoid annoying noises // set PWM frequency lower to avoid annoying noises
// in combination with 47uF at fan output, 220Hz is kinda sweetspot for a fan // in combination with 47uF at fan output, 220Hz is kinda sweetspot for a fan

View file

@ -30,10 +30,16 @@ body {
} }
.center { .center {
width: 100%; width: 100%;
margin: auto; margin: auto;
} }
.centered {
display: block;
margin-left: auto;
margin-right: auto;
}
h1, h2, h3, h4, h5 { h1, h2, h3, h4, h5 {
text-align: center; text-align: center;
} }

View file

@ -92,7 +92,8 @@ bool UseLEDrelais;
bool UseFANrelais; bool UseFANrelais;
// Which temperature sensor to use? // Which temperature sensor to use?
byte TemperatureSensor_Type; byte TemperatureSensor_Type;
unsigned short MaintenanceDuration = 60; unsigned short MaintenanceDuration = 300;
char Esp32CamIP[16];
// //
// Grow Stuff // Grow Stuff

View file

@ -147,14 +147,14 @@ int getSoilmoisture(byte moistureSensor, bool returnRAW = false) {
// read analog value from analog moisture sensor // read analog value from analog moisture sensor
wet = 180; wet = 180;
// this value was measured in air, without contact to anything // this value was measured in air, without contact to anything
// dry= 590; //dry= 590;
// was measured in dry soil, not bone dry but really dry (6 days no watering) // was measured in dry soil, not bone dry but really dry (6 days no watering)
dry = 300; dry = 360;
//digitalWrite(PINsoilmoisture, HIGH); digitalWrite(PINsoilmoisture, HIGH);
// wait a bit to let the circuit stabilize // wait a bit to let the circuit stabilize
//delay(50); delay(50);
// get analog input value // get analog input value
// get values 10 times and get the middle for more precise data // get values 10 times and get the middle for more precise data
@ -164,11 +164,15 @@ int getSoilmoisture(byte moistureSensor, bool returnRAW = false) {
soilmoisture = soilmoisture / 10; soilmoisture = soilmoisture / 10;
// disable Vcc for the sensor to release analog pin // disable Vcc for the sensor to release analog pin
//digitalWrite(PINsoilmoisture, LOW); digitalWrite(PINsoilmoisture, LOW);
break; break;
case 2: case 2:
// read soil moisture from chrip I2C // read soil moisture from chrip I2C
wet = 560; // this value was measured in water
// wet = 560;
// measured in fresh watered soil
wet = 390;
dry= 250; dry= 250;
// get raw value from I2C chirp sensor // get raw value from I2C chirp sensor

View file

@ -101,9 +101,10 @@ bool loadEEPROM() {
* 215 UseFANrelais * 215 UseFANrelais
* 216 PinFANPWM * 216 PinFANPWM
* 217 SunFade * 217 SunFade
* 218 SunFadeDuration * 218 SunFadeDuration
* 219 MaintenanceDuration * 219 MaintenanceDuration (2 byte)
* 221 .. * 221 Esp32CamIP (16 byte)
* 237 ...
* *
*/ */
@ -165,6 +166,8 @@ bool loadEEPROM() {
EEPROM.get(215, UseFANrelais); EEPROM.get(215, UseFANrelais);
// size is 2 byte // size is 2 byte
EEPROM.get(219, MaintenanceDuration); EEPROM.get(219, MaintenanceDuration);
// size is 16 byte
EEPROM.get(221, Esp32CamIP);
} }
// TODO auth does not work atm // TODO auth does not work atm
// EEPROM.get(160, WebUiUsername); // EEPROM.get(160, WebUiUsername);

View file

@ -324,7 +324,16 @@ void WEBroot() {
body += valSoilmoisture; body += valSoilmoisture;
body += "'); "; body += "'); ";
body += "</script>"; body += "</script><br>\n";
// when an ESP32-Cam IP is given, display picture from it
if(strlen(Esp32CamIP) > 0) {
body += "<img class='centered' src='http://";
body += Esp32CamIP;
body += "/capture' alt='Image capture from ESP32CAM at ";
body += Esp32CamIP;
body += "'>\n<br>\n";
}
body += "Grow started: "; body += "Grow started: ";
body += returnStrDateFromEpoch(GrowStart); body += returnStrDateFromEpoch(GrowStart);
@ -575,7 +584,13 @@ void WEBsystemSettings() {
body += "Maintenance Duration: <input class='inputShort' type='number' name='MaintenanceDuration' min='0' max='900' value='"; body += "Maintenance Duration: <input class='inputShort' type='number' name='MaintenanceDuration' min='0' max='900' value='";
body += MaintenanceDuration; body += MaintenanceDuration;
body += "' required> Seconds<br>\n"; body += "' required> Seconds<br>\n";
body += "ESP32-Cam IP (optional): <input type='text' name='Esp32CamIP' maxlength='16' value='";
body += Esp32CamIP;
body += "' ><br>\n";
body += "<input type='submit' value='Save'>\n"; body += "<input type='submit' value='Save'>\n";
body += "</form>\n"; body += "</form>\n";
@ -764,6 +779,9 @@ void POSTsystemSettings() {
UseFANrelais = webserver.arg("UseFANrelais").toInt(); UseFANrelais = webserver.arg("UseFANrelais").toInt();
TemperatureSensor_Type = webserver.arg("TemperatureSensor_Type").toInt(); TemperatureSensor_Type = webserver.arg("TemperatureSensor_Type").toInt();
MaintenanceDuration = webserver.arg("MaintenanceDuration").toInt(); MaintenanceDuration = webserver.arg("MaintenanceDuration").toInt();
String Esp32CamIP_tmp = webserver.arg("Esp32CamIP");
Esp32CamIP_tmp.toCharArray(Esp32CamIP, 221);
configured = true; configured = true;
@ -788,6 +806,7 @@ void POSTsystemSettings() {
// size is 1 byte // size is 1 byte
EEPROM.put(215, UseFANrelais); EEPROM.put(215, UseFANrelais);
EEPROM.put(219, MaintenanceDuration); EEPROM.put(219, MaintenanceDuration);
EEPROM.put(221, Esp32CamIP);
// write data to EEPROM // write data to EEPROM
EEPROM.commit(); EEPROM.commit();

View file

@ -15,10 +15,16 @@ body {
} }
.center { .center {
width: 100%; width: 100%;
margin: auto; margin: auto;
} }
.centered {
display: block;
margin-left: auto;
margin-right: auto;
}
h1, h2, h3, h4, h5 { h1, h2, h3, h4, h5 {
text-align: center; text-align: center;
} }
@ -106,7 +112,7 @@ a:active {
background: #026b45; background: #026b45;
color: #fff; color: #fff;
border-radius: 3px; border-radius: 3px;
padding: 8px 16px; padding: 6px 12px;
text-align: center; text-align: center;
text-decoration: none; text-decoration: none;
display: inline-block; display: inline-block;
@ -138,7 +144,7 @@ input[type=text], input[type=date], input[type=number], input[type=password], se
<li><a href='/systemSettings' >&#9881; System settings</a></li> <li><a href='/systemSettings' >&#9881; System settings</a></li>
<li><a href='/wifiSettings' >&#128225; WiFi settings</a></li> <li><a href='/wifiSettings' >&#128225; WiFi settings</a></li>
<li><a href='/help' >&#x2753; Help</a></li> <li><a href='/help' >&#x2753; Help</a></li>
<li><span class='MenuTime'>23:39:48</span></li> <li><span class='MenuTime'>01:53:31</span></li>
<li><a href='https://git.la10cy.net/DeltaLima/CanGrow' target='_blank'>CanGrow v0.1</a></li> <li><a href='https://git.la10cy.net/DeltaLima/CanGrow' target='_blank'>CanGrow v0.1</a></li>
</ul><div class='center'><h2>&#x1F331; Ruderalis Indica</h2> </ul><div class='center'><h2>&#x1F331; Ruderalis Indica</h2>
@ -198,10 +204,13 @@ input[type=text], input[type=date], input[type=number], input[type=password], se
var gaugeSoilmoisture = new Gauge(document.getElementById('gaugeSoilmoisture')); var gaugeSoilmoisture = new Gauge(document.getElementById('gaugeSoilmoisture'));
</script> </script>
<script>gaugeTemperature.value('21.10', 42, ' °C'); gaugeHumidity.value('59.00'); gaugeSoilmoisture.value('94'); </script>Grow started: 2024-04-12<br> <script>gaugeTemperature.value('21.27', 42, ' °C'); gaugeHumidity.value('61.83'); gaugeSoilmoisture.value('98'); </script><br>
Day of Grow: 33<br> <img class='centered' src='http://192.168.30.6/capture' alt='Image capture from ESP32CAM at 192.168.30.6'>
<br>
Grow started: 2024-04-12<br>
Day of Grow: 41<br>
Pump water level: <span style='color: red;'>Critical</span><br> Pump water level: <span style='color: red;'>Critical</span><br>
Growlight brightness: 69 %<br> Growlight brightness: 100 %<br>
<form method='post' action='/switch'> <form method='post' action='/switch'>
MOSFET<select id='output' name='output' > MOSFET<select id='output' name='output' >
<option disabled value='' selected hidden>---</option> <option disabled value='' selected hidden>---</option>