Capstone · #19 of 52

Power Budget + Measurement

Calculating Battery Lifetime

Why it matters

Power budget tells you if your design will work. Without it, you're guessing how long the battery will last.

The idea

What Is a Power Budget?

A power budget calculates total energy consumption:

Typical Values

ESP32 power consumption:

Calculation

For 5-minute cycle:

Battery Lifetime

For 2000mAh battery:

Measurement

Use multimeter in current mode:

Demo

Adjust Active Current, Active Time, Sleep Current, and Sleep Time to see how battery lifetime changes.

Watch for:

E/cycle: 243 mA·s lifetime: 103 days

Key takeaways

Going deeper

Real-world power consumption varies with temperature, battery age, and component tolerances. Always add a 20–30% safety margin. For production, use a power profiler (like Nordic Power Profiler) to measure actual consumption. Consider battery self-discharge (~5% per month for LiPo).

Math details

A power-budget diagram showing one active interval, one sleep interval, and the battery-lifetime calculation.
Do the budget over one repeating cycle, then divide battery capacity by that cycle cost. Keep units consistent: mA times seconds gives mA-s. · TooFoo original SVG

The compact formula is E_cycle = I_active * t_active + I_sleep * t_sleep. Convert sleep current into milliamps before adding it to the active term. Battery life then comes from cycles = battery_capacity / E_cycle and lifetime = cycles * cycle_time.

Implementation

LLM Prompt: Power Budget Calculator

Write Rust function to calculate power budget and battery lifetime.
Input: active current, active time, sleep current, sleep time, battery capacity.
Output: energy per cycle, cycles, lifetime (days). Include validation:
warn if lifetime < 30 days (may need optimization).

Lab Exercise

  1. Measure active current with multimeter (series measurement)
  2. Measure sleep current (may need µA range)
  3. Time each operation (sensor read, Wi‑Fi connect, transmit)
  4. Calculate power budget — verify < 300mAs per cycle
  5. Calculate battery lifetime — verify > 90 days

full glossary →