01 Overview
Deep sleep is the core power-saving mechanism for battery-powered ESP32 devices: the CPU stops, most digital peripherals power down, and only the RTC domain and a few wake-up logic circuits remain active.
It solves the standby power problem for duty-cycled products—sensors wake up every minute or hour, take a reading, report, and sleep again, bringing average current down to microamps.
Typical use cases include temperature/humidity sensors, door/window contacts, environmental monitoring nodes, and low-power trackers. They don't need real-time response, only to be woken at specific moments.
Deep sleep is not standby: ordinary RAM contents are lost, and the program restarts from the beginning. Therefore, critical state must be kept in RTC memory or NVS.
It is also not suitable for devices that need to stay online or respond with low latency, such as remote controls or real-time control panels.
This example demonstrates both timer wake-up and GPIO wake-up, and provides a code framework for distinguishing cold boot from wake-up boot.