firmware wip - PINsoilmoisture is always HIGH and gets only low when waterlevel is measured

This commit is contained in:
Marcus 2024-05-21 00:30:39 +02:00
parent 71b846c5b0
commit d396830026
3 changed files with 27 additions and 19 deletions

View file

@ -65,12 +65,16 @@ void setup() {
// set all OUTPUT to low
digitalWrite(PinFAN, LOW);
digitalWrite(PINwaterlevel, LOW);
digitalWrite(PINsoilmoisture, LOW);
digitalWrite(PinLED, LOW);
digitalWrite(PinPUMP, LOW);
// except PINsoilmoisture
// PINsoilmoisture is always HIGH and gets LOW in moment of waterlevel measurement
digitalWrite(PINsoilmoisture, HIGH);
// set PWM frequency lower to avoid annoying noises
// in combination with 47uF at fan output, 220Hz is kinda sweetspot
// in combination with 47uF at fan output, 220Hz is kinda sweetspot for a fan
// but i guess putting just a cap in parallel for voltage regulation isnt a good idea
// low pass filter or buck converter would be better
// 220Hz is note A3 btw.
analogWriteFreq(220);

View file

@ -53,11 +53,13 @@ int getWaterlevel(bool returnRAW = false) {
short waterlevelRAW = 0;
byte waterlevel = 0;
// disable first PINsoilmoisture
digitalWrite(PINsoilmoisture, LOW);
// enable Vcc for water level sensor
digitalWrite(PINwaterlevel, HIGH);
// wait a bit to let the circuit stabilize
// TODO: replace delay() with millis()
delay(50);
delay(100);
// get the value
for(byte i = 0; i < 10 ; i++) {
@ -67,7 +69,8 @@ int getWaterlevel(bool returnRAW = false) {
// disable Vcc for the sensor to prevent electrolysis effect and release analog pin
digitalWrite(PINwaterlevel, LOW);
// and turn soilmoisture back on
digitalWrite(PINsoilmoisture, HIGH);
if( waterlevelRAW >= waterlevelOK) {
waterlevel = 0;
} else if( waterlevelRAW >= waterlevelWARN) {
@ -131,9 +134,9 @@ int getSoilmoisture(byte moistureSensor, bool returnRAW = false) {
wet = 180;
dry= 590;
digitalWrite(PINsoilmoisture, HIGH);
//digitalWrite(PINsoilmoisture, HIGH);
// wait a bit to let the circuit stabilize
delay(50);
//delay(50);
// get analog input value
// get values 10 times and get the middle for more precise data
@ -143,7 +146,7 @@ int getSoilmoisture(byte moistureSensor, bool returnRAW = false) {
soilmoisture = soilmoisture / 10;
// disable Vcc for the sensor to release analog pin
digitalWrite(PINsoilmoisture, LOW);
//digitalWrite(PINsoilmoisture, LOW);
break;
case 2:
// read soil moisture from chrip I2C

View file

@ -4,7 +4,7 @@
<head>
<meta charset='UTF-8'>
<meta name='viewport' content='width=device-width, initial-scale=1.0'>
<title>CanGrow - Amnesia Haze</title>
<title>CanGrow - Ruderalis Indica</title>
<link rel='stylesheet' type='text/css' href='gauge.css'>
<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>
@ -83,7 +83,7 @@ a:active {
text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.5);
}
.nav li a:hover , .activeMenu, .button:link:hover, input[type=button]:hover, input[type=submit]:hover, input[type=reset]:hover {
.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;
@ -102,18 +102,18 @@ a:active {
background: #292929;
}
.button, .button:link , input[type=button], input[type=submit], input[type=reset] {
.button, .button:link, .button:visited, input[type=button], input[type=submit], input[type=reset] {
background: #026b45;
color: #fff;
border-radius: 3px;
padding: 6px 12px;
padding: 8px 16px;
text-align: center;
text-decoration: none;
display: inline-block;
border: none;
}
.button:link:active, input[type=button]:active, input[type=submit]:active, input[type=reset]:active {
.button:link:active, .button:visited:active, input[type=button]:active, input[type=submit]:active, input[type=reset]:active {
background: #026b45;
color: #cae0d0;
}
@ -122,6 +122,7 @@ input[type=text], input[type=date], input[type=number], input[type=password], se
background: #cae0d0;
color: #1d211e;
border: 1px solid #026b45;
border-radius: 3px;
}
@media only screen and (min-width: 1280px) {
@ -132,14 +133,14 @@ input[type=text], input[type=date], input[type=number], input[type=password], se
</style>
</head>
<body>
<ul class='nav'><li><a href='/'>&#x1F331; Amnesia Haze</a></li>
<ul class='nav'><li><a href='/'>&#x1F331; Ruderalis Indica</a></li>
<li><a href='/growSettings' >&#128262; Grow settings</a></li>
<li><a href='/systemSettings' >&#9881; System settings</a></li>
<li><a href='/wifiSettings' >&#128225; WiFi settings</a></li>
<li><a href='/help' >&#x2753; Help</a></li>
<li><span class='MenuTime'>03:22:14</span></li>
<li><span class='MenuTime'>23:39:48</span></li>
<li><a href='https://git.la10cy.net/DeltaLima/CanGrow' target='_blank'>CanGrow v0.1</a></li>
</ul><div class='center'><h2>&#x1F331; Amnesia Haze</h2>
</ul><div class='center'><h2>&#x1F331; Ruderalis Indica</h2>
<div class='gaugeWrapper'>
<div class='gauge gauge--liveupdate spacer' id='gaugeTemperature' style='float:left; margin-right: 10px;'>
@ -197,10 +198,10 @@ input[type=text], input[type=date], input[type=number], input[type=password], se
var gaugeSoilmoisture = new Gauge(document.getElementById('gaugeSoilmoisture'));
</script>
<script>gaugeTemperature.value('nan', 42, ' °C'); gaugeHumidity.value('nan'); gaugeSoilmoisture.value('140'); </script>Grow started: 2024-05-08<br>
Day of Grow: 1<br>
<script>gaugeTemperature.value('21.10', 42, ' °C'); gaugeHumidity.value('59.00'); gaugeSoilmoisture.value('94'); </script>Grow started: 2024-04-12<br>
Day of Grow: 33<br>
Pump water level: <span style='color: red;'>Critical</span><br>
Growlight brightness: 100 %<br>
Growlight brightness: 69 %<br>
<form method='post' action='/switch'>
MOSFET<select id='output' name='output' >
<option disabled value='' selected hidden>---</option>