What Is Deep Sleep? Wiring and Errors (2026 Guide)
Share
What Is Deep Sleep? Wiring and Errors (2026 Guide)
Deep Sleep is the ESP32's party trick for battery builds — it's how you get months of runtime on a small LiPo instead of days. It powers down the CPU, most of the RAM, and the WiFi/BT radio entirely; only the RTC domain and, if you need it, the ULP coprocessor stay alive.
Quick answer: A bare ESP32 chip idles around 10µA in deep sleep versus 50–100mA fully awake — a four-orders-of-magnitude difference. The program restarts from setup() on every wake; nothing survives except variables declared RTC_DATA_ATTR. Ask "why did I wake up" first via esp_sleep_get_wakeup_cause(), then branch.
Proof of work: the explanation and code below are Soldr's actual answer to "What is Deep Sleep and how do I use it?", asked through Compoden's AI build assistant on 11 August 2026. Published 11 August 2026 · Last updated 11 August 2026.
What actually survives an ESP32 going to sleep and waking up?
The mental model is simple but easy to miss: the program restarts from setup() on every wake, as if the board had just been powered on. Almost nothing survives except variables explicitly declared RTC_DATA_ATTR, which live in the RTC memory domain that stays powered through sleep. Because of this, the first thing any deep-sleep sketch should do is check the wake cause and branch — was this a real first boot, or a wake from sleep?
| Source | What it wakes on |
|---|---|
| Timer | Wake every N microseconds — the most common source |
| EXT0 | One GPIO at a defined level (e.g. a door switch) |
| EXT1 | A set of GPIOs, any-high or any-low — standard for a wake-on-touch array |
| Touch pads / ULP | The ULP coprocessor watches a sensor and wakes the main CPU when it crosses a threshold |
How do you check the wake cause and track boot count across sleep cycles?
This is the exact pattern from Soldr's session — the classic "measure, sleep, repeat" structure, using RTC memory to count how many times the board has woken from timer sleep:
#include <esp_sleep.h>
RTC_DATA_ATTR int bootCount = 0; // survives deep sleep
void setup() {
Serial.begin(115200);
delay(100);
esp_sleep_wakeup_cause_t cause = esp_sleep_get_wakeup_cause();
if (cause != ESP_SLEEP_WAKEUP_TIMER) {
Serial.println("[INIT] first boot");
} else {
bootCount++;
Serial.print("[DATA] boot count: ");
Serial.println(bootCount);
}
// ... do your sensor read / send here ...
esp_sleep_enable_timer_wakeup(30 * 1000000); // wake in 30 seconds
esp_deep_sleep_start();
}
void loop() {
// never reached - the board sleeps at the end of setup()
}
The RTC_DATA_ATTR declaration and the wake-cause branch are verbatim from the session's Firmware tab; the sleep-enable call and the closing loop() follow the timer-wake pattern the session's own explanation centers on, not independently compile-checked for this post.
Why is my "low-power" ESP32 build still drawing way more than 10µA?
The single biggest mistake is powering the board through USB or its onboard regulator and still expecting bare-chip numbers — the regulator itself eats current that never shows up in the datasheet's 10µA figure. A real low-power build powers the ESP32 straight off a 3.7V LiPo, not through the dev board's USB or onboard regulator, and even then a dev board (with its USB-serial chip and regulator) draws more than a bare chip — plan for a few hundred µA on a dev board, not 10µA. A second common mistake: trying to use WiFi in deep sleep at all — there is none. If your build sends data, the real flow is wake → boot WiFi → connect → send → disconnect → sleep, and the WiFi connect step alone costs a second or two, which is the real price of staying battery-friendly.
What do you need to try this yourself?
An ESP32 30-Pin Development Board (CP2102, WiFi/Bluetooth) (Rs.400) — a full classic ESP32 dev board, so every wake source above applies. Soldr's session referred to this as an "ESP32-DEVKITC Development Board," which this is the closest catalog match for.
Frequently asked questions
Deep sleep mein ESP32 kitni battery bachata hai?
Bare ESP32 chip deep sleep mein karib 10 microamps kheenchta hai, jabki poori tarah jaga hua chip 50-100 milliamps tak kheench sakta hai - yeh chaar order-of-magnitude ka fark hai. Isi wajah se ek badi LiPo battery par mahine bhar tak project chal sakta hai agar sahi tarike se deep sleep use kiya jaaye.
Does WiFi keep working while the ESP32 is in deep sleep?
No - WiFi and Bluetooth radios are completely powered down in deep sleep. If your project needs to send data, the flow is: wake up, boot WiFi, connect, send the data, disconnect, then go back to sleep. That connection step takes a second or two each cycle, which is the real cost of staying battery-friendly.
What is the price of an ESP32 board for a deep-sleep battery project in India?
The ESP32 30-Pin Development Board (CP2102, WiFi/Bluetooth) costs Rs.400 at Compoden, with cash on delivery available across India. Prices checked 11 August 2026.
Can I use more than one wake source at the same time?
Each sleep cycle picks one wake configuration - timer, EXT0, EXT1, or touch - via its own enable call like esp_sleep_enable_timer_wakeup(). You call the setup for whichever source you want before esp_deep_sleep_start(); mixing multiple sources on the same sleep call isn't the standard pattern the session's own explanation describes.