Shenzhen Xin Yuan Electronic Technology Co., Ltd.
购物车图片 购物车 ( )
找服务 找新闻
The recommended reading
Hot label / Products

ESP32 Deep-Sleep

Time: 2017-08-02
Clicks: 634

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

ESP32 Deep-Sleep

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

ESP32 Deep-Sleep

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

ESP32 Deep-Sleep

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

ESP32 Deep-Sleep

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

ESP32 Deep-Sleep

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.









Share to:
Related recommendations
2019 - 12 - 16
点击次数: 0
“Creative Friday”—Week 15 !!!T-Watch without touch version, TTP223 touch buttons have been added, which are fully compatible with&...
2019 - 12 - 07
点击次数: 12
“Creative Friday”—Week 14 !!!T-fork is the development interface board of t-watch function backplane. Each functional backplane of the t-watch has an ...
2019 - 12 - 02
点击次数: 14
“Creative Friday”— Week 13 !!! LILYGO T-OI as the name suggestsT continues our T series. TOI when you read from right...
2019 - 11 - 23
点击次数: 17
DS18B20 waterproof temperature sensor is used for t-higrow and t-watch with t-grove interface. For example, it can be used with t-higrow to test the temperature and humidity of flowerpot soil and envi...
  • 资质认证


  • 支付安全


  • 专人服务


  • 售后无忧


The unified hotline:
0086 13928411439

  • Aliexpress

  • ebay

  • "Sweeping" attention to us, more activities, surprise waiting for you
    E-mail:       Wechat: 13928411439       QQ :3004603945

    Copyright ©2005 - 2013 Shenzhen Xin Yuan Electronic Technology Co., Ltd.