From 72f8d3639367c77cc95dd17354e49176d2a54c9c Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 24 May 2021 20:07:22 +0200 Subject: [PATCH] ignore bod while starting upstepper --- esp32/src/main.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/esp32/src/main.cpp b/esp32/src/main.cpp index b703770..9750d2e 100644 --- a/esp32/src/main.cpp +++ b/esp32/src/main.cpp @@ -26,6 +26,8 @@ #include #include #include "DS2438.h" +#include "soc/soc.h" +#include "soc/rtc_cntl_reg.h" /****************************************************************************** * DEFINES @@ -319,11 +321,16 @@ void onHomieEvent(const HomieEvent &event) { mPlants[i].deactivatePump(); } + WRITE_PERI_REG(RTC_CNTL_BROWN_OUT_REG, 0); + digitalWrite(OUTPUT_ENABLE_PUMP, HIGH); + delay(100); + WRITE_PERI_REG(RTC_CNTL_BROWN_OUT_REG, 1); mDownloadMode = true; break; case HomieEventType::OTA_SUCCESSFUL: - Homie.getLogger() << "OTA successfull" << endl; + Homie.getLogger() << "OTA successful" << endl; digitalWrite(OUTPUT_ENABLE_SENSOR, LOW); + digitalWrite(OUTPUT_ENABLE_PUMP, LOW); ESP.restart(); break; default: @@ -444,7 +451,10 @@ void setup() // Power pins pinMode(OUTPUT_ENABLE_PUMP, OUTPUT); + digitalWrite(OUTPUT_ENABLE_PUMP, LOW); + + pinMode(OUTPUT_ENABLE_SENSOR, OUTPUT); if (HomieInternals::MAX_CONFIG_SETTING_SIZE < MAX_CONFIG_SETTING_ITEMS) @@ -673,7 +683,12 @@ void plantcontrol(bool withHomie) } else { + //prevent BOD to be paranoid + WRITE_PERI_REG(RTC_CNTL_BROWN_OUT_REG, 0); digitalWrite(OUTPUT_ENABLE_PUMP, HIGH); + delay(100); + WRITE_PERI_REG(RTC_CNTL_BROWN_OUT_REG, 1); + rtcLastWateringPlant[lastPumpRunning] = getCurrentTime(); mPlants[lastPumpRunning].activatePump(); }