{"id":8121,"date":"2023-03-14T08:39:27","date_gmt":"2023-03-14T06:39:27","guid":{"rendered":"https:\/\/deepbluembedded.com\/?p=8121"},"modified":"2023-08-17T23:50:40","modified_gmt":"2023-08-17T20:50:40","slug":"esp32-sleep-modes-power-consumption","status":"publish","type":"post","link":"https:\/\/deepbluembedded.com\/esp32-sleep-modes-power-consumption\/","title":{"rendered":"ESP32 Sleep Modes & Power Consumption in Each Mode"},"content":{"rendered":"\n
In this tutorial, we’ll discuss the available ESP32 sleep modes (low-power modes) and the power consumption in each mode. You’ll learn how to maximize the power-saving while using ESP32 to achieve the required functionalities of your application and maintain the battery life for extended periods of operation.<\/p>\n\n\n\n
The ESP32 is a very powerful microcontroller that runs at much higher frequencies compared to other Arduino boards and it has on-chip WiFi, Bluetooth, and radio support that make it an even more power-hungry microcontroller. For some IoT applications, battery life can be a very critical resource that we need to carefully manage. And that’s exactly what we’ll be doing in this tutorial.<\/p>\n\n\n
The ESP32 power management features provide the user with 5 configurable and selectable power modes. And we as system designers have to choose between the 5 different power modes according to the application’s needs. You can also programmatically switch from one mode to another while operating, which needs to be implemented carefully in the code.<\/p>\n\n\n\n
The ESP32 Power Modes Are<\/strong>:<\/p>\n\n\n\n ESP32 Low-Power Modes are<\/strong>: (Modem Sleep, Light Sleep, Deep Sleep, and Hibernation). Each one of the ESP32 sleep modes has its own list of activated features as well as deactivated features in order to achieve certain levels of power consumption. Depending on your application’s need, you get to choose the most convenient power mode in order to prolong the battery life as much as possible and perform the required tasks.<\/p>\n\n\n Please be advised that all current consumption values listed in this article are meant to be for the bare ESP32 chip, not the whole ESP32 dev board. Any ESP32 dev board will have much higher power consumption due to having onboard LEDs, resistors, and other passives that sum up to a larger current consumption than the values listed hereafter in this article. <\/p>\n\n\n\n For low-power applications, you need to have your custom PCB design with the ESP32 target microcontroller with minimal on-board passives to achieve the needed functionalities with minimal power consumption.<\/p>\n\n<\/div><\/div>\n\n\n The ESP32 Active Mode is the normal operation mode in which all the peripherals are working, WiFi and Bluetooth are enabled, and the chip can transmit, receive or listen.<\/p>\n\n\n\n The only way to save some power in Active Mode is to control the clock frequency at which the CPU is running and\/or change the RF operation mode according to your application’s needs and to the following table.<\/p>\n\n\n\n ESP32 Active mode current consumption<\/strong> is: (95~240) mA<\/strong>, depending on the WiFi\/BLE mode and the CPU clock speed at which you’re operating the microcontroller.<\/p>\n\n\n\n This clearly shows that ESP32 Active mode is the least power-efficient mode and you should consider disabling any unused feature by running in any other low-power mode as long as it’s not needed by your application.<\/p>\n\n\n\n In Modem Sleep Mode, the ESP32 core is operational, the clock is configurable, and every other peripheral is functional except for the (Radio, WiFi, and Bluetooth) which are disabled. Therefore, current consumption in this mode is totally dependent on the CPU clock rate. Reducing the clock frequency will reduce the current consumption and vice versa.<\/p>\n\n\n\n ESP32 Modem Sleep Mode Current Consumption is (2~4)mA<\/strong> @ 2MHz “Slow Speed”, (20~25)mA<\/strong> @ 80MHz “Normal Speed”, and (30~50)mA<\/strong> @ 240MHz “Max Speed”.<\/p>\n\n\n\n ESP32 Modem Sleep Mode Wake-Up Latency<\/strong><\/strong> is: immediate<\/strong>!<\/p>\n\n\n\n So we can interpret the ESP32 Modem Sleep mode as follows: if you’re going to disable Radio, Bluetooth, and WiFi, then it’s going to be up to the CPU frequency in order to reduce the current consumption even more. And it’s going to be just like any microcontroller sleep mode.<\/p>\n\n\n\n However, if you still need WiFi, you’ll have to keep switching between active and sleep modes periodically after connecting to the access point (AP) successfully. In the modem sleep mode, Radio, WiFi, and BT are turned OFF in order to reduce power consumption. The ESP32 device (station) can keep the connection with the AP in modem sleep mode. This is using what’s known as DTIM<\/strong> (Delivery Traffic Indication Message).<\/p>\n\n\n\n The basic idea behind the DTIM beacon technique is to periodically send a message with beacons. Which notifies all stations to wake up from sleep state and synchronize between all the members in the network. The DTIM beacon interval time dictates the sleeping time in which the ESP32 will be in “modem sleep mode” before it switches back to “active” in order to receive the DTIM frame from the AP.<\/p>\n\n\n\n This process can happen more or less frequently, leading to the emergence of 2 additional derivatives of the “Modem Sleep Mode”. These two modes are as follows:<\/p>\n\n\n\n For more information: please refer to Espressif documentation<\/a>, and to this ESP-IDF example<\/a>.<\/p>\n\n\n\n The ESP32 Light Sleep Mode is very similar to the Modem Sleep Mode. However, the only difference is that in light sleep mode, the CPUs are stalled (clock-gated) as well as most of the RAM, and the digital peripherals. Their supply voltage is also reduced in order to save more power.<\/p>\n\n\n\n ESP32 Light Sleep Mode Current Consumption<\/strong> is: ~0.8mA<\/strong><\/p>\n\n\n\n Wake-Up Latency in ESP32 Light Sleep Mode<\/strong> is: less than 1ms<\/strong><\/p>\n\n\n\n Clock-gating the digital peripherals, RAM, and CPUs causes them to stop without losing context or any data. And it does bring the current consumption down to nearly 800\u00b5A. Upon exit from Light Sleep, the digital peripherals, RAM, and CPUs resume operation and their internal states are preserved.<\/p>\n\n\n\n In ESP32 Deep Sleep Mode, the CPUs, most of the RAM, and all digital peripherals that are clocked from APB_CLK are powered OFF. The only active parts of the chip are RTC Memories, RTC Controller, and the ULP coprocessor.<\/p>\n\n\n\n The Ultra-Low-Power (ULP) coprocessor can still do some simple tasks like reading data coming from sensors or RTC GPIOs. Therefore, we can use RTC peripherals (Timers, GPIOs, etc) as well as the ULP to generate various “wake-up” events in order to wake up the device from “Deep Sleep” mode.<\/p>\n\n\n In Deep Sleep Mode, the CPU context is lost and whenever the CPU wakes up from “Deep Sleep”, it’s going to start program execution all over again from the very beginning. The RTC power domain () is the only section in the microcontroller that preserves its context before going into “Deep Sleep”. <\/p>\n\n\n\n Therefore, if you need to store any data and retrieve it after a “Deep Sleep”, you have to save it in the RTC memory. (e.g. RTC_DATA_ATTR int data = 0; \/\/ This global variable will retain its value even after a deep sleep wake-up)<\/p>\n\n<\/div><\/div>\n\n\n ESP32 Deep Sleep Mode Current Consumption<\/strong> is: ~(10-150)\u00b5A<\/strong> Depending on what features are activated according to the following table.<\/p>\n\n\n\n ESP32 Deep Sleep Mode<\/strong> Wake-Up Latency<\/strong> is: less than 1ms<\/strong><\/p>\n\n\n\n\n
\n\n\nESP32 Active Mode<\/h2>\n\n\n
Mode<\/strong><\/td> Current Consumption<\/strong><\/td><\/tr> WiFi TX, DSSS 1 Mbps, POUT = +19.5 dBm<\/td> 240 mA<\/td><\/tr> WiFi TX, OFDM 54 Mbps, POUT = +16 dBm<\/td> 190 mA<\/td><\/tr> WiFi TX, OFDM MCS7, POUT = +14 dBm<\/td> 180 mA<\/td><\/tr> WiFi RX (listening)<\/td> (95~100) mA<\/td><\/tr> BT\/BLE TX, POUT = 0 dBm<\/td> 130 mA<\/td><\/tr> BT\/BLE RX (listening)<\/td> (95~100) mA<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n
\n\n\nESP32 Modem Sleep Mode<\/h2>\n\n\n
\n
\n\n\nESP32 Light Sleep Mode<\/h2>\n\n\n
\n\n\nESP32 Deep Sleep Mode<\/h2>\n\n\n
\n\n
\n Power Mode<\/strong><\/td>\n Activated Features<\/strong><\/td>\n Current Consumption<\/strong><\/td>\n<\/tr>\n \n Deep Sleep<\/td>\n The ULP Coprocessor is ON<\/td>\n 150\u00b5A<\/td>\n<\/tr>\n \n ULP sensor-monitored-pattern<\/td>\n 100\u00b5A<\/td>\n<\/tr>\n \n RTC Timer + RTC Memory<\/td>\n 10\u00b5A<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/figure>\n\n\n\n