firmware wip - quick hack inverted outputs for pcb v0.6 together. but watering now broke a bit
This commit is contained in:
parent
56d9756744
commit
d2e264db56
3 changed files with 30 additions and 18 deletions
|
@ -71,10 +71,10 @@ void setup() {
|
|||
|
||||
|
||||
// set all OUTPUT to low
|
||||
digitalWrite(PinFAN, LOW);
|
||||
digitalWrite(PinFAN, HIGH);
|
||||
digitalWrite(PINwaterlevel, LOW);
|
||||
digitalWrite(PinLED, LOW);
|
||||
digitalWrite(PinPUMP, LOW);
|
||||
digitalWrite(PinLED, HIGH);
|
||||
digitalWrite(PinPUMP, HIGH);
|
||||
// except PINsoilmoisture
|
||||
// PINsoilmoisture is always HIGH and gets LOW in moment of waterlevel measurement
|
||||
digitalWrite(PINsoilmoisture, LOW);
|
||||
|
|
|
@ -439,9 +439,9 @@ void setOutput(byte Output, byte OutputState) {
|
|||
//~ Serial.println(UseRelais);
|
||||
|
||||
if( (UseRelais == true) || (OutputPin == PinPUMP) ) {
|
||||
digitalWrite(OutputPin, OutputState);
|
||||
digitalWrite(OutputPin, 1 - OutputState);
|
||||
} else {
|
||||
analogWrite(OutputPin, OutputState);
|
||||
analogWrite(OutputPin, 255 - OutputState);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -661,11 +661,13 @@ void controlPUMP() {
|
|||
// when PumpOnManuel is true, turn pump on for PumpOnTime seconds
|
||||
if(PumpOnManual == true) {
|
||||
if(PumpOnTimePassed < PumpOnTime) {
|
||||
digitalWrite(PinPUMP, HIGH);
|
||||
setOutput(3, 1)
|
||||
//digitalWrite(PinPUMP, HIGH);
|
||||
PumpOnTimePassed++;
|
||||
} else {
|
||||
PumpOnManual = false;
|
||||
digitalWrite(PinPUMP, LOW);
|
||||
setOutput(3, 0);
|
||||
//digitalWrite(PinPUMP, LOW);
|
||||
EEPROM.put(237, PumpLastOn);
|
||||
PumpOnTimePassed = 0;
|
||||
}
|
||||
|
@ -677,17 +679,20 @@ void controlPUMP() {
|
|||
if( (timeClient.getEpochTime() - PumpLastOn) >= (PumpInterval) ) { // TODO: * 24 * 60 * 60 PumpInterval
|
||||
// only water as long PumpOnTime
|
||||
if(PumpOnTimePassed < PumpOnTime) {
|
||||
digitalWrite(PinPUMP, HIGH);
|
||||
setOutput(3, 1);
|
||||
//digitalWrite(PinPUMP, HIGH);
|
||||
PumpOnTimePassed++;
|
||||
} else {
|
||||
digitalWrite(PinPUMP, LOW);
|
||||
setOutput(3, 0);
|
||||
//digitalWrite(PinPUMP, LOW);
|
||||
PumpLastOn = timeClient.getEpochTime();
|
||||
// write the value to EEPROM for the case ESP gets restarted
|
||||
EEPROM.put(237, PumpLastOn);
|
||||
PumpOnTimePassed = 0;
|
||||
}
|
||||
} else {
|
||||
digitalWrite(PinPUMP, LOW);
|
||||
setOutput(3, 0);
|
||||
//digitalWrite(PinPUMP, LOW);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -696,16 +701,19 @@ void controlPUMP() {
|
|||
if( (valSoilmoistureAvg < SoilmoistureLow) || ( (valSoilmoistureAvg >= SoilmoistureLow) && ( (PumpOnTimePassed > 0) && (PumpOnTimePassed <= PumpOnTime) ) ) ) {
|
||||
// check if we alerady exceeded max PumpOnTime
|
||||
if(PumpOnTimePassed < PumpOnTime) {
|
||||
digitalWrite(PinPUMP, HIGH);
|
||||
setOutput(3, 1);
|
||||
//digitalWrite(PinPUMP, HIGH);
|
||||
PumpOnTimePassed++;
|
||||
} else {
|
||||
digitalWrite(PinPUMP, LOW);
|
||||
setOutput(3, 0);
|
||||
//digitalWrite(PinPUMP, LOW);
|
||||
PumpLastOn = timeClient.getEpochTime();
|
||||
PumpOnTimePassed = 0;
|
||||
}
|
||||
// when valSoilmoistureAvg is greater then the Low value,
|
||||
} else {
|
||||
digitalWrite(PinPUMP, LOW);
|
||||
setOutput(3, 0);
|
||||
//digitalWrite(PinPUMP, LOW);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -717,17 +725,20 @@ void controlPUMP() {
|
|||
) ) {
|
||||
// check if we alerady exceeded max PumpOnTime
|
||||
if(PumpOnTimePassed < PumpOnTime) {
|
||||
digitalWrite(PinPUMP, HIGH);
|
||||
setOutput(3, 1);
|
||||
//digitalWrite(PinPUMP, HIGH);
|
||||
PumpOnTimePassed++;
|
||||
} else {
|
||||
digitalWrite(PinPUMP, LOW);
|
||||
setOutput(3, 0);
|
||||
//digitalWrite(PinPUMP, LOW);
|
||||
PumpLastOn = timeClient.getEpochTime();
|
||||
EEPROM.put(237, PumpLastOn);
|
||||
PumpOnTimePassed = 0;
|
||||
}
|
||||
// when valSoilmoistureAvg is greater then the Low value,
|
||||
} else {
|
||||
digitalWrite(PinPUMP, LOW);
|
||||
setOutput(3, 0);
|
||||
//digitalWrite(PinPUMP, LOW);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -735,6 +746,7 @@ void controlPUMP() {
|
|||
}
|
||||
} else {
|
||||
// ensure pump is off when it should be off
|
||||
digitalWrite(PinPUMP, LOW);
|
||||
setOutput(3, 0);
|
||||
//digitalWrite(PinPUMP, LOW);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* CanGrow_Version.h gets generated from cangrow.sh */
|
||||
|
||||
const char* CanGrowVer = "0.1-dev";
|
||||
const char* CanGrowBuild = "1a1fd39-20240912013347";
|
||||
const char* CanGrowBuild = "56d9756-20240919020116";
|
||||
|
||||
|
|
Loading…
Reference in a new issue