Skip to content
Tutorial
10 min read
June 8, 2026

ESP32 Deep Sleep Guide: Extend Battery Life from Days to Months

ESP32 draws 240mA at full power. In deep sleep, that drops to 10µA. This guide shows how to use deep sleep modes to run ESP32 projects on battery for months.

ESP32 Deep Sleep Guide: Extend Battery Life from Days to Months

The ESP32 is power-hungry when active — WiFi alone draws 80–240mA. But with proper deep sleep management, the same chip can sip current at 10 microamps, making battery-powered projects that last months or even years entirely realistic.


Understanding Sleep Modes

ModeCPUWiFi/BTRAMCurrent
ActiveONONON80–240mA
Modem SleepONOFFON20–30mA
Light SleepPausedOFFON~0.8mA
Deep SleepOFFOFFRTC only~10µA
HibernationOFFOFFOFF~2.5µA

Deep sleep is the sweet spot for most battery-powered IoT sensors.


Basic Deep Sleep Code

C++

Wakeup Sources

Timer wakeup — Wake after N seconds. Most common for sensors.

esp_sleep_enable_timer_wakeup(30 * 1000000ULL); // 30 seconds

External wakeup (EXT0) — Wake when a single GPIO goes HIGH or LOW. Use for PIR sensors, button presses.

esp_sleep_enable_ext0_wakeup(GPIO_NUM_33, 1); // Wake on GPIO33 = HIGH

Touch wakeup — Wake when a touch pin is touched. Useful for wearables.

touchSleepWakeUpEnable(T3, 40); // Wake when touch pin T3 drops below threshold 40

Battery Life Calculation

For a weather sensor that wakes every 5 minutes, connects WiFi, reads DHT22, sends MQTT, and sleeps:

  • Active time: ~3 seconds at ~120mA average = 0.1mAh per cycle
  • Sleep time: 297 seconds at 0.01mA = 0.00083mAh per cycle
  • Per cycle total: ~0.1mAh
  • Cycles per day: 288
  • Daily consumption: ~28.8mAh
  • 2000mAh battery: ~69 days

Optimize the active period and you can push past 100 days easily.


Common Mistakes

Using delay() instead of deep sleep: delay(30000) keeps the CPU and RAM active for 30 seconds at full power. esp_deep_sleep_start() drops to 10µA for the same period.

Not holding GPIO state during sleep: External peripherals (sensors, displays) may reset or behave unexpectedly when the ESP32 wakes. Use RTC GPIO pins for peripherals that need stable power.

Long WiFi reconnection: Each wake-sleep cycle reconnects WiFi from scratch (~1–2 seconds). Consider storing WiFi channel and BSSID in RTC memory to reduce reconnection time to under 200ms.

Get new projects straight to your inbox

Arduino, ESP32 & IoT tutorials — new builds, firmware tips, Wokwi guides. No spam.

ESP32 Deep Sleep Guide: Extend Battery Life from Days to Months | SolderHub