ESP32: deep sleep and battery life, the honest numbers
Put an ESP32 into deep sleep and measure the actual current draw with a multimeter. Includes what to expect on different boards and battery chemistries.
Deep sleep is the difference between a project that lasts a weekend on a USB power bank and one that lasts a year on a couple of AAs. This is the tutorial I wish someone had written for me the first time I tried to build a battery-powered sensor.
The short version: an ESP32 in deep sleep pulls about 10 uA when wired right. Wired wrong, it pulls 30 mA and your battery is dead in two days. This tutorial is about getting to the 10 uA.
What you need
- ESP32 dev board (the bare module, not a board with a USB-serial chip you do not need powered; more on this below)
- Multimeter with a uA range, or a USB power meter that can read down to 0.01A
- A battery (single 18650, two AAs in series, or a LiPo)
- Jumper wires
The two kinds of ESP32 boards
This matters.
- Plain ESP32 dev boards (e.g. ESP32-DevKitC, NodeMCU-32S, most of what you find on Amazon). These have a USB-serial chip (CP2102 or CH340) and a voltage regulator that draws about 10-20 mA even when the ESP32 is asleep.
- Bare ESP32 modules (the WROOM-32 chip on its own, or a board that explicitly says “low power”). These can get to deep sleep currents of about 10 uA.
If you are serious about battery life, you need option 2, or you need to modify option 1 (cut the trace to the regulator LED, etc., which I do not recommend for beginners).
The code
#define uS_TO_S_FACTOR 1000000ULL
#define TIME_TO_SLEEP 60 // seconds between wake-ups
RTC_DATA_ATTR int bootCount = 0;
void setup() {
Serial.begin(115200);
delay(1000); // give the serial time to attach
bootCount++;
Serial.println("Boot number: " + String(bootCount));
// ---- do your work here ----
// (read a sensor, send to MQTT, whatever)
// ----------------------------
Serial.println("Going to sleep for " + String(TIME_TO_SLEEP) + " seconds");
esp_sleep_enable_timer_wakeup(TIME_TO_SLEEP * uS_TO_S_FACTOR);
esp_deep_sleep_start();
}
void loop() {
// never reached
}
Upload it. Open Serial Monitor. You will see one boot message, then silence
for 60 seconds, then another boot message. That is the chip waking up,
running setup(), and going back to sleep.
Measuring the actual current
This is the part most tutorials skip. Put your multimeter in series with the battery (between the battery positive and the board’s VIN or BAT pin). Use the uA or mA range.
What you should see:
- During the boot (about 1-3 seconds): 80-260 mA, spiky.
- During sleep: the steady-state current when nothing is happening.
For a plain dev board, “during sleep” is going to be 10-20 mA. That is the USB-serial chip and the regulator. For a bare module, it should be under 50 uA.
If you see steady 30 mA, the most common cause is the on-board LED. Find the
LED on your board, find the GPIO it is on (usually GPIO 2), and turn it off
in setup():
pinMode(2, OUTPUT);
digitalWrite(2, LOW);
Battery math
A single 18650 is about 2500 mAh. If your sleep current is 10 uA and your active current is 100 mA for 3 seconds every 60 seconds:
- Sleep: 10 uA average (because you sleep 99.95% of the time)
- Active: 100 mA * 3s / 60s = 5 mA average
- Total: about 5 mA average
- Battery life: 2500 / 5 = 500 hours = 20 days
That is with a plain dev board. With a bare module at 10 uA sleep, you are talking about 6 months on the same battery.
What wakes the ESP32 up
esp_sleep_enable_timer_wakeup(seconds): after N secondsesp_sleep_enable_ext0_wakeup(gpio, level): when a GPIO goes high or low (e.g. a button press)esp_sleep_enable_touchpad_wakeup(): when a touch pin is touched
You can combine wakeup sources (timer OR button). The ESP32 wakes on the first one that fires.
What eats battery when nothing is happening
In rough order of impact:
- The USB-serial chip on dev boards (~5-10 mA)
- The voltage regulator (~5-10 mA when fed 5V; less when fed battery direct)
- The power LED (~1-2 mA)
- Pull-up resistors on I2C lines (~0.5 mA total if both lines are pulled up)
- The ESP32 itself (~10 uA in deep sleep)
If you are chasing uA-level sleep current, you need to address all of them. For “weekend project on a power bank,” items 1-3 do not matter.
When to use a bare module vs. a dev board
- Dev board: prototyping, projects that plug into USB, anything that needs the serial chip for programming
- Bare module: battery-powered projects, anything deployed, anything where you have already committed to the design
This is the project I do not cut corners on. The dev board is fine for testing; the bare module is what ships.
What to build next
- The 18650 + TP4056 tutorial pairs with sleep for multi-month battery builds.
- The weather station project uses deep sleep between readings.
- The book IoT with ESP32 bundles the power tutorials.