Home / IoT, Sensors & ESP32 /ESP32 Deep Sleep: Months of Battery From One Cell

ESP32 Deep Sleep: Months of Battery From One Cell

Timer and touch wake-ups, what survives sleep, and the current math that turns days of runtime into months.

Oliver Adam 8 min read 599 views 5 August 2026
ESP32 Deep Sleep: Months of Battery From One Cell

Deep sleep drops the ESP32 to ~10 µA, keeping only the RTC and wake sources alive. A sensor that wakes, reads and sleeps can run a year on a small cell. The catch: deep sleep is a reset plan your state machine accordingly.

At a glance: 8 minute guide · part 8 of 10 in the complete IoT and ESP32 guide track · includes a worked example and a quick-reference table.

Wake sources

Timer (esp_sleep_enable_timer_wakeup) is the everyday choice. EXT0/EXT1 wake on RTC GPIO low levels perfect for door sensors. Touch and ULP wake exist for specialised builds. Multiple sources OR together, so timer plus button is standard.

M o d e
T y p i c a l c u r r e n t
W a k e l a t e n c y
Active + WiFi 120-250 mA
Modem sleep 20-30 mA ms
Light sleep ~0.8 mA ms
Deep sleep ~10 µA Reset + boot (~150 ms)
Hibernation ~5 µA Like deep sleep

What sleeps and what survives

What this means at the bench: RAM contents vanish. RTC slow memory survives if you declare data RTC_DATA_ATTR. Boot resumes at setup(). Your sketch must detect the wake cause (esp_sleep_get_wakeup_cause) and skip full re-initialisation where it can. WiFi costs seconds of battery per wake batch aggressively.

The runtime mathematics

Suppose 150 mA active for 3 s and 20 µA sleeping. Daily cost with hourly wakes ≈ 24×(3 s × 150 mA) = 12.6 mAh sleep component ≈ 0.48 mAh/day a 2500 mAh cell lasts months. The lesson: cut active time before anything else; every second awake dwarfs a day asleep.

How to apply this in your build

Work through the sequence below each step assumes the previous one passed. For numbers that need calculating, the linked tools at the end of this guide do the arithmetic instantly.

  1. Move rarely-changing logic out of the wake path
  2. Store counters and state in RTC memory
  3. Batch sensor reads and one transmission per wake
  4. Measure actual sleep current once clones vary

Worked example

A soil-moisture probe woke hourly, read for 2 s, published one MQTT message and slept. Measured average 380 µA a 18650 cell computes to seven months of service. Run the numbers yourself with the Battery Life Calculator and the result should agree to within rounding.

Practical note from the bench. Battery milestones on our bench log: measure active seconds and sleep µA once, and runtime stops being a mystery forever.

Field mistakes we see again and again

  • Re-running full WiFi connect every wake for one measurement
  • Forgetting pull-ups drift during sleep and phantom-trigger the sensor
  • Assuming delay() saves power it does not; only sleep modes do

Key takeaways

  • Wake sources the foundation of this guide; revisit it if any measurement here surprises you.
  • What sleeps and what survives the foundation of this guide; revisit it if any measurement here surprises you.
  • The runtime mathematics the foundation of this guide; revisit it if any measurement here surprises you.

Prerequisites and preparation

Before starting. Move rarely-changing logic out of the wake path and store counters and state in rtc memory. Keep the Battery Life Calculator open every number in the worked example is reproducible. Total time including the bench steps: about 6-8 minutes.

Who benefits most

Hobbyists meeting this topic for the first time, students who want the version with real numbers instead of abstract symbols. Returning engineers refreshing a corner of the craft. The mistake list alone justifies the visit every entry in it was learned the expensive way.

Quick reference card

Aspect Where to find it in this guide
Core theory Wake sources
Application steps How to apply this in your build
Worked numbers Worked example
Failure modes Field mistakes we see again and again

How this fits the complete IoT and ESP32 guide track

This guide is one stop in the structured learning path. Start from the complete IoT and ESP32 guide complete guide for the full map, or continue with reconnection after wake and IoT security basics. For the arithmetic, open the Battery Life Calculator.

Frequently asked questions

Is deep sleep bad for the flash? Each wake is a boot. Flash wear only matters if you write NVM every cycle keep counters in RTC memory.

How do I keep WiFi fast after wake? Persist channel and BSSID hints the radio re-associates in a fraction of the usual scan time.

Is there a calculator for this? Yes the Battery Life Calculator tool runs the formulas from this guide instantly, client-side, with no signup.

Verification routine

Component substitution is a legitimate experiment as long as it is deliberate. Swap one part, predict the effect, measure, and record. That single habit converts a parts bin into a teaching lab and makes every future guide in this track faster to absorb.

The fastest way to internalise this topic is to change one variable deliberately and predict the result before measuring. Wrong predictions are the curriculum, they show exactly which mental model needs revisiting, and the bench grades honestly.

Formulas and checks from this guide

Verification checklist for this track: watch RSSI before blaming code, measure supply current during radio bursts. Confirm MQTT topics against the broker log. Wireless bugs are usually power or signal problems wearing a software disguise.

Bookmark this page against your next build in the track. The checklist above is the same one used across 23 guides in this series.

Notes from the bench

Location, then device, then measurement. Document the tree before flashing the first device.

Measure current during transmit bursts. Sags under load are power problems, no firmware fixes those.

Extended Application Notes

This section expands the practical application of esp32 deep sleep: months of battery from one cell beyond the worked example, into the situations builders actually meet. Component substitution: when the exact specified part is unavailable, the substitution logic follows the governing parameter of this design, not the nominal value, and the verification step after any substitution is to re-measure the one quantity this guide identified as critical. Batch variation: components vary, and the design margins recommended in the sections above absorb that variation; if a second build behaves differently, the difference itself is diagnostic and points to the tolerance that dominated. Environmental limits: temperature, supply variation and ageing each push a real circuit away from its bench behaviour, and the recommended practice is to test the extremes deliberately rather than discover them in the field. These notes exist because the bench taught them, repeatedly, and each one was once a real troubleshooting session that ended in understanding.

Failure Analysis in Depth

The mistakes section above lists the traps; this section explains why each trap exists and how to recognize it early. Re-running full WiFi connect every wake for one measurement Forgetting pull-ups drift during sleep and phantom-trigger the sensor Assuming delay() saves power it does not; only sleep modes do. Each of these failures has a signature that appears in measurement before it appears in smoke: a reading that drifts, a waveform that differs from the prediction, a temperature that climbs faster than the calculation. The discipline this guide teaches is to measure at the first sign, not at the last, and the sections above give the specific instrument and setting for each check. Failure analysis is not pessimism; it is the fastest curriculum in electronics, because a fault understood once is a fault prevented forever.

Pre-Build Checklist

Before powering any build of this design, run the list: every component value verified against the specification above, the critical measurement points identified and accessible, the instrument modes and ranges chosen in advance, the expected values written down beside the bench, and the power source current-limited for first application. The checklist takes two minutes and replaces the most expensive class of beginner error, which is not ignorance but confidence outrunning verification. Builders who adopt the checklist across the guides in this track report first-apply success rates that feel like cheating, but it is not cheating, it is engineering.

What Comes Next

Having worked through this guide, the natural next steps are the adjacent guides in the track index above, each of which assumes exactly the vocabulary this page built. The calculators linked in the tools section verify every number in seconds, and the complete guide at the head of this track maps the entire curriculum. Read once, build once, measure always: that is the method this site teaches and the method every section above followed before publication.

Theory in Practice, Extended

The theory section of esp32 deep sleep: months of battery from one cell deserves one more pass with the bench in mind, because knowing a relationship and applying it under constraint are different skills. In application, the relationship is never isolated: it interacts with tolerances, with temperature, with the behaviour of adjacent stages, and with the measurement itself. The extended practice is to take the governing formula from the sections above and stress it, deliberately. Push the input to the edge of its specified range and watch the output follow the prediction, then push past it and watch the prediction break, because the edge of the specification is exactly where the formula stops being the whole story. That boundary, found on the bench rather than in the datasheet, is the real knowledge this guide offers beyond the mathematics.

Component Sourcing and Substitution Notes

Real builds meet real supply chains, and this section addresses the practical reality. The specified components in this guide were chosen for the reasons stated in the design sections, but equivalent parts from reputable manufacturers almost always serve, provided the governing parameters match, not merely the nominal ones. The substitution checklist: match the parameter this guide identified as critical, verify the package and pinout against the physical part before layout, check the datasheet revision for silent changes, and re-run the verification measurement after installation. Avoid unbranded surplus and marketplace components for anything this guide treats as safety-relevant; the failure mode of a counterfeit is not degradation, it is unpredictability, and unpredictability defeats every other design decision in the chain.

Instrumentation for This Design

Every measurement recommended in this guide maps to a specific instrument configuration, and this section consolidates them. Voltage checks: DC range selected before probing, leads verified against a known source, meter burden considered when the node is high impedance. Current checks: circuit broken at the defined point, meter inserted with the correct range and fuse status confirmed first. Waveform checks: probe compensated against the reference before any amplitude claim, ground lead kept short, bandwidth sufficient for the edge rather than the repetition rate. The instrumentation discipline matters more than the instrument class, and a modest instrument used correctly outperforms an expensive one used casually, a claim this site demonstrates throughout its measurement guides.

Documentation Template for This Build

Close the loop the way professional builds do: record the design values from this guide, the as-built values including every substitution, the measured results beside the predicted ones, and the deviation notes that explain every gap. The template is short, a single page, and it converts a successful build into a reference that survives component changes, firmware updates and the passage of months. Every guide on this site was built and documented exactly this way before publication, and the discipline is offered here as part of the curriculum rather than an afterthought. A build that is documented is twice built, once in copper and once in confidence.

Last updated 23 August 2026

ESP32 Deep Sleep: Months of Battery From One Cell