The ESP32 stands as a formidable contender against many WiFi/MCU SoCs, surpassing them in both performance and price. However, its power consumption can vary depending on its mode of operation.
When your IoT project is connected to an electrical outlet, power usage might not be a concern. However, if you intend to run your project on a battery, every milliampere matters.
To address this, utilizing one of the ESP32’s sleep modes is key to minimizing power consumption. This approach is particularly effective for extending the battery life of projects that don’t need to be active continuously.
It’s a power-saving state where the ESP32 conserves energy by shutting down unnecessary peripherals and storing data in RAM. In this mode, RAM retains its data while consuming minimal power.
Parts Required
Component Name | Buy Now |
ESP32-WROOM-32 Development | Amazon |
Inside the ESP32 chip
Understanding the internal components of the chip is crucial for comprehending how the ESP32 achieves power efficiency. Below is the block diagram illustrating the components of the ESP32 chip.
The ESP32 chip comprises a dual-core 32-bit microprocessor, accompanied by 448 KB of ROM, 520 KB of SRAM, and 4 MB of flash memory.
Furthermore, the chip houses a WiFi module, a Bluetooth module, a cryptographic accelerator (a specialized co-processor for cryptographic tasks), an RTC module, and various peripherals.
Power Modes of the ESP32
The ESP32 boasts advanced power management, providing five customizable power modes. Depending on the power needs, the chip can transition between these modes. They include:
- Active Mode
- Modem Sleep Mode
- Light Sleep Mode
- Deep Sleep Mode
- Hibernation Mode
Each mode offers unique features and energy-saving capabilities. Let’s explore them individually.
ESP32 Active Mode
The standard operating state is also known as Active Mode. In this mode, all peripherals of the chip remain operational.
As everything remains active, including the WiFi module, processing core, and Bluetooth module, the chip consumes approximately 240 mA of power. It has also been observed that the chip can draw over 790 mA at times, particularly when both WiFi and Bluetooth are simultaneously utilized.
According to the ESP32 datasheet, the power consumption during RF operations in active mode is as follows:
Mode | Power Consumption |
Wi-Fi Tx packet 13dBm~21dBm | 160~260mA |
Wi-Fi/BT Tx packet 0dBm | 120mA |
Wi-Fi/BT Rx and listening | 80~90mA |
This mode undeniably consumes the most current and is the least efficient. To conserve power, it’s essential to disable unused features by switching to another power mode.
ESP32 Modem Sleep
When in modem sleep mode, all components of the ESP32 chip remain active except for the WiFi, Bluetooth, and radio. The CPU continues to operate, and the clock can be adjusted as needed.
During this mode, the chip consumes approximately 3 mA at a slow speed and 20 mA at a high speed.
To ensure continuous connectivity, WiFi, Bluetooth, and the radio are periodically awakened at specific intervals, following what is known as the Association Sleep Pattern.
Throughout this pattern, the ESP32 switches back and forth between active mode and modem sleep mode.
To enable this behavior, the ESP32 establishes a connection to the router in station mode using the DTIM beacon mechanism. The WiFi module remains inactive between two DTIM beacon intervals, automatically reactivating just before the next beacon arrives. This method effectively conserves power.
The length of each sleep cycle is determined by the router’s DTIM beacon interval, typically ranging from 100 ms to 1000 ms.
DTIM, which stands for Delivery Traffic Indication Message, is a mechanism in which the access point (AP)/router broadcasts beacon frames periodically. These frames contain network-related information, serving to announce the presence of a wireless network and synchronize all connected devices.
ESP32 Light Sleep
In light sleep mode, the ESP32 follows a sleep pattern similar to modem sleep, known as the Association Sleep Pattern. However, during light sleep, the CPU, most of the RAM, and digital peripherals are subject to clock gating.
Clock gating is a widely-used power management technique that aims to reduce dynamic power dissipation. It achieves this by stopping or ignoring the clock signal when the circuit is inactive.
This technique lowers power consumption by trimming the clock tree, which deactivates sections of the circuitry, preventing the flip-flops within them from changing states. As state transitions consume power, minimizing them effectively reduces power consumption to nearly zero.
During light sleep mode, the CPU is halted by suspending its clock pulse, while the RTC and ULP coprocessor continue to operate. As a result, power consumption in light sleep mode is lower than in modem sleep mode, averaging around 0.8 mA.
Before entering light sleep mode, the ESP32 stores its internal state in RAM, allowing it to resume operation upon awakening from sleep. This preservation technique is known as Full RAM Retention.
Deep Sleep Mode on the ESP32
During deep sleep mode, the CPUs, most of the RAM, and all digital peripherals are deactivated. Only specific components of the chip remain functional:
- ULP Coprocessor
- RTC Controller
- RTC Peripherals
- RTC fast and slow memory
In this mode, power consumption varies from 0.15 mA (when the ULP coprocessor is active) to 10 µA.
While in deep sleep, the primary CPU is powered down, while the Ultra-Low-Power (ULP) Coprocessor can perform sensor readings and awaken the CPU when necessary. This sleep pattern is known as the ULP sensor-monitored pattern. It’s valuable for applications where the CPU must be roused by an external event, timer, or a combination of both, while keeping power usage to a minimum.
Additionally, the main memory of the chip is disabled, leading to the erasure of its contents, rendering them inaccessible.
However, RTC memory remains active during deep sleep, preserving its contents even when the chip is asleep. This is why the chip stores Wi-Fi and Bluetooth connection data in RTC memory before entering deep sleep.
To retain data after a reboot, store it in RTC memory by defining a global variable with the RTC_DATA_ATTR
attribute. For example, RTC_DATA_ATTR int myVar = 0;
Upon waking from deep sleep, the chip undergoes a reset and begins program execution anew.
For further insights into ESP32 Deep Sleep and its wake-up sources, please refer to our comprehensive tutorial below.
ESP32 Hibernation mode
Hibernation mode closely resembles deep sleep, with the key difference being the deactivation of the internal 8 MHz oscillator and the ULP coprocessor. In hibernation mode, only one RTC timer (running on a slow clock) and a few RTC GPIOs remain active to awaken the chip.
Since the RTC recovery memory is also disabled, data cannot be preserved while the chip is in hibernation mode.
Consequently, the chip’s power consumption is further minimized, with hibernation mode consuming just about 2.5 μA.
This mode proves particularly beneficial for projects that do not require continuous activity.