Hands-On Exercise: Calculate Battery Life with Real Power Measurements

Hands-On Exercise: Calculate Battery Life with Real Power Measurements

Objective: Apply integrals (energy budgeting) and exponentials (battery discharge curves) to estimate how long an ESP32 sensor will run on two AA batteries.

Given Data:

  • Battery capacity: two AA alkaline = 2,000 mAh at 3V (6,000 mWh total energy)
  • ESP32 power states:
    • Active (Wi-Fi transmit): 160 mA for 2 seconds
    • Light sleep: 0.8 mA for 58 seconds
    • Measurement interval: Every 60 seconds

Step 1: Calculate Average Current (from Section A.2, Integrals)

Using the duty cycle formula from Quick Reference:

Iavg=(Iactive×Dactive)+(Isleep×Dsleep)I_{avg} = (I_{active} \times D_{active}) + (I_{sleep} \times D_{sleep})

Where D = duty cycle (fraction of time): - Dactive=2s/60s=0.0333D_{active} = 2s / 60s = 0.0333 (3.3% of time) - Dsleep=58s/60s=0.9667D_{sleep} = 58s / 60s = 0.9667 (96.7% of time)

Iavg=(160mA×0.0333)+(0.8mA×0.9667)I_{avg} = (160mA \times 0.0333) + (0.8mA \times 0.9667) Iavg=5.33mA+0.77mA=6.1mAI_{avg} = 5.33mA + 0.77mA = 6.1mA

Step 2: Calculate Battery Life

Hours=Battery Capacity (mAh)Average Current (mA)=2000mAh6.1mA=328 hoursHours = \frac{Battery\ Capacity\ (mAh)}{Average\ Current\ (mA)} = \frac{2000mAh}{6.1mA} = 328\ hours

Days=328÷24=13.7 daysDays = 328 \div 24 = 13.7\ days

Step 3: Account for Battery Discharge Curve (Section B.1, Exponentials)

Alkaline terminal voltage changes during discharge; its usable capacity depends on load, temperature, and the device cutoff voltage. Assume usable capacity is ~80% at a 1.1V cutoff:

Daysactual=13.7×0.80=11 daysDays_{actual} = 13.7 \times 0.80 = 11\ days

Challenge Extension:

  • What if you reduce transmit time to 1 second (faster Wi-Fi)? Recalculate IavgI_{avg}.
  • What if you switch to lithium AA (2,500 mAh, flatter discharge curve = 90% usable)? New battery life?
  • Use Section B.1 RC time constant: If ESP32 has 100uF decoupling cap, how long to charge from sleep voltage?

Answer: With 1s transmit, IavgI_{avg} drops to 3.44 mA -> 19.3 days (alkaline) or 27 days (lithium).

Why This Matters: Battery life estimation is the #1 requirement for field-deployed IoT. This exercise applies integrals (averaging), exponentials (discharge curves), and real-world engineering judgment (efficiency factors).

Back to the chapter