From 490569ccac5edca94e15cd125521170e3bf02e94 Mon Sep 17 00:00:00 2001 From: stefanbode Date: Fri, 7 Aug 2020 14:48:59 +0200 Subject: [PATCH 1/3] Added DeepSleep for ESP32 First implementation of TIME based Deepsleep for ESP32 processors --- tasmota/xdrv_29_deepsleep.ino | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/tasmota/xdrv_29_deepsleep.ino b/tasmota/xdrv_29_deepsleep.ino index 4ac0531db..6b66439a4 100644 --- a/tasmota/xdrv_29_deepsleep.ino +++ b/tasmota/xdrv_29_deepsleep.ino @@ -71,7 +71,13 @@ void DeepSleepReInit(void) AddLog_P2(LOG_LEVEL_ERROR, PSTR("DSL: Remain DeepSleep %d"), RtcSettings.ultradeepsleep); RtcSettingsSave(); RtcRebootReset(); - ESP.deepSleep(100 * RtcSettings.deepsleep_slip * (DEEPSLEEP_MAX_CYCLE < RtcSettings.ultradeepsleep ? DEEPSLEEP_MAX_CYCLE : RtcSettings.ultradeepsleep), WAKE_RF_DEFAULT); + #ifdef ESP8266 + ESP.deepSleep(100 * RtcSettings.deepsleep_slip * (DEEPSLEEP_MAX_CYCLE < RtcSettings.ultradeepsleep ? DEEPSLEEP_MAX_CYCLE : RtcSettings.ultradeepsleep), WAKE_RF_DEFAULT); + #endif + #ifdef ESP32 + esp_sleep_enable_timer_wakeup(100 * RtcSettings.deepsleep_slip * (DEEPSLEEP_MAX_CYCLE < RtcSettings.ultradeepsleep ? DEEPSLEEP_MAX_CYCLE : RtcSettings.ultradeepsleep)); + esp_deep_sleep_start(); + #endif yield(); // Sleeping } @@ -136,8 +142,13 @@ void DeepSleepStart(void) WifiShutdown(); RtcSettings.ultradeepsleep = RtcSettings.nextwakeup - UtcTime(); RtcSettingsSave(); - +#ifdef ESP8266 ESP.deepSleep(100 * RtcSettings.deepsleep_slip * deepsleep_sleeptime); +#endif +#ifdef ESP32 + esp_sleep_enable_timer_wakeup(100 * RtcSettings.deepsleep_slip * deepsleep_sleeptime); + esp_deep_sleep_start(); +#endif yield(); } From cdb1915fdf63526cab4af674db3d396d8454580b Mon Sep 17 00:00:00 2001 From: stefanbode Date: Fri, 7 Aug 2020 14:49:49 +0200 Subject: [PATCH 2/3] Update tasmota_template_ESP32.h Added Deepsleep --- tasmota/tasmota_template_ESP32.h | 1 - 1 file changed, 1 deletion(-) diff --git a/tasmota/tasmota_template_ESP32.h b/tasmota/tasmota_template_ESP32.h index ac422cfc6..644826923 100644 --- a/tasmota/tasmota_template_ESP32.h +++ b/tasmota/tasmota_template_ESP32.h @@ -36,7 +36,6 @@ // Not ported (yet) #undef USE_DISCOVERY -#undef USE_DEEPSLEEP #undef USE_MY92X1 #undef USE_TUYA_MCU #undef USE_PS_16_DZ From d63b8ead8c3b2281cc4e900ed20d3ae15ff3a906 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Fri, 7 Aug 2020 14:56:03 +0200 Subject: [PATCH 3/3] Update xdrv_29_deepsleep.ino --- tasmota/xdrv_29_deepsleep.ino | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/tasmota/xdrv_29_deepsleep.ino b/tasmota/xdrv_29_deepsleep.ino index 6b66439a4..84b30f740 100644 --- a/tasmota/xdrv_29_deepsleep.ino +++ b/tasmota/xdrv_29_deepsleep.ino @@ -71,13 +71,12 @@ void DeepSleepReInit(void) AddLog_P2(LOG_LEVEL_ERROR, PSTR("DSL: Remain DeepSleep %d"), RtcSettings.ultradeepsleep); RtcSettingsSave(); RtcRebootReset(); - #ifdef ESP8266 - ESP.deepSleep(100 * RtcSettings.deepsleep_slip * (DEEPSLEEP_MAX_CYCLE < RtcSettings.ultradeepsleep ? DEEPSLEEP_MAX_CYCLE : RtcSettings.ultradeepsleep), WAKE_RF_DEFAULT); - #endif - #ifdef ESP32 - esp_sleep_enable_timer_wakeup(100 * RtcSettings.deepsleep_slip * (DEEPSLEEP_MAX_CYCLE < RtcSettings.ultradeepsleep ? DEEPSLEEP_MAX_CYCLE : RtcSettings.ultradeepsleep)); - esp_deep_sleep_start(); - #endif +#ifdef ESP8266 + ESP.deepSleep(100 * RtcSettings.deepsleep_slip * (DEEPSLEEP_MAX_CYCLE < RtcSettings.ultradeepsleep ? DEEPSLEEP_MAX_CYCLE : RtcSettings.ultradeepsleep), WAKE_RF_DEFAULT); +#else // ESP32 + esp_sleep_enable_timer_wakeup(100 * RtcSettings.deepsleep_slip * (DEEPSLEEP_MAX_CYCLE < RtcSettings.ultradeepsleep ? DEEPSLEEP_MAX_CYCLE : RtcSettings.ultradeepsleep)); + esp_deep_sleep_start(); +#endif // ESP8266 or ESP32 yield(); // Sleeping } @@ -144,11 +143,10 @@ void DeepSleepStart(void) RtcSettingsSave(); #ifdef ESP8266 ESP.deepSleep(100 * RtcSettings.deepsleep_slip * deepsleep_sleeptime); -#endif -#ifdef ESP32 +#else // ESP32 esp_sleep_enable_timer_wakeup(100 * RtcSettings.deepsleep_slip * deepsleep_sleeptime); esp_deep_sleep_start(); -#endif +#endif // ESP8266 or ESP32 yield(); }