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.

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.



    • Make it Glow Contest 2018

      Make it Glow Contest 2018
    • Plastics Contest

      Plastics Contest
    • Optics Contest

      Optics Contest

    14 Discussions


    4 months 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.


    7 months 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 8 months 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.


    9 months ago

    what about ULP co processor wakeup?


    1 year ago

    My master,

    I am your student for LiVe sir.



    1 year 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

    1 year 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

    1 year ago

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

    Thank you!

    2 replies