Light Sleep

Browse source code on GitHub

Overview

This example illustrates usage of light sleep mode. Unlike deep sleep mode, light sleep preserves the state of memory, CPU, and peripherals.

Light sleep is entered automatically while the system is idle and power management is enabled. In the current implementation, wake-up from light sleep is supported only via an RTC timer, since execution resumes under control of the Zephyr scheduler and the wake-up time is scheduled in advance.

Building, Flashing and Running

west build -b esp32_devkitc/esp32/procpu samples/boards/espressif/light_sleep
west flash

Sample Output

The output below shows the system repeatedly entering light sleep while calling k_sleep(). The sample uses the minimum residency time configured for the light sleep (standby) power state in the device tree, applies a timing margin, and transitions the system into light sleep. The system wakes up via the RTC timer and resumes execution under control of the Zephyr scheduler.

*** Booting Zephyr OS build v4.3.0-5178-gf042bd21bce7 ***
Entering light sleep
Returned from light sleep, reason: timer, t=218 ms, slept for 51 ms
Entering light sleep
Returned from light sleep, reason: timer, t=279 ms, slept for 51 ms
Entering light sleep
Returned from light sleep, reason: timer, t=340 ms, slept for 51 ms
Entering light sleep
Returned from light sleep, reason: timer, t=401 ms, slept for 51 ms