There are typically several sleep modes available in microcontrollers to optimize power consumption. The exact sleep modes available depend on the specific microcontroller and manufacturer.
Below mentioned parameter which affects the average power consumption of the microcontroller device which should be as low as possible to reduce the consumption.
- Operating frequency
- Active Peripheral
- Peripheral mode wrt frequency
- Average active time
- Radio power configuration
However here we understand some common sleep mode with example of ESP32 microcontrollers:
Sleep Modes in ESP32
Power efficiency is an important factor in the success of any embedded project, especially when it comes to microcontrollers. The ESP32 microcontroller is a most popular choice regarding low cost and powerful capabilities that offers a wide range of functionalities for IoT projects. Power efficiency is one of the best areas of this. By leveraging the sleep modes provided by the ESP32, developers can significantly reduce power consumption and extend the battery life of their projects.
Before discussing the power mode, we talked about configuration for power saving for the project.
Power Management Unit (PMU) on ESP32 can manage power wrt to switch between different power modes. Five types of power modes designed for typical scenarios: Wake-up, Modem /Radio-sleep mode, light sleep mode, Deep-sleep mode, Hibernation mode.
Exploring the Power modes in ESP32
–Wake-up or Active mode: The chip radio (Wi-Fi, BLE) is powered up. The chip can receive, transmit, or listen.
–Modem/ Radio -sleep mode: The CPU is operational, high frequency clock and other peripheral clock is configurable. The RF peripherals e.g. Wi-Fi and Bluetooth are disabled.
– Light-sleep mode: The CPU is paused. The RTC memory and RTC peripherals, as well as the ULP coprocessor are running. Any wake-up events (internal or external) will wake up the chip.
– Deep-sleep mode: Only the RTC memory and RTC peripherals are wake-up. RF modules like Wi-Fi and BLE connection data are stored in the RTC memory. The ULP (Ultra Low Powered) coprocessor is functional.
– Hibernation mode: The internal 8 MHz oscillator and ULP coprocessor are disabled. The RTC recovery memory is powered down. Only one RTC timer (Sleep timer) with slow clock and certain real time clock (RTC) general purpose IO (GPIO) are active. That will help to wake up the chip from the Hibernation mode.
As shown on table, behavior of different functionality as per sleep mode to save the power.
SN | Functionality | Active Mode | Modem sleep mode | Light sleep Mode | Deep sleep Mode | Hibernation mode |
1 | Peripheral (GPIO, UART, I2C, SPI etc) | Active | Active | Sleep | Sleep | Sleep |
2 | BLE | Active | Disabled | Sleep | Sleep | Sleep |
3 | Wi-Fi | Active | Disabled | Sleep | Sleep | Sleep |
4 | Radio | Active | Disabled | Sleep | Sleep | Sleep |
5 | Core | Active | Active | Active | Sleep | Sleep |
6 | ULP Co-processor | Active | Active | Active | Partial sleep | Sleep |
7 | RTC | Active | Active | Active | Active | Active |
Below table shows the power consumption wrt different power modes.
ESP32 API to configure mode and wakeup example:
Example of light sleep mode:
/*configure timer to generate interrupt after 1 seconds for wakeup*/
esp_sleep_enable_timer_wakeup(1000000);
/*start light sleep */
esp_light_sleep_start();
/*wakeup after timer expired */
Example of deep sleep mode.
/*configure timer to generate interrupt after 2 seconds for wakeup*/
esp_sleep_enable_timer_wakeup(2000000);
/*start deep sleep */
esp_deep_sleep_start();
/*wakeup after timer expired */
Example of Hibernation mode:
/* disable RTC memory */
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);
/*configure timer to generate interrupt after 5 seconds for wakeup*/
esp_sleep_enable_timer_wakeup(5 * 1000000);
/*start deep sleep */
esp_deep_sleep_start();
/*wakeup after timer expired */
Conclusion:
The ESP32 sleep mode is a powerful feature that allows the microcontroller to conserve energy and extend battery life at low power consumption. By placing the ESP32 in sleep mode, redundant features and functions can be prevented or reduced, significantly reducing power consumption. Sleep mode can be triggered by programming or external events, and the ESP32 can quickly wake up from sleep to resume normal operation. This useful feature of ESP32 makes it ideal MCU for low powered IoT devices. Overall, the sleep mode of the ESP32 maximizes its power reserve and makes it a versatile platform.