1.. _esp32-light-sleep-sample: 2 3ESP32 Light Sleep demo 4###################### 5 6Overview 7******** 8 9This example illustrates usage of light sleep mode. Unlike deep sleep mode, 10light sleep preserves the state of the memory, CPU, and peripherals. Execution 11of code on both CPUs is stopped when esp_light_sleep_start() function is called. 12When the chip exits light sleep mode, execution continues at the point where it 13was stopped, and esp_light_sleep_start() function returns. 14 15The example enables the following wakeup sources: 16 17* ``Timer``: wake up the chip in 2 seconds. 18* ``EXT0``: wake up the chip if a button attached to GPIO0 is pressed (i.e. if 19 GPIO0 goes low). 20 21Requirements 22************ 23 24This example can be used with any ESP32 development board. Most boards have a 25button attached to GPIO0, often labelled BOOT. If the board does not have such 26button, an external button can be connected, along with a 10k pull-up resistor, 27and a 100nF capacitor to ground for debouncing. 28 29Building, Flashing and Running 30****************************** 31 32.. zephyr-app-commands:: 33 :zephyr-app: samples/boards/esp32/light_sleep 34 :board: esp32_devkitc_wroom 35 :goals: build flash 36 :compact: 37 38Sample Output 39================= 40ESP32 core output 41----------------- 42 43In the scenario below, the button attached to GPIO0 was pressed and held for 44about 500 ms, after the second wakeup from light sleep. The program has 45indicated the wakeup reason after each sleep iteration. 46 47.. code-block:: console 48 49 *** Booting Zephyr OS build zephyr-v3.1.0-3667-gb42e2b225ecf *** 50 51 Entering light sleep 52 Returned from light sleep, reason: timer, t=3344 ms, slept for 2001 ms 53 Entering light sleep 54 Returned from light sleep, reason: timer, t=5354 ms, slept for 2000 ms 55 Entering light sleep 56 Returned from light sleep, reason: pin, t=5885 ms, slept for 521 ms 57 Waiting for GPIO0 to go high... 58 Entering light sleep 59 Returned from light sleep, reason: timer, t=8765 ms, slept for 2000 ms 60 Entering light sleep 61 Returned from light sleep, reason: timer, t=10776 ms, slept for 2001 ms 62 Entering light sleep 63 64Troubleshooting 65*************** 66 67If pressing the button attached to GPIO0 does not affect program behavior, 68check DTR/RTS configuration in the serial monitor. This is not necessary for 69IDF monitor, but for other tools it might be necessary to set DTR and RTS line 70state to "disabled" or "de-asserted". 71