ESP32 Deep-Sleep




About: Small electronic projects , tutorials, and reviews for sensors, ESP8266, Arduino, Raspberry Pi, and ESP32

The ESP32 is the successor of the famous ESP8266. It has much more features like Bluetooth. This instructable shows you, how to deep-sleep the ESP32 and wake it up using different sources.

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: Watch the Video

If you want more details, please watch this video:

Step 2: ESP32 Block Diagram and Pins

But first, let’s get an overview: The ESP32 chip has 2 processor types, the main, and the ultra-low power, or ULP processor. And it has plenty of pins, which can be used by these two processors. Most of the ESP32 pins have many different functions, which can be quite confusing if you look at the data sheet. Here is an excel sheet for an overview of the pins of the WROOM-32 module:

17 pins can also be used by the ULP processor, they are called RTC_GPIOs (RTC_GPIO1 and 2 are not available on the WROOM-32 module).
There are also 10 touch sensors. And they are also connected to the ULP area. These pins will be used later on.

Step 3: Wake-Up Sources

The ESP32 supports five different modes from active where everything is “ON” to hibernation, where everything is “OFF”. Today, we concentrate on two modes: Active and deep-sleep. And we see, that even during deep-sleep, the ULP processor can be kept on. Cool. But how much current does the module consume in this state? According the Data sheet, it is 0.15 mA or 150 µA. But how can we wake the ESP32 up from its deep-sleep? With the ESP8266 we basically had two possibilities: Either reset the chip from an external source or connect GPIO16 to the reset pin for a timed wake-up. And, with the timer, we were only able to sleep for about one hour. The ESP32 has four different wake-up sources:

  1. The timer
  2. Two possibilities of external Wake-ups
  3. The touch pads
  4. ULP coprocessor wake-up

Step 4: Timer Wake-Up

The ESP8266 is only capable of sleeping for one hour.The ESP32 can sleep many years before it wakes-up. And it is no more necessary to connect pins to use the timed wake-up. Everything is internally connected.

We start the deep-sleep with esp_deep_sleep_start(); The sketch never reaches code after this statement, because, after wake-up, it starts with the execution of setup().

We also get good information on the boot procedure (e.g. reset cause).

Step 5: External Wake-Up

The next is wake-up by an external source. This was also possible with the ESP8266 by resetting the chip. Here, we get much more possibilities: We can wake-up the chip by one particular pin only. To do this, we have to select the ext0 mode and tell the chip, which pin is connected to the button. And in addition, we can decide, if we want to trigger the wake-up by a low or a high state of the pin. To find-out the pin number is a little tricky: We have to use the GPIO number of the pin, not the RTC_GPIO pin number. Fortunately, we still have our Excel sheet and we can see, that RTC_GPIO00 and GPIO36 are connected to the same pin on the WROOM-32 module.

One thing is important: You have, depending on the interrupt polarity, to connect an external pull-up or down resistor to the pin. I used a 100k resistor and it worked.

But what, if we would like to have several buttons for the wake-up? Also here, our new toy offers an elegant solution: we use the ext1 wake-up source. In this mode, we can use several pins for wake-up. Because we can declare more than one pin, we have to define a so called “mask” instead of only a pin.

Step 6: Touch Pin Wake-Up

The last one is the touch wake-up. Also this wake-up works somehow similar. The deep sleep is started with the same command, and after deep-sleep, the ESP32 also starts with the execution of setup(). The definition of the touch pin, however is different: This source uses touchInterrupts() and you attach the interrupt of each touch sensor you want to use to a “callback function”. If you do not attach the interrupt, this sensor is inactive. In addition, you have to enable touch pad wake-ups.

Be the First to Share


    • Instrument Contest

      Instrument Contest
    • Make it Glow Contest

      Make it Glow Contest
    • STEM Contest

      STEM Contest

    18 Discussions


    Question 5 months ago

    Hi Andreas,
    Where can i find the "soc/rtc.h" library to slow down the ESP32 frequency?
    Best regards,

    João Cera


    8 months ago

    Dear Andreas,
    Thank you so much for your informative posts. Not to forget the also funny ones on youtube.
    You seem to be the guy with a really big knowhow in the esp topic.
    Maybe you - or another nice person reading my question - find the time to help me in my area where I'm stuck.
    Let me add that I'm curently using ESP-01 (with the soldering deep sleep mod), ESP-12 as well as Wemos D1 Mini mostly for checking the environment. But mailing as well as acessing the internet and my raspberries works fine, too.
    My next project is to add an existing rain sensor, where existing means its hardware is there and working but the software is outdated and/or not working anymore.
    There are two sensors for the rain part: the first one closes a gap between two metal spikes if a drop of water is collected. So this immediately identifies when it starts to rain.
    And secondly there's a seesaw that in case a certain amount of water is collected closes a reed relais or opens it. The states only change if the seesaw moves.
    Which ESP should I use in case I'm additionally handling temperature, humidity and pressure every 15minutes collected by a BME280? Inbetween the ESP should be in deep sleep.
    I suppose a ESP-01 isn't the best choice as I'm activating the BME280 only in case a reading is to be made (VCC to a GPIO).
    But am I forced to use an ESP32, which I assume from your instructasble will work, or will it work using an ESP-12 as well. How?


    11 months ago

    Hi Andreas, your Instructable is very helpful! Now I would like an addendum or new Instructable from you that goes over Light Sleep and what currents are drawn by all the different modes of ESP32 sleep. I found that light sleep was, in the end, better than deep sleep because of the extra power deep sleep needed to reconnect to Wifi every waking. Light sleep, on the other hand, does not reset but resumes where it left off in the sketch and seems to keep the Wifi connection somewhat active. With my external circuitry (solar battery charger regulator) and the DOIT Devkit v.1 board, I was getting 16mA used during deep sleep, and 17mA during light sleep.


    1 year ago

    Can the ESP32 be programmed to wake from deep sleep based upon a timer wake up AND an external wake up trigger? In other words, please sleep according to schedule unless an earthquake occurs which would trigger the external wake up event.


    1 year ago


    Comment in source code says:

    * Push Button to GPIO 33 pulled down with a 10K Ohm resistor

    But deep sleep statement in same source is:

    * Serial.println(esp_deep_sleep_enable_ext0_wakeup(GPIO_NUM_39, 1)); //1 = High, 0 = Low

    And Excel file says:




    Question 1 year ago on Step 6

    You are quoting current from the datasheet during ULP operation of 150uA, however you do not make any measurements. In your video you show deep sleep current when using a timer or ext wakeup which I also confirm is ~5-6uA. Once touch is enabled and the FSM is running, my current jumps to 360uA, not 150. Have you also measured the current while using the touch wakeup?

    I would very much like to achieve the 150uA.

    It is possible to watch this current jump between 5uA and 360uA with the start and stop of the FSM using the SW control.


    I am using a esp32WROOM with a 5K pull up to VDD33 on IO0, a 5K pull down to VSS on IC2 and a 12K pullup on EN to VDD33.


    1 year ago

    what about ULP co processor wakeup?


    2 years ago

    My master,

    I am your student for LiVe sir.



    2 years ago

    This instructable page will solve the problem of missing out the details on youtube videos. one can watch the videos for a general idea and read this page of step-by-step instructions. very helpful.

    1 reply
    Maker Saga

    2 years ago

    Oh awesome I didn't know you had an page.

    I recommended your esp8266 deep sleep videos to my group as a learning resource when we were working with NodeMCU and ESP-01 projects. Your videos were very helpful.

    1 reply

    2 years ago

    you do a really great job with your videos and now also instructions.

    Thank you!

    2 replies