From d2e264db56dfc1e5fa8dbb1108c1a21513871aaf Mon Sep 17 00:00:00 2001 From: Marcus Date: Thu, 19 Sep 2024 02:11:57 +0200 Subject: [PATCH] firmware wip - quick hack inverted outputs for pcb v0.6 together. but watering now broke a bit --- Arduino/CanGrow/CanGrow.ino | 6 ++-- Arduino/CanGrow/CanGrow_SysFunctions.h | 40 +++++++++++++++++--------- Arduino/CanGrow/CanGrow_Version.h | 2 +- 3 files changed, 30 insertions(+), 18 deletions(-) diff --git a/Arduino/CanGrow/CanGrow.ino b/Arduino/CanGrow/CanGrow.ino index 9a8ef1d..6a44635 100644 --- a/Arduino/CanGrow/CanGrow.ino +++ b/Arduino/CanGrow/CanGrow.ino @@ -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); diff --git a/Arduino/CanGrow/CanGrow_SysFunctions.h b/Arduino/CanGrow/CanGrow_SysFunctions.h index 899e600..81e4a4a 100644 --- a/Arduino/CanGrow/CanGrow_SysFunctions.h +++ b/Arduino/CanGrow/CanGrow_SysFunctions.h @@ -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); } } diff --git a/Arduino/CanGrow/CanGrow_Version.h b/Arduino/CanGrow/CanGrow_Version.h index 68f50b0..62a125e 100644 --- a/Arduino/CanGrow/CanGrow_Version.h +++ b/Arduino/CanGrow/CanGrow_Version.h @@ -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";