Power is the embedded engineer's eternal struggle. A mains-powered system can afford to leave the CPU running at full clock; a battery-powered one cannot.
12.1 Sleep modes, in detail
Most modern MCUs offer a hierarchy of low-power modes:
| Mode | What is on | Wake latency | Typical I |
|---|---|---|---|
| Run | Everything | 0 | 30-80 mA |
| Idle/sleep | CPU clock gated, peripherals on | <1 us | 5-20 mA |
| Stop | Most clocks off, RAM retained, RTC/external pins can wake | 5-20 us | 50-500 uA |
| Standby | Most logic off, only specific wake sources | 100 us-ms | 1-5 uA |
| Shutdown / VBat | Only RTC + tiny SRAM | reset on wake | 200-500 nA |
Names differ across vendors (STM32 calls them Sleep / Stop / Standby / Shutdown; Nordic uses System ON / System OFF; ESP32 has Modem-sleep / Light-sleep / Deep-sleep / Hibernation).
12.2 Wake sources
Common sources: external pin (button), RTC alarm, low-power timer, ADC threshold, comparator, BLE radio activity, watchdog. The deeper the sleep, the fewer sources available.
12.3 Coin-cell math
CR2032: nominal 3 V, 220 mAh, self-discharge ~1 % per year.
Suppose your sensor wakes every minute, samples for 50 ms at 5 mA, then sleeps at 1 uA.
- Active charge per minute:
- Sleep charge per minute:
- Total per minute: 0.0861 uAh
- Per year:
220 mAh / 45 mAh/year = ~4.9 years. Add 30 % for self-discharge and temperature, and you get the typical "5-year coin-cell battery" advertised on sensors. Cut sleep current to 500 nA (some Nordic, Ambiq, ST options) and you push it to ~8 years.
If you add a single radio transmission (10 mA for 5 ms) per minute, that adds another 50 uAh/minute, halving battery life. Every milliamp counts.
12.4 Software techniques
- Tickless idle. RTOS skips ticks while idle, computes how long to sleep, asks RTC to wake.
- DMA + sleep. Set up DMA, sleep until done.
- Event-driven design. No spinning, no polling, no
delay(). - Aggressive peripheral gating. Only enable a peripheral while you need it. ADCs, flash boost converter, brown-out detector all draw current.
- Pin state on sleep. A floating GPIO leaks more than a tied one. Tie all unused pins to a defined state.
- Lowest-power oscillators. 32 kHz LSE for RTC. Internal LSI for cheap wake; LSE for accuracy.
- Profile. Use a power profiler. Assumptions are often off by 10x.
12.5 Real-world
ARM mbed devices, Nordic nRF52, Apollo3 (Ambiq) routinely hit sub-microamp idle. Pacemakers run for 7-10 years. Wireless sensors (Decentlab, Disruptive Technologies) advertise 10-15 years. Coin-cell BLE beacons (Estimote, iBeacon clones) hit 2-5 years. The key is aggressive sleep with brief radio bursts.
I ^
(mA)| ** ** **
| * * * * * *
| * * * * * *
| * * * * * *
1uA |--+------+------------+------+------------+------*------>
<-- 60 s sleep --> ... time
^ wake
| sample 50 ms at 5 mA, transmit 5 ms at 10 mAThat envelope, sleep most of the time, brief active bursts, is the universal shape of low-power IoT.