← all lessons
Capstone · #19 of 48

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

Power budget formula:
  E_cycle = (I_active × t_active) + (I_sleep × t_sleep)

  Where:
  E_cycle = energy per cycle (mAs)
  I_active = active current (mA)
  t_active = active time (s)
  I_sleep = sleep current (µA, convert to mA)
  t_sleep = sleep time (s)

Battery lifetime:
  Cycles = Battery_capacity (mAs) / E_cycle
  Lifetime = Cycles × Cycle_time

Example:
  I_active = 80mA, t_active = 3s → 240mAs
  I_sleep = 10µA = 0.01mA, t_sleep = 297s → 2.97mAs
  E_cycle = 243mAs

  Battery: 2000mAh = 7,200,000mAs
  Cycles = 7,200,000 / 243 = 29,600
  Lifetime = 29,600 × 5min = 148,000min = 103 days

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 →