diff --git a/Platformio/hardware/ESP32/sleep_hal_esp32.cpp b/Platformio/hardware/ESP32/sleep_hal_esp32.cpp index 1e44e24..0b69e9d 100644 --- a/Platformio/hardware/ESP32/sleep_hal_esp32.cpp +++ b/Platformio/hardware/ESP32/sleep_hal_esp32.cpp @@ -238,6 +238,10 @@ uint32_t get_sleepTimeout_HAL() { } void set_sleepTimeout_HAL(uint32_t aSleepTimeout) { sleepTimeout = aSleepTimeout; + // For reason unknown, some users reported sleepTimeout was set to 0. In this case device would immediately go to sleep. Prevent this. + if (sleepTimeout == 0) { + sleepTimeout = DEFAULT_SLEEP_TIMEOUT; + } } bool get_wakeupByIMUEnabled_HAL() { return wakeupByIMUEnabled;