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
|
// set all OUTPUT to low
|
||||||
digitalWrite(PinFAN, LOW);
|
digitalWrite(PinFAN, HIGH);
|
||||||
digitalWrite(PINwaterlevel, LOW);
|
digitalWrite(PINwaterlevel, LOW);
|
||||||
digitalWrite(PinLED, LOW);
|
digitalWrite(PinLED, HIGH);
|
||||||
digitalWrite(PinPUMP, LOW);
|
digitalWrite(PinPUMP, HIGH);
|
||||||
// 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, LOW);
|
digitalWrite(PINsoilmoisture, LOW);
|
||||||
|
|
|
@ -439,9 +439,9 @@ void setOutput(byte Output, byte OutputState) {
|
||||||
//~ Serial.println(UseRelais);
|
//~ Serial.println(UseRelais);
|
||||||
|
|
||||||
if( (UseRelais == true) || (OutputPin == PinPUMP) ) {
|
if( (UseRelais == true) || (OutputPin == PinPUMP) ) {
|
||||||
digitalWrite(OutputPin, OutputState);
|
digitalWrite(OutputPin, 1 - OutputState);
|
||||||
} else {
|
} else {
|
||||||
analogWrite(OutputPin, OutputState);
|
analogWrite(OutputPin, 255 - OutputState);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -661,11 +661,13 @@ void controlPUMP() {
|
||||||
// when PumpOnManuel is true, turn pump on for PumpOnTime seconds
|
// when PumpOnManuel is true, turn pump on for PumpOnTime seconds
|
||||||
if(PumpOnManual == true) {
|
if(PumpOnManual == true) {
|
||||||
if(PumpOnTimePassed < PumpOnTime) {
|
if(PumpOnTimePassed < PumpOnTime) {
|
||||||
digitalWrite(PinPUMP, HIGH);
|
setOutput(3, 1)
|
||||||
|
//digitalWrite(PinPUMP, HIGH);
|
||||||
PumpOnTimePassed++;
|
PumpOnTimePassed++;
|
||||||
} else {
|
} else {
|
||||||
PumpOnManual = false;
|
PumpOnManual = false;
|
||||||
digitalWrite(PinPUMP, LOW);
|
setOutput(3, 0);
|
||||||
|
//digitalWrite(PinPUMP, LOW);
|
||||||
EEPROM.put(237, PumpLastOn);
|
EEPROM.put(237, PumpLastOn);
|
||||||
PumpOnTimePassed = 0;
|
PumpOnTimePassed = 0;
|
||||||
}
|
}
|
||||||
|
@ -677,17 +679,20 @@ void controlPUMP() {
|
||||||
if( (timeClient.getEpochTime() - PumpLastOn) >= (PumpInterval) ) { // TODO: * 24 * 60 * 60 PumpInterval
|
if( (timeClient.getEpochTime() - PumpLastOn) >= (PumpInterval) ) { // TODO: * 24 * 60 * 60 PumpInterval
|
||||||
// only water as long PumpOnTime
|
// only water as long PumpOnTime
|
||||||
if(PumpOnTimePassed < PumpOnTime) {
|
if(PumpOnTimePassed < PumpOnTime) {
|
||||||
digitalWrite(PinPUMP, HIGH);
|
setOutput(3, 1);
|
||||||
|
//digitalWrite(PinPUMP, HIGH);
|
||||||
PumpOnTimePassed++;
|
PumpOnTimePassed++;
|
||||||
} else {
|
} else {
|
||||||
digitalWrite(PinPUMP, LOW);
|
setOutput(3, 0);
|
||||||
|
//digitalWrite(PinPUMP, LOW);
|
||||||
PumpLastOn = timeClient.getEpochTime();
|
PumpLastOn = timeClient.getEpochTime();
|
||||||
// write the value to EEPROM for the case ESP gets restarted
|
// write the value to EEPROM for the case ESP gets restarted
|
||||||
EEPROM.put(237, PumpLastOn);
|
EEPROM.put(237, PumpLastOn);
|
||||||
PumpOnTimePassed = 0;
|
PumpOnTimePassed = 0;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
digitalWrite(PinPUMP, LOW);
|
setOutput(3, 0);
|
||||||
|
//digitalWrite(PinPUMP, LOW);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -696,16 +701,19 @@ void controlPUMP() {
|
||||||
if( (valSoilmoistureAvg < SoilmoistureLow) || ( (valSoilmoistureAvg >= SoilmoistureLow) && ( (PumpOnTimePassed > 0) && (PumpOnTimePassed <= PumpOnTime) ) ) ) {
|
if( (valSoilmoistureAvg < SoilmoistureLow) || ( (valSoilmoistureAvg >= SoilmoistureLow) && ( (PumpOnTimePassed > 0) && (PumpOnTimePassed <= PumpOnTime) ) ) ) {
|
||||||
// check if we alerady exceeded max PumpOnTime
|
// check if we alerady exceeded max PumpOnTime
|
||||||
if(PumpOnTimePassed < PumpOnTime) {
|
if(PumpOnTimePassed < PumpOnTime) {
|
||||||
digitalWrite(PinPUMP, HIGH);
|
setOutput(3, 1);
|
||||||
|
//digitalWrite(PinPUMP, HIGH);
|
||||||
PumpOnTimePassed++;
|
PumpOnTimePassed++;
|
||||||
} else {
|
} else {
|
||||||
digitalWrite(PinPUMP, LOW);
|
setOutput(3, 0);
|
||||||
|
//digitalWrite(PinPUMP, LOW);
|
||||||
PumpLastOn = timeClient.getEpochTime();
|
PumpLastOn = timeClient.getEpochTime();
|
||||||
PumpOnTimePassed = 0;
|
PumpOnTimePassed = 0;
|
||||||
}
|
}
|
||||||
// when valSoilmoistureAvg is greater then the Low value,
|
// when valSoilmoistureAvg is greater then the Low value,
|
||||||
} else {
|
} else {
|
||||||
digitalWrite(PinPUMP, LOW);
|
setOutput(3, 0);
|
||||||
|
//digitalWrite(PinPUMP, LOW);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -717,17 +725,20 @@ void controlPUMP() {
|
||||||
) ) {
|
) ) {
|
||||||
// check if we alerady exceeded max PumpOnTime
|
// check if we alerady exceeded max PumpOnTime
|
||||||
if(PumpOnTimePassed < PumpOnTime) {
|
if(PumpOnTimePassed < PumpOnTime) {
|
||||||
digitalWrite(PinPUMP, HIGH);
|
setOutput(3, 1);
|
||||||
|
//digitalWrite(PinPUMP, HIGH);
|
||||||
PumpOnTimePassed++;
|
PumpOnTimePassed++;
|
||||||
} else {
|
} else {
|
||||||
digitalWrite(PinPUMP, LOW);
|
setOutput(3, 0);
|
||||||
|
//digitalWrite(PinPUMP, LOW);
|
||||||
PumpLastOn = timeClient.getEpochTime();
|
PumpLastOn = timeClient.getEpochTime();
|
||||||
EEPROM.put(237, PumpLastOn);
|
EEPROM.put(237, PumpLastOn);
|
||||||
PumpOnTimePassed = 0;
|
PumpOnTimePassed = 0;
|
||||||
}
|
}
|
||||||
// when valSoilmoistureAvg is greater then the Low value,
|
// when valSoilmoistureAvg is greater then the Low value,
|
||||||
} else {
|
} else {
|
||||||
digitalWrite(PinPUMP, LOW);
|
setOutput(3, 0);
|
||||||
|
//digitalWrite(PinPUMP, LOW);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -735,6 +746,7 @@ void controlPUMP() {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// ensure pump is off when it should be off
|
// 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 */
|
/* CanGrow_Version.h gets generated from cangrow.sh */
|
||||||
|
|
||||||
const char* CanGrowVer = "0.1-dev";
|
const char* CanGrowVer = "0.1-dev";
|
||||||
const char* CanGrowBuild = "1a1fd39-20240912013347";
|
const char* CanGrowBuild = "56d9756-20240919020116";
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue