Enabling hibernate mode on ESP32-S2

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
Post Reply
mzakharo
Posts: 3
Joined: Thu May 05, 2022 7:12 pm

Enabling hibernate mode on ESP32-S2

Post by mzakharo » Thu May 05, 2022 7:36 pm

Hello,

I wanted to document the journey here on enabling hibernation mode (ultra-low power deep sleep) on ESP32-S2 (UM-FeatherS2) board.
It takes a couple of changes to get this message on the UART0 console when entering deepsleep mode:

Code: Select all

D (5225) sleep: RTC_PERIPH: OFF
D (5225) sleep: RTC_SLOW_MEM: OFF
D (5225) sleep: RTC_FAST_MEM: OFF
First of all, in order to see the debug prints on the UART console from ESP-IDF, you have to change micropython/ports/esp32/boards/sdkconfig.base

Code: Select all

CONFIG_LOG_DEFAULT_LEVEL_DEBUG=y
CONFIG_LOG_DEFAULT_LEVEL=4
Then, to be able to turn off RTC_FAST_MEM on ESP32-S2 , add the following to sdconfig.base

Code: Select all

CONFIG_ESP32S2_ALLOW_RTC_FAST_MEM_AS_HEAP=n

Finally, add this to machine_sleep_helper() function inside modmachine.c

Code: Select all

 esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH,   ESP_PD_OPTION_OFF);
 esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_SLOW_MEM, ESP_PD_OPTION_OFF);
 esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_FAST_MEM, ESP_PD_OPTION_OFF);
 esp_sleep_pd_config(ESP_PD_DOMAIN_XTAL,         ESP_PD_OPTION_OFF);

Profit.

tepalia02
Posts: 99
Joined: Mon Mar 21, 2022 5:13 am

Re: Enabling hibernate mode on ESP32-S2

Post by tepalia02 » Fri May 06, 2022 10:53 am

Thanks a lot for sharing all these details with us.

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Enabling hibernate mode on ESP32-S2

Post by pythoncoder » Sat May 07, 2022 9:13 am

@mzakharo Interesting. I tested a UM Feather S2 just issuing machine.deepsleep(time) with standard firmware. The current draw of my sample was 65μA which I thought was very impressive. What figure do you achieve with your additional changes?
Peter Hinch
Index to my micropython libraries.

mzakharo
Posts: 3
Joined: Thu May 05, 2022 7:12 pm

Re: Enabling hibernate mode on ESP32-S2

Post by mzakharo » Fri Feb 10, 2023 4:52 pm

pythoncoder wrote:
Sat May 07, 2022 9:13 am
@mzakharo Interesting. I tested a UM Feather S2 just issuing machine.deepsleep(time) with standard firmware. The current draw of my sample was 65μA which I thought was very impressive. What figure do you achieve with your additional changes?
Sorry for the late reply. I am using nRF Profiler Kit II to measure current, and my UM Feather S2 deep sleep is 34 uA @ 3.3V. I am applying power through the JST connector, not USB. This should give lower current. Also, be mindful of the on-board Ambient sensor. You will get lowest reading when the room is dark :). I just soldered it off the board to get consistent current measurement.

mzakharo
Posts: 3
Joined: Thu May 05, 2022 7:12 pm

Re: Enabling hibernate mode on ESP32-S2

Post by mzakharo » Fri Feb 10, 2023 4:57 pm

My nRF Profiler kit II measures 34uA @ 3.3V. Ensure you measure through JST connector, not USB. Also Ambient light sensor will throw off your reading. Measure when room is dark, or just solder it off for consistent measurement.

Post Reply