Sleep 2 hours on low battery

This commit is contained in:
Ollo 2024-04-07 12:50:12 +02:00
parent cb37426fbb
commit d2f1605b90
2 changed files with 8 additions and 5 deletions

View File

@ -144,7 +144,7 @@
#ifdef HWREVISION07 #ifdef HWREVISION07
#define SOLAR_VOLT_FACTOR (4.0306f) /**< 100k and 33k voltage dividor */ #define SOLAR_VOLT_FACTOR (4.0306f) /**< 100k and 33k voltage dividor */
#else #else
#define SOLAR_VOLT_FACTOR 11f #define SOLAR_VOLT_FACTOR 11.0f
#endif #endif
#define BATTSENSOR_INDEX_SOLAR 0 #define BATTSENSOR_INDEX_SOLAR 0
#define BATTSENSOR_INDEX_BATTERY 1 #define BATTSENSOR_INDEX_BATTERY 1
@ -160,7 +160,7 @@
#define VOLT_MAX_BATT 4.2f #define VOLT_MAX_BATT 4.2f
#define VOLT_MIN_BATT 3.0f /**< Minimum battery voltage for normal operation */ #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_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)*/ #define WATER_LEVEL_MINIMUM 500 /**< Minimum Analog value (1023 is the maximum)*/

View File

@ -239,11 +239,14 @@ void espDeepSleep(bool afterPump = false)
} }
} }
#define SECOND2USECOND_FACTOR (1000U * 1000U)
/* sleep always at least one second */ /* sleep always at least one second */
if (secondsToSleep < 0) { if (secondsToSleep <= 0) {
secondsToSleep = 1; 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()) if (aliveWasRead())
{ {
delay(1000); delay(1000);