Deactivate all Pumps when pump power is deactivated

This commit is contained in:
c3ma 2020-10-23 19:32:12 +02:00
parent 8f21f58950
commit 0230cc2fe9

View File

@ -52,13 +52,12 @@ const char* ntpServer = "pool.ntp.org";
bool warmBoot = true; bool warmBoot = true;
bool mode3Active = false; /**< Controller must not sleep */ bool mode3Active = false; /**< Controller must not sleep */
bool mDeepsleep = false;
int plantSensor1 = 0; int plantSensor1 = 0;
int mWaterGone = -1; /**< Amount of centimeter, where no water is seen */ int mWaterGone = -1; /**< Amount of centimeter, where no water is seen */
int readCounter = 0; int readCounter = 0;
int mButtonClicks = 0;
bool mConfigured = false; bool mConfigured = false;
@ -112,12 +111,13 @@ long getCurrentTime(){
//wait till homie flushed mqtt ect. //wait till homie flushed mqtt ect.
bool prepareSleep(void *) { bool prepareSleep(void *) {
//FIXME wait till pending mqtt is done, then start sleep via event or whatever //FIXME wait till pending mqtt is done, then start sleep via event or whatever
//Homie.prepareToSleep(); //Homie.disableResetTrigger();
bool queueIsEmpty = true; bool queueIsEmpty = true;
if(queueIsEmpty){ if(queueIsEmpty){
esp_deep_sleep_start(); mDeepsleep = true;
} }
return true; // repeat? true there is something in the queue to be done return false; // repeat? true there is something in the queue to be done
} }
void espDeepSleepFor(long seconds, bool activatePump = false){ void espDeepSleepFor(long seconds, bool activatePump = false){
@ -125,6 +125,11 @@ void espDeepSleepFor(long seconds, bool activatePump = false){
gpio_deep_sleep_hold_en(); gpio_deep_sleep_hold_en();
if (activatePump) { if (activatePump) {
gpio_hold_en(GPIO_NUM_13); //pump pwr gpio_hold_en(GPIO_NUM_13); //pump pwr
} else {
digitalWrite(OUTPUT_PUMP, LOW);
for (int i=0; i < MAX_PLANTS; i++) {
mPlants[i].deactivatePump();
}
} }
//gpio_hold_en(GPIO_NUM_23); //p0 //gpio_hold_en(GPIO_NUM_23); //p0
//FIXME fix for outher outputs //FIXME fix for outher outputs
@ -417,7 +422,7 @@ int determineNextPump(){
Serial.printf("%d Requested pumping\r\n", i); Serial.printf("%d Requested pumping\r\n", i);
return i; return i;
} }
Serial.println("No pump required"); Serial.printf("%d No pump required\r\n", i);
} }
return -1; return -1;
} }
@ -643,7 +648,11 @@ void setup() {
*/ */
void loop() { void loop() {
if (!mDeepsleep) {
Homie.loop(); Homie.loop();
} else {
esp_deep_sleep_start();
}
if(millis() > 30000 && !mode3Active){ if(millis() > 30000 && !mode3Active){
Serial << (millis()/ 1000) << "s alive" << endl; Serial << (millis()/ 1000) << "s alive" << endl;