>
section 12 of 183 min read

12. Power Management

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:

ModeWhat is onWake latencyTypical I
RunEverything030-80 mA
Idle/sleepCPU clock gated, peripherals on<1 us5-20 mA
StopMost clocks off, RAM retained, RTC/external pins can wake5-20 us50-500 uA
StandbyMost logic off, only specific wake sources100 us-ms1-5 uA
Shutdown / VBatOnly RTC + tiny SRAMreset on wake200-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: 5 mA×50 ms=250 uAs=0.0694 uAh5 \text{ mA} \times 50 \text{ ms} = 250 \text{ uAs} = 0.0694 \text{ uAh}
  • Sleep charge per minute: 1 uA×60 s=60 uAs=0.0167 uAh1 \text{ uA} \times 60 \text{ s} = 60 \text{ uAs} = 0.0167 \text{ uAh}
  • Total per minute: 0.0861 uAh
  • Per year: 0.0861×60×24×365=45,260 uAh45 mAh0.0861 \times 60 \times 24 \times 365 = 45{,}260 \text{ uAh} \approx 45 \text{ mAh}

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.

plaintext
   I  ^
   (mA)|     **                  **                  **
       |    *  *                *  *                *  *
       |   *    *              *    *              *    *
       |  *      *            *      *            *      *
   1uA |--+------+------------+------+------------+------*------>
                  <-- 60 s sleep -->                  ... time
        ^ wake
        | sample 50 ms at 5 mA, transmit 5 ms at 10 mA

That envelope, sleep most of the time, brief active bursts, is the universal shape of low-power IoT.