1.. zephyr:code-sample:: esp32-deep-sleep 2 :name: Deep Sleep 3 4 Use deep sleep with wake on timer, GPIO, and EXT1 sources on ESP32. 5 6Overview 7******** 8 9The deep sleep mode of the ESP32 Series is a power saving mode that causes the 10CPU, majority of RAM, and digital peripherals that are clocked from APB_CLK to 11be powered off. 12 13This sample shows how to set a wake up source, trigger deep sleep and then 14make use of that pre-configured wake up source to bring the system back again. 15 16The following wake up sources are demonstrated in this example: 17 181. ``Timer``: An RTC timer that can be programmed to trigger a wake up after 19 a preset time. This example will trigger a wake up every 20 seconds. 202. ``EXT1``: External wake up 1 is tied to multiple RTC GPIOs. This example 21 uses GPIO2 and GPIO4 to trigger a wake up with any one of the two pins are 22 HIGH. 233. ``GPIO``: Only supported by some Espressif SoCs, in the case of ESP32-C3 24 GPIOS0~5 can be used as wake-up sources. 25 26In this demo, Timer is the only wake-up source that cannot be disabled via a 27Kconfig option. The target SoC will always repeat the following: enable Timer 28as wake-up source, deep sleep for 20 seconds, wake up. 29 30Requirements 31************ 32 33This example should be able to run on any commonly available 34:zephyr:board:`esp32_devkitc_wroom` development board without any extra hardware if 35only ``Timer`` is used as wakeup source. 36 37However, when ``EXT1`` is also enabled, GPIO2 and GPIO4 should be pulled-down 38by external resistors to avoid floating pins. When triggering a wake up, one 39or both of the pins must be set to high. Note that floating pins may trigger 40a wake up. 41 42The same connection logic used on ``EXT1`` should be applied when ``GPIO`` is 43enabled as wake-up source. 44 45To enable or disable ``EXT1``, edit ``CONFIG_EXAMPLE_EXT1_WAKEUP`` on demo's 46``prj.conf`` file. By default, this wake up source is enabled. Follow similar 47steps to enable or disable ``GPIO`` by editing ``CONFIG_EXAMPLE_GPIO_WAKEUP``. 48 49Building, Flashing and Running 50****************************** 51 52.. zephyr-app-commands:: 53 :zephyr-app: samples/boards/espressif/deep_sleep 54 :board: esp32_devkitc_wroom/esp32/procpu 55 :goals: build flash 56 :compact: 57 58Sample Output 59================= 60ESP32 core output 61----------------- 62 63With both wake up sources enabled, the console output will be as below. The 64reset reason message depends on the wake up source used. The console output 65sample below is for GPIO2. 66 67.. code-block:: console 68 69 *** Booting Zephyr OS build zephyr-v3.1.0-3667-gb42e2b225ecf *** 70 71 Wake up from GPIO 2 72 Enabling timer wakeup, 20s 73 Enabling EXT1 wakeup on pins GPIO2, GPIO4 74 Powering off 75