How to use ESP32 Deep Sleep Mode for Low Power Consumption

User Avatar Anand D
Author
Share
ESP32-S3 Deep Sleep Mode

We have built several ESP32 projects using different ESP32 development boards. But these boards come with a power-saving mode called deep-sleep mode. Let's try to understand deep sleep on the ESP32 with an example. Take an example of a laptop. When it's in use, the fans spin at high speed, the display is on, some apps run in the background, and the battery drains fast. But when we close the laptop lid, the power consumption becomes very low, the fans stop spinning, the display goes off, and background apps also stop. The same way, we can put an ESP32 into this deep-sleep mode when we want it to be. Deep Sleep Mode is also available for Arduino boards. If you’d like to see how this is done on Arduino boards, make sure to check out our Arduino Sleep Modes and How to Use Them to Save the Power Tutorial.


Using sleep mode makes battery-powered projects more practical. It lets the ESP32 stay in sleep mode most of the time, wake up only to read a sensor or update a value, and then go back to sleep. This technique can extend the battery life from a couple of days to years. Before we dive into deep sleep, we will learn about the various other power modes of an ESP32 as well. In this tutorial, we put a Seeed Studio XIAO ESP32-S3 into deep sleep, wake it with a push button, and measure the real ESP32 deep sleep current on a multimeter.

Key Takeaways

  • XIAO ESP32-S3 idle in active mode: 31.21 mA
  • Active mode with LED load: 40.40 mA
  • Deep sleep, waiting for a button press: 0.13 mA (130 µA), about a 99.6% reduction
  • The bare ESP32-S3 chip is rated at about 7–8 µA in deep sleep. The remaining current on a dev board comes from the regulator and other onboard circuits.
  • Deep sleep wipes normal RAM, so the chip restarts from setup() on every wake-up. Use RTC_DATA_ATTR to keep values.

What Is Deep Sleep Mode of ESP32?

Deep sleep mode of ESP32 is a power-saving state where the microcontroller cores, SRAM, Wi-Fi, Bluetooth, and all high-speed clocks are disabled while only the RTC control unit, RTC memory, RTC peripherals, and the ULP (ultra-low power) processor are operational. When a wake-up signal strikes, the chip resets and executes the setup() function again. As a result, a device powered by batteries can be inactive for most of its life while performing only simple tasks, such as measurement or triggering an activity.

ESP32 Power Modes and Current Consumption Compared

Before we look at deep sleep in detail, here is how the ESP32 power modes compare.

Power ModeCPU StateTypical Current Draw (Bare Chip)Typical Use Case
Active ModeFully Running40 mA - 160 mAProcessing data, active Wi-Fi/BT streaming 
Modem SleepCPU Running, Radio OFF3 mA - 20 mALocal tasks while maintaining occasional Wi-Fi links
Light SleepPaused (Clock Gated)~0.8 mAShort idle periods where instant wake-up without reboot is required
Deep SleepPowered OFF10 uA - 150 uABattery-powered sensors, periodic loggers, event triggers
HibernationPowered OFF (RTC memory OFF)~2.5 uALong-term ultra-low power storage, RTC timer wake-up only

ESP32 Deep Sleep Wake-Up Sources

Suppose we are deploying Deep Sleep in our project. There are various ways to wake the chip up from sleep mode. Let's take a look at them. 

1Timer Wake-Up (esp_sleep_enable_timer_wakeup)
Wakes up automatically after a set interval (e.g., wake every 15 minutes, read a sensor, sleep).
2External Single-Pin Wake-Up (ext0)
Wakes up when one specific RTC pin changes state (e.g., your current single push button project).
3External Multi-Pin Wake-Up (ext1)
Wakes up when any or all pins out of a group of RTC pins switch state (e.g., a keypad or multiple door sensors).
4Touch Pin Wake-Up (touchSleepWakeUpEnable)
Wakes up when a capacitive touch pin detects a human touch.
5ULP Co-processor Wake-Up
The ultra-low-power co-processor runs mini-programs (like threshold checks) while the main CPU stays asleep.

Here in this tutorial, we will be using ext0 (External Single-Pin Wake-Up). During deep sleep, the primary dual-core CPU shuts down entirely, leaving only a tiny RTC hardware circuit running that monitors GPIO 1(D0), to which we will be attaching a button switch. Different ESP32 Boards have different RTC-enabled pins. You can learn more about RTC pins on the ESP32 used to enable Deep Sleep in our ESP32 Interrupt Tutorial.

esp_sleep_enable_ext0_wakeup(BUTTON_PIN, 1);

Passing 1 as the second argument tells the RTC controller to wake the ESP32 up when the voltage on BUTTON_PIN transitions to HIGH (3.3V) when the button is pressed. We will see the whole code explained in detail in the code explanation part.

Components Required

The following are the components required for this ESP32 deep sleep tutorial.

Components used to test ESP32 deep sleep mode on the XIAO ESP32-S3

The XIAO ESP32-S3 board is selected as the main processor. The whole circuit will be assembled on to a breadboard as it's the best way to do testings out of this. We have a push button to turn the LED on and off. The LED here is to act as a load to demonstrate the power consumption. All the connections will be made using jumper cables.

S NoItemDescription
1XIAO ESP32-S3 The main processor
2Button SwitchTo turn the LED on and off
3LEDTo act as a load
4BreadboardTo assemble the circuit
5Jumper WiresTo make the connections

ESP32 Deep Sleep Mode Circuit Diagram

Below is the circuit diagram to test out the Deep-Sleep Mode on ESP32 Boards. As shown below, we are testing it out with an official Seeed Studio ESP32-S3 development board. Any ESP32 board can be utilised for this demonstration, as deep sleep is applicable to every board. Only one thing to note is the PINs. Make sure to update the PINs as per your plan. Apart from the ESP32-S3, we have an LED that is connected to the GPIO pin labelled D1 and a push button that is connected to the GPIO pin labelled D0.

ESP32 deep sleep wake-up pin circuit: push button on D0 (GPIO 1), LED on D1 (GPIO 2)

Hardware Setup for Measuring ESP32 Deep Sleep Current

Below is the full hardware setup for this tutorial. We have the circuit explained above hooked up to a bench power supply, which is the UNI-T UTP1306. In the image, the power supply is set to 5V and 1A. CHNT ZTW890D Pro is the multimeter that we will be using to measure the current consumption. We will be running two different Arduino codes on the same ESP32 to demonstrate how it behaves when sleep is enabled and when it is not enabled. 

Bench setup used to measure ESP32 deep sleep power consumption

The image below shows the ESP32 Board in Active mode. As we can see, when the LED is off, the ESP32 board consumes around 31.21 mA. It is utilized for keeping CPU active, continuously running loop() waiting for a button press.

XIAO ESP32-S3 active mode current of 31.21 mA with LED off on multimeter Active mode, LED off: 31.21 mA

Below is the same setup in Active Mode, but this time, the LED is powered on on the button press. This time. The LED power consumption is also added to the normal Active Mode power consumption. So now, in total, the current consumed by the board is around 40.40 mA.

XIAO ESP32-S3 active mode current of 40.40 mA with LED on Active mode, LED on: 40.40 mA

Now, let's test out the Deep Sleep Mode. Here on the same board, we have flashed code with deep sleep mode enabled. We can see clearly that the current consumption dropped and is just 0.13 mA, which is 130µA. This is a huge difference.

ESP32 deep sleep current of 0.13 mA (130 µA) measured on XIAO ESP32-S3 Deep sleep mode: 0.13 mA (130 µA)

We have prepared all of the readings in the table below so that it's easy to compare and understand the effect of Deep Sleep Mode on an ESP32 board. Let's take a look at it.

ESP32 Deep Sleep Power Consumption Results

The table below puts all of our readings side by side, so you can see the effect of deep sleep on the XIAO ESP32-S3.

ModeStateCurrent DrawWhat the ESP32 is Doing
Active ModeLED ON~40.40 mACPU active + powering the LED load
LED OFF~31.21mACPU active, continuously running loop() waiting for a button press
Deep Sleep ModeLED ON~40.40 mAWoken up, active CPU + powering the LED load
LED OFF0.13 mACPU, RAM, and digital peripherals completely powered OFF

In Active mode, the board draws a continuous 31.21 mA while idle just to keep the dual-core CPU, RAM, and internal clocks running inside loop(). When the button is pressed and the LED turns on, the power draw increases to around 40.40 mA. This constant 31.21 mA baseline means that even when doing no real work, the chip utilises battery energy continuously.

In Deep Sleep Mode, turning off the LED drops the current draw down to 0.13 mA (130 µA), a 99.6% reduction in idle power. This small current is drawn by the board's onboard voltage regulator and minor passive components while the main ESP32-S3 chip sleeps. When the push button is pressed to wake it up and turn on the LED, the current jumps back up to around 40.40 mA, just as in the active mode, proving that the chip instantly restores full processing power and load execution when triggered.

How This Impacts Battery Life

For a quick reference, we can assume a 1000 mAh battery using our observed currents will last roughly as follows. The estimate does not take battery self-discharge, regulator efficiency and spikes during boot time into account, so the data presented should be regarded as the highest possible.

Scenario (1000 mAh battery)Average CurrentEstimated Runtime
Always in active mode (idle)31.21 mA~32 hours (about 1.3 days)
Deep sleep + 10 button presses a day (5 s LED each)~0.15 mA~270 days
Always in deep sleep (this board)0.13 mA~320 days

99.6% Power Reduction on ESP32? Here is how 

99.6% less power on ESP32? We tested deep sleep on the XIAO ESP32-S3, and the current dropped from 31.21 mA to just 130 µA. See how to set up an ext0 wake-up pin with a push button, keep data in RTC memory, and measure real ESP32 deep sleep current on the bench.

 

ESP32 Deep Sleep Code Explanation

Now, let's take a look at the code explanation. Below is the code with Deep Sleep. For the other code where we operate the ESP32 in Active Mode, check the GitHub link provided below.

Checking the Wake-Up Cause

void setup() {
 pinMode(LED_PIN, OUTPUT);
 digitalWrite(LED_PIN, LOW);
 Serial.begin(115200);
 delay(500);
 esp_sleep_wakeup_cause_t wakeup_reason = esp_sleep_get_wakeup_cause();

pinMode & digitalWrite initialise the LED pin as an output and ensure it starts in the OFF state. Serial.begin(115200) sets up the serial link to output status messages to the Serial Monitor. esp_sleep_get_wakeup_cause() queries the internal sleep controller to check why the chip just booted up (e.g., initial power plug-in vs. button trigger).

Handling the Button Wake-Up

RTC_DATA_ATTR int wakeCount = 0;
if (wakeup_reason == ESP_SLEEP_WAKEUP_EXT0) {
   wakeCount++;
   Serial.println("\n--- ESP32 WOKE UP FROM DEEP SLEEP (BUTTON PRESSED) ---");
   Serial.print("Boot Count: ");
   Serial.println(wakeCount);
   Serial.println("Status: LED ON - Active Load");
   digitalWrite(LED_PIN, HIGH);
   delay(5000);
   digitalWrite(LED_PIN, LOW);
 } else {
   Serial.println("\n--- ESP32 INITIAL POWER-ON ---");
   Serial.println("Status: System starting up directly into Deep Sleep...");
 }

if (wakeup_reason == ESP_SLEEP_WAKEUP_ext0) checks if the wake event was triggered by the external signal on BUTTON_PIN, as we are using External Single-Pin Wake-Up (ext0).
Inside the if block (when Button Press Triggered), it increments wakeCount in RTC memory, prints system status and current boot count, turns the LED ON for 5 seconds to represent an active workload, then turns it OFF. Inside the else block (Fresh Power-On / USB plug-in), it skips the LED action because the device just turned on and hasn't received a button trigger yet.

Configuring the Wake-Up Pin and Entering Deep Sleep

Serial.println("Status: Entering Deep Sleep Mode now...");
 Serial.flush();
 // Explicitly configure internal pull-down for RTC GPIO during sleep
 rtc_gpio_pulldown_en(BUTTON_PIN);
 rtc_gpio_pullup_dis(BUTTON_PIN);
 // Enable ext0 wake-up on HIGH signal
 esp_sleep_enable_ext0_wakeup(BUTTON_PIN, 1);
 esp_deep_sleep_start();
}

Serial.flush() forces all serial output buffer data out to the computer before the serial peripheral shuts down. The main things to note here are esp_sleep_enable_ext0_wakeup(BUTTON_PIN, 1), which configures the RTC wake controller to monitor GPIO 1 (ext0 mode) and wake up the main CPU the instant a HIGH (3.3V) signal is detected and esp_deep_sleep_start(), which powers off the main dual-core CPU, RAM, Wi-Fi radio, and high-frequency clocks. The chip remains completely asleep until BUTTON_PIN goes HIGH.

Conclusion

These experimental results clearly demonstrate the real-world value of power management on the XIAO ESP32-S3. While Active Mode consumes a constant 31.21 mA just keeping the dual-core CPU and internal system clocks running in loop(), switching to Deep Sleep Mode drops the idle baseline down to 0.13 mA (130 µA), achieving about a 99.6% reduction in power draw.

When the button triggers an event, the current instantly jumps to 40.40 mA, proving that the ESP32-S3 can keep on running for months or years while maintaining the ability to wake up instantly and execute its workload on demand. For battery-powered IoT devices and maker projects, implementing Deep Sleep is the single most critical software design choice to extend battery life from a couple of days to multiple years. One such practical example can be a Bluetooth iBeacon using an ESP32, where we need long battery life for long term working. But the applications are endless.

GitHub Repository

Below are the Arduino codes to measure and compare ESP32 active mode and deep sleep power consumption on the Seeed Studio XIAO ESP32-S3, with a push button wake-up on an ext0 pin (D0/GPIO 1) and an LED load on D1.

ESP32 deep sleep GitHubESP32 deep sleep Downloadable Zip

If you have any questions, leave them in the comment section below or use our Forums for other technical questions.

Frequently Asked Questions about ESP32 Deep Sleep

⇥ What is the current consumption for the deep sleep state of the ESP32 chip?
Based on information provided by Espressif, the original ESP32 chip in deep sleep mode consumes about 10 µA with the RTC timer and memory powered on and approximately 150 µA when ULP is active. The ESP32-S3 is rated at about 7–8 µA. But development boards consume more energy. The XIAO ESP32-S3 we tested consumes 130 µA at 5 V.

⇥ Does the ESP32 lose its data during deep sleep state?
Yes, the main SRAM is powered off, so regular variables are lost, and the program starts from setup() upon waking up. One may keep some variables such as counters or sensor readings by defining some variables as global with RTC_DATA_ATTR that will save them in RTC memory. For keeping data that should be stored during power loss, use flash storage like the Preferences library.

⇥ Is it true that the ESP32 can maintain a Wi-Fi connection during deep sleep mode?
It is not possible. Deep sleep mode results in total shutdown of the Bluetooth and Wi-Fi radios, meaning that disconnections are unavoidable. Typically, the ESP32 must reconnect after waking up, which requires effort and energy consumption. The best options to preserve connection are either modem or light sleep.

More Interesting ESP32 Projects to Explore

Explore more exciting ESP32 projects, including a DIY desktop weather station with an E-Ink display, a feature-packed ESP32 smartwatch with multiple sensors, and a smart digital Ludo game board powered by ESP32-S3. These projects offer practical insights into ESP32 development, sensor integration, custom PCB design, display interfacing, and low-power applications.

How to Build a Desktop Weather Station Using ESP32 and E-ink Display

How to Build a Desktop Weather Station Using ESP32 and E-ink Display

This project offers a practical way to build a clean and minimal DIY weather station using an ESP32 microcontroller and an E-Ink display. The use of E-Ink ensures that the display remains readable even without constant power, making it a perfect fit for battery-powered desktop use. 

DIY Smartwatch with multiple Watch Faces, Heart Rate Sensor, Compass and Games

DIY Smartwatch with multiple Watch Faces, Heart Rate Sensor, Compass and Games

Throughout this part of the project, you will be guided through the process of assembling the hardware components, setting up the software, and configuring the settings and features of your smartwatch. By the end of this project, you will have a fully functional smartwatch that you can wear and use on a daily basis. 

Build a Smart Digital Game Board Using Multicolour PCB

Build a Smart Digital Game Board Using Multicolour PCB

This article shows how to build a Digital Ludo Board, a modern take on this classic game that combines the nostalgia of the physical game with the convenience and interactivity of the digital world. Designed and built from scratch, this is not only a fun project but also an opportunity to try out the new multicolour PCB.

Complete Project Code

#include <driver/rtc_io.h> // Include RTC IO driver
#define BUTTON_PIN GPIO_NUM_1
#define LED_PIN    2
RTC_DATA_ATTR int wakeCount = 0;
void setup() {
 pinMode(LED_PIN, OUTPUT);
 digitalWrite(LED_PIN, LOW);
 Serial.begin(115200);
 delay(500);
 esp_sleep_wakeup_cause_t wakeup_reason = esp_sleep_get_wakeup_cause();
 if (wakeup_reason == ESP_SLEEP_WAKEUP_EXT0) {
   wakeCount++;
   Serial.println("\n--- ESP32 WOKE UP FROM DEEP SLEEP (BUTTON PRESSED) ---");
   Serial.print("Boot Count: ");
   Serial.println(wakeCount);
   Serial.println("Status: LED ON - Active Load");
   digitalWrite(LED_PIN, HIGH);
   delay(5000);
   digitalWrite(LED_PIN, LOW);
 } else {
   Serial.println("\n--- ESP32 INITIAL POWER-ON ---");
   Serial.println("Status: System starting up directly into Deep Sleep...");
 }
 Serial.println("Status: Entering Deep Sleep Mode now...");
 Serial.flush();
 // Explicitly configure internal pull-down for RTC GPIO 33 during sleep
 rtc_gpio_pulldown_en(BUTTON_PIN);
 rtc_gpio_pullup_dis(BUTTON_PIN);
 // Enable ext0 wake-up on HIGH signal
 esp_sleep_enable_ext0_wakeup(BUTTON_PIN, 1);
 esp_deep_sleep_start();
}
void loop() {
}
Have any question related to this Article?

Add a comment

No account needed. Your comment appears once a moderator has reviewed it.

Never shown publicly.
CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.