The ESP32 is undeniably a worthy competitor to many WiFi/MCU SoCs, outperforming them in both performance and price. However, depending on which mode it is in, the ESP32 can be a relatively power-hungry device.

When your IoT project is powered by an electrical outlet, power consumption is of little concern; however, if you plan to power your project with a battery, every mA counts.

The solution here is to take advantage of one of the ESP32�s sleep modes to reduce power consumption. This is an excellent strategy for significantly increasing the battery life of a project that does not need to be active all of the time.

What exactly is the ESP32 Sleep Mode?

The ESP32 sleep mode is a power-saving mode. When not in use, the ESP32 can enter this mode, storing all data in RAM. At this point, all unnecessary peripherals are disabled while the RAM receives enough power to retain its data.

Inside the ESP32 chip

Knowing what is inside the chip will help us better understand how the ESP32 manages power savings. The block diagram of the ESP32 chip is shown below.

Block Diagrams

The ESP32 chip contains a dual-core 32-bit microprocessor along with 448 KB of ROM, 520 KB of SRAM, and 4 MB of flash memory.

In addition, the chip contains a WiFi module, a Bluetooth module, a cryptographic accelerator (a co-processor designed specifically to perform cryptographic operations), an RTC module, and a number of peripherals.

ESP32 Power Modes

Thanks to the ESP32�s advanced power management, it offers five configurable power modes. According to the power requirement, the chip can switch between different power modes. These modes are:

  • Active Mode
  • Modem Sleep Mode
  • Light Sleep Mode
  • Deep Sleep Mode
  • Hibernation Mode

Each mode has distinct features and power-saving capabilities. Let�s take a look at them one by one.

ESP32 Active Mode

Normal mode is also referred to as Active Mode. In this mode, all peripherals of the chip remain active.

Since everything is always active in this mode (especially the WiFi module, processing core, and Bluetooth module), the chip consumes about 240 mA of power. It has also been observed that the chip draws more than 790 mA at times, particularly when both WiFi and Bluetooth are used simultaneously.

ESP32 Active Mode Functional Block Diagram

According to the ESP32 datasheet, the power consumption during RF operations in active mode is as follows:

ModePower Consumption
Wi-Fi Tx packet 13dBm~21dBm160~260mA
Wi-Fi/BT Tx packet 0dBm120mA
Wi-Fi/BT Rx and listening80~90mA

This mode, without a doubt, consumes the most current and is the least efficient. In order to save power, you must disable features that are not in use by switching to another power mode.

ESP32 Modem Sleep

In modem sleep mode, everything is active except for the WiFi, Bluetooth, and the radio. The CPU remains active, and the clock is configurable.

In this mode, the chip consumes approximately 3 mA at slow speed and 20 mA at high speed.

ESP32 Modem Sleep Functional Block Diagram

To keep the connection alive, Wi-Fi, Bluetooth, and the radio are woken up at predefined intervals. This is referred to as the Association Sleep Pattern.

During this sleep pattern, ESP32 switches between active mode and modem sleep mode.

To accomplish this, the ESP32 connects to the router in station mode using the DTIM beacon mechanism. The Wi-Fi module is disabled between two DTIM beacon intervals and then automatically enabled just before the next beacon arrives. This results in power conservation.

The sleeping time is determined by the router�s DTIM beacon interval time, which is typically 100 ms to 1000 ms.

What is the DTIM Beacon Mechanism?

DTIM stands for Delivery Traffic Indication Message.

DTIM-Beacon

In this mechanism, the access point (AP)/router broadcasts beacon frames periodically. Each frame contains network-related information. It is used to announce the presence of a wireless network as well as to synchronize all connected members.

ESP32 Light Sleep

Light sleep is similar to modem sleep in that the chip follows the Association Sleep Pattern. The only difference is that in light sleep mode, the CPU, most of the RAM, and digital peripherals are clock-gated.

What is Clock Gating?

Clock gating is a popular power management technique for reducing dynamic power dissipation by removing or ignoring the clock signal when the circuit is not in use.

Clock gating reduces power consumption by pruning the clock tree. Pruning the clock disables portions of the circuitry, preventing the flip-flops in them from switching states. Since switching states consumes power, when not switched, the power consumption drops to zero.

During light sleep mode, the CPU is paused by disabling its clock pulse. The RTC and ULP-coprocessor, on the other hand, remain active. This results in a lower power consumption than the modem sleep mode, which is around 0.8 mA.

ESP32 Light Sleep Functional Block Diagram

Before entering light sleep mode, the ESP32 stores its internal state in RAM and resumes operation upon waking from sleep. This is referred to as Full RAM Retention.

ESP32 Deep Sleep

In deep sleep mode, the CPUs, most of the RAM, and all digital peripherals are disabled. Only the following parts of the chip remain operational:

  • ULP Coprocessor
  • RTC Controller
  • RTC Peripherals
  • RTC fast and slow memory

In deep sleep mode, the chip consumes anywhere between 0.15 mA (when the ULP coprocessor is on) and 10 �A.

ESP32 Deep Sleep Functional Block Diagram

During deep sleep mode, the primary CPU is turned off, whereas the Ultra-Low-Power (ULP) Coprocessor can take sensor readings and wake up the CPU as needed. This sleep pattern is referred to as the ULP sensor-monitored pattern. This is useful for designing applications where the CPU needs to be woken up by an external event, a timer, or a combination of these events, while maintaining minimal power consumption.

Along with the CPU, the main memory of the chip is also disabled. As a result, everything stored in that memory is erased and cannot be accessed.

Because RTC memory is kept active, its contents are preserved even during deep sleep and can be retrieved once the chip is woken up. This is why the chip stores Wi-Fi and Bluetooth connection data in RTC memory before entering deep sleep.

If you want to use the 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;

When the chip wakes up from deep sleep, it performs a reset and begins program execution from the beginning.

When waking up from deep sleep, the ESP32 can run a deep sleep wake stub. It�s a piece of code that executes as soon as the chip wakes up, before any normal initialization, bootloader, or ESP-IDF code is executed. After executing the wake stub, the chip can either return to sleep or continue to start ESP-IDF normally.

If you�re interested in learning more about ESP32 Deep Sleep and its wake-up sources, please visit our in-depth tutorial below.

ESP32 Hibernation mode

Hibernate mode is very similar to deep sleep. The only difference is that in hibernation mode, the chip disables the internal 8 MHz oscillator as well as the ULP-coprocessor, leaving only one RTC timer (on slow clock) and a few RTC GPIOs to wake the chip up.

Because the RTC recovery memory is also turned off, we cannot save any data while in hibernation mode.

ESP32 Hibernation Mode Functional Block Diagram

As a result, the chip�s power consumption is reduced even further; in hibernation mode, it consumes only about 2.5 ?A.

This mode is especially useful if you�re working on a project that doesn�t need to be active all the time.


Login
ADS CODE