diff --git a/esp32/include/ControllerConfiguration.h b/esp32/include/ControllerConfiguration.h index 4d987da..1d0190a 100644 --- a/esp32/include/ControllerConfiguration.h +++ b/esp32/include/ControllerConfiguration.h @@ -144,7 +144,7 @@ #ifdef HWREVISION07 #define SOLAR_VOLT_FACTOR (4.0306f) /**< 100k and 33k voltage dividor */ #else -#define SOLAR_VOLT_FACTOR 11f +#define SOLAR_VOLT_FACTOR 11.0f #endif #define BATTSENSOR_INDEX_SOLAR 0 #define BATTSENSOR_INDEX_BATTERY 1 @@ -160,7 +160,7 @@ #define VOLT_MAX_BATT 4.2f #define VOLT_MIN_BATT 3.0f /**< Minimum battery voltage for normal operation */ #define LOWVOLT_SLEEP_FACTOR 3 /**< Factor for nightsleep delay, if the battery drops below minimum (@see VOLT_MIN_BATT) */ -#define LOWVOLT_SLEEP_MINIMUM 5400 /**< At low voltage sleep at least for 90 minutes */ +#define LOWVOLT_SLEEP_MINIMUM 7200 /**< At low voltage sleep at least for 120 minutes (two hours) */ #define WATER_LEVEL_MINIMUM 500 /**< Minimum Analog value (1023 is the maximum)*/ diff --git a/esp32/src/main.cpp b/esp32/src/main.cpp index 9f3165e..e5124bd 100644 --- a/esp32/src/main.cpp +++ b/esp32/src/main.cpp @@ -239,11 +239,14 @@ void espDeepSleep(bool afterPump = false) } } + #define SECOND2USECOND_FACTOR (1000U * 1000U) + /* sleep always at least one second */ - if (secondsToSleep < 0) { - secondsToSleep = 1; + if (secondsToSleep <= 0) { + secondsToSleep = (unsigned long) (UINT64_MAX / SECOND2USECOND_FACTOR); } - esp_sleep_enable_timer_wakeup((secondsToSleep * 1000U * 1000U)); + esp_sleep_enable_timer_wakeup((secondsToSleep * SECOND2USECOND_FACTOR)); + #undef SECOND2USECOND_FACTOR if (aliveWasRead()) { delay(1000);