A 2000 mAh battery powering a microcontroller running its main loop continuously lasts about 24 hours. The same battery powering the same chip with proper sleep management lasts a year. The five-hundred-fold difference is not a rounding error — it is the difference between a viable battery product and an embarrassing one. This article is the deep-dive on how that gap closes.
The numbers throughout are measured on a current-mode bench multimeter (Keysight U1242C) with the chip on a custom test fixture, so you can trust them within roughly ±10%. Your mileage will vary slightly with different boards and firmware.
Energy budget thinking
Stop thinking in volts and amps. Start thinking in milliamp-hours per day. A 2000 mAh battery has 2000 mAh of capacity. If your daily consumption is 5 mAh, your battery lasts 400 days. If your daily consumption is 50 mAh, it lasts 40 days. Every design decision is really a question of how it adds to or subtracts from your daily mAh number.
To compute daily consumption, sum the contribution of each mode the chip spends time in. For an ESP32 reading a sensor every ten minutes:
Active for sensor read + WiFi send: 5 seconds @ 80 mA per cycle
-> per day: 5 sec * 144 cycles * (80 mA / 3600) = 16 mAh
Deep sleep: rest of the time @ 10 uA
-> per day: ~24 hours * 0.01 mA = 0.24 mAh
Total: ~16 mAh per day
2000 mAh / 16 mAh per day = 125 daysNow imagine the firmware skipped deep sleep and ran continuously at 80 mA. Daily consumption: 1920 mAh. Battery life: 1 day. The math drives the architecture.
The power state machine
Every modern microcontroller has multiple power modes, traded off as latency vs current draw. The names vary by vendor; the concepts are universal.
Generic microcontroller power state machine. Vendor names differ; the structure is universal: each step down stops more clocks, saves more power, and accepts longer wake-up latency.
Run mode: the cheapest savings
Even before sleep modes, the run mode itself has knobs. Lowering the CPU clock reduces dynamic power proportionally, sometimes more (slower clock = lower minimum supply voltage = lower static power too).
- Drop the CPU clock when you do not need full speed. STM32L4 at 24 MHz draws under 2 mA versus 10 mA at 80 MHz. ESP32 at 80 MHz versus 240 MHz: roughly half the power.
- Use voltage scaling. Modern MCUs have multiple operating voltage domains; lower clocks allow lower core voltage, which reduces power further (P proportional to V^2).
- Avoid spinning loops. A
while (!flag) {}burns full power doing nothing. Use__WFI()(Wait For Interrupt) instead — the chip drops to sleep mode until the flag-changing interrupt fires.
Peripheral gating
Every peripheral on the chip has a clock that can be disabled when not in use. Disabling a peripheral's clock cuts its power to near zero. This is one of the highest-leverage savings: an unused UART or ADC is wasting battery in the background.
// STM32 HAL example
__HAL_RCC_USART2_CLK_DISABLE(); // turn off when not transmitting
__HAL_RCC_ADC1_CLK_DISABLE(); // ADC not in use
__HAL_RCC_GPIOC_CLK_DISABLE(); // entire port unusedThe ESP32 has similar primitives via the periph_module_disable() API. The savings vary: an unused ADC saves around 100 µA, a UART around 50 µA, a SPI around 30 µA. Individually small; collectively meaningful when you are budgeting microamps.
Wake sources
Every sleep mode has restrictions on what can wake the chip. The deeper the sleep, the fewer the wake sources.
- Run/Sleep: any interrupt wakes the CPU.
- Stop / Light Sleep: only specific peripherals can wake (RTC, EXTI on certain pins, watchdog).
- Standby / Deep Sleep: typically only RTC, dedicated wake pins, or reset.
The wake source dictates the architecture. A motion-triggered camera uses GPIO wake (PIR sensor on a wake-capable pin). A periodic logger uses RTC wake (alarm every 10 minutes). A communication receiver uses peripheral wake (LPUART that can wake on incoming data).
BLE advertising tricks
BLE peripherals advertise periodically — default interval 100 ms. Each advertisement transmits for around 1 ms at 5 mA, then the chip can sleep. Average current at 100 ms interval: about 60 µA. Stretch the interval to 1 second: average drops to 8 µA. To 10 seconds: under 1 µA.
The trade-off is connection latency. A phone scanning for the device may need several scan windows to catch a slow advertiser. For a fitness band you want fast reconnection (100–200 ms intervals); for a temperature sensor that talks to a hub once a minute, multi-second intervals are fine.
Real numbers from a project
From the WiFi temperature logger we covered earlier: ESP32-S3, BME280, 2000 mAh LiPo, deep sleep with 10-minute wake interval.
Phase Current Duration Per cycle
--------------------------------------------------------------
Deep sleep 7 uA ~600 sec 1.2 uAh
Boot + WiFi connect 80 mA ~3 sec 0.067 mAh
BME280 read 12 mA ~0.5 sec 0.0017 mAh
HTTPS POST 100 mA ~2 sec 0.056 mAh
Total per cycle 0.124 mAh
Cycles per day: 144
Daily consumption: 18 mAh
Battery life: 2000 / 18 = 111 daysAbout 3.5 months. Switching to MQTT (less overhead than HTTPS) saves about 0.02 mAh per cycle, extending life to 130 days. Adding TLS certificate caching saves another 5%. Tiny optimisations compound.
Things that quietly destroy battery life
- LDO leakage. A linear regulator drops voltage with linear efficiency. A 5V battery feeding a 3.3V chip via LDO: 34% energy wasted as heat continuously. Use a buck converter instead for any battery project.
- Pull-up resistors during sleep. A 4.7 k pull-up holding a pin high pulls 700 µA continuously. If the chip is sleeping at 10 µA, the pull-up is 70× the chip's draw. Configure pull-ups only when needed; disable them in sleep.
- I2C bus held active. Even with the chip in deep sleep, an active I2C bus with pull-ups draws power. Cut external sensor power with a MOSFET on the high side during sleep, restore before reading.
- Floating GPIO inputs. A floating CMOS input draws current as it switches between high and low at random. Configure unused pins as outputs or with explicit pull-ups/downs.
- Clock to peripherals you do not use. Default startup code often enables clocks to most peripherals. Disable explicitly.
Measurement matters
The single most valuable tool for power debugging is a current-monitoring power supply or a sensitive multimeter in current-shunt mode. The Joulescope, Otii Arc, and Nordic Power Profiler Kit II ($90) all let you watch current consumption in real time, including the brief spikes during wake events that average meters miss entirely.
Without measurement, every claim about power consumption is a guess. With measurement, you find out which sleep mode you are actually in (often not the one you configured), how long peripherals take to power down, and which library calls have hidden delays that keep the chip awake.
Frequently Asked Questions
Why is my deep sleep current 100 µA instead of 10 µA?
Almost certainly an external component you forgot. The CP2102 USB-serial chip on most dev boards draws 100 µA even when no USB cable is connected. Power LEDs draw 2 mA continuously. External regulators have quiescent current. For battery products, design a custom board without development-only components.
Should I use external sensors that can sleep?
Yes, when available. The BME280 has a forced-mode that takes a single reading then drops to 0.1 µA. The DS3231 RTC draws 1 µA while keeping time. Sensors without sleep capability should be powered through a MOSFET that the MCU switches off between readings.
How do I measure 1 µA current draw?
A multimeter in current mode adds a burden voltage that can prevent the chip from operating correctly at low currents (the meter introduces resistance which causes voltage drop). Either use a Joulescope/Power Profiler Kit which measures without burden voltage, or place a known shunt resistor (10 ohm) and measure the voltage drop across it with a high-impedance instrument.
What about LoRa or NB-IoT for battery projects?
LoRa is dramatically more power-efficient than WiFi for telemetry: an SX1262 transmits at 30 mA for 100 ms then sleeps at 0.2 µA. For a sensor sending one packet per ten minutes, LoRa enables a year on a pair of AAs. NB-IoT lands in between — usable for low-frequency reporting (once an hour or less), but more power-hungry than LoRa.
How much does temperature affect battery life?
Significantly. A LiPo at 0°C delivers about 80% of its rated capacity. At −20°C, around 50%. For outdoor projects, oversize the battery or insulate the enclosure.
Share your thoughts
Worked with this in production and have a story to share, or disagree with a tradeoff? Email us at support@mybytenest.com — we read everything.