Ir al contenido

Battery Life Calculation

Esta página aún no está disponible en tu idioma.

Battery Life Calculation

This section provides a systematic method for calculating battery life in IoT button applications. By the end of this section, you will be able to:

  • Calculate energy consumption for both active and sleep periods
  • Estimate battery life based on usage patterns
  • Create a battery life budget for buyer consultations
  • Explain the factors that affect battery longevity

Before starting this section, please ensure:

Battery life is calculated using the concept of milliamp-hours (mAh) — a measure of electrical charge capacity.

Energy Consumed (mAh) = Current (mA) × Time (hours)
Example: A device drawing 60 mA for 5 seconds
= 60 mA × (5 / 3600) hours = 0.083 mAh

For a device with two states (active + sleep), total daily consumption is:

Daily Consumption = (Active Current × Active Time per Day) + (Sleep Current × Sleep Time per Day)

A button press cycle follows this pattern:

Current
│
80mA ┤
│ ┌───────────────────┐
│ │ Active Phase │
│ │ (WiFi + MQTT) │
│ └───────────────────┘
│
│ ┌──────────────
│ │ Deep Sleep Phase
~5µA ┤────────────────────┘
│
└─────────────────────────────────────── Time
↑ Press ↑ Back to ↑ Next Press
Button Sleep (hours/days later)
│◄── Active (~5s) ──────►│◄─── Sleep (hours to days) ──►│

Step 1: Measure or Estimate Current Values

Section titled “Step 1: Measure or Estimate Current Values”
Parameter Symbol XIAO ESP32-C3 Value Notes
Active current (WiFi on) I_active 60 mA Measured at 3.3V
Active current (WiFi off) I_idle 15 mA Not used in button application
Deep sleep current I_sleep 5 µA = 0.005 mA RTC + GPIO wake configured
WiFi connection time T_wifi 2-3 seconds Optimized connection
MQTT publish time T_mqtt 0.5-1 second Single message
Post-publish delay T_post 0.5 seconds Serial flush, cleanup
Active time per press:
T_active = T_wifi + T_mqtt + T_post
= 2.5s + 0.5s + 0.5s
= 3.5 seconds
Energy per press:
E_press = I_active × (T_active / 3600)
= 60 mA × (3.5 / 3600) hours
= 0.0583 mAh per press

Step 3: Calculate Daily Energy Consumption

Section titled “Step 3: Calculate Daily Energy Consumption”

Example: 2 presses per day

Active energy:
E_active_daily = 0.0583 mAh × 2 = 0.1166 mAh
Sleep energy (24 hours minus active time):
Sleep time = 24 - (2 × 3.5 / 3600) ≈ 23.998 hours
E_sleep_daily = 0.005 mA × 23.998 h = 0.120 mAh
Total daily consumption:
E_daily = 0.1166 + 0.120 = 0.237 mAh per day

Example formulas for different usage frequencies:

Presses/Day Active Energy (mAh) Sleep Energy (mAh) Total Daily (mAh)
0 (standby) 0 0.120 0.120
1 0.058 0.120 0.178
2 0.117 0.120 0.237
5 0.292 0.120 0.412
10 0.583 0.120 0.703
20 1.167 0.120 1.287
50 2.917 0.119 3.036
Usable battery capacity = Capacity × Depth of Discharge (DoD)
For safety, use 80% DoD (avoid deep discharge):
Usable = 350 mAh × 0.8 = 280 mAh
Battery life = Usable capacity / Daily consumption
Example (350 mAh battery, 2 presses/day):
Life = 280 mAh / 0.237 mAh/day = 1,181 days ≈ 3.2 years

Battery life for common scenarios:

Battery 1 Press/Day 2 Presses/Day 10 Presses/Day 50 Presses/Day
150 mAh 674 days 506 days 171 days 40 days
300 mAh 1,348 days 1,012 days 341 days 79 days
350 mAh 1,573 days 1,181 days 398 days 92 days
500 mAh 2,247 days 1,685 days 569 days 132 days
1000 mAh 4,494 days 3,370 days 1,138 days 264 days

Real-world adjustment: These calculations assume ideal conditions. Real battery life is typically 70-85% of calculated values due to battery aging, temperature variations, and measurement tolerances.

For rapid estimation during buyer consultations, use these simplified formulas:

Battery life (days) ≈ (Battery capacity × 0.8) / (0.12 + 0.058 × Presses_per_day)
Where:
- 0.8 = usable capacity factor
- 0.12 = baseline daily sleep consumption (mAh)
- 0.058 = energy per button press (mAh)

Example (350 mAh battery, 5 presses/day):

Life ≈ (350 × 0.8) / (0.12 + 0.058 × 5)
= 280 / 0.41
≈ 683 days ≈ 22 months
Factor Impact Mitigation
Battery self-discharge 3-5% capacity loss/month Use quality batteries; account in calculation
Temperature 10-20% reduction in cold (< 0°C) Insulate or use appropriate chemistry
Battery aging 20% capacity loss after 300 cycles Replace batteries annually in production
WiFi signal strength Weak signal → longer connection time → higher energy Ensure good WiFi coverage
Measurement tolerances ±10% on current measurements Add 20% safety margin
Capacitor leakage 1-5 µA additional drain Minimize external components
  • Per-press energy calculated and consistent with measurements
  • Daily consumption model accounts for actual usage pattern
  • Safety margin (20%) included in final estimate
  • Battery life estimate matches real-world results
  • Low-battery warning threshold calculated

Issue: Battery Life Shorter Than Calculated

Section titled “Issue: Battery Life Shorter Than Calculated”

Possible Causes:

  • Actual sleep current higher than measured (check GPIO states)
  • WiFi connection takes longer than expected
  • Battery capacity lower than rated (cheap batteries)
  • Temperature effects reduce effective capacity

Solution:

// Log actual active time for verification
void logActiveTime() {
static unsigned long startTime = 0;
if (startTime == 0) {
startTime = millis();
} else {
unsigned long activeMs = millis() - startTime;
Serial.print("Actual active time: ");
Serial.print(activeMs);
Serial.println(" ms");
startTime = 0;
}
}
  • ✅ Always add a 20% safety margin to calculated battery life
  • ✅ Measure actual current rather than relying on datasheet values
  • ✅ Consider the weakest link — often WiFi connection time, not sleep current
  • ✅ Monitor battery voltage in firmware to detect end-of-life
  • ✅ Use known-brand batteries — generic batteries often have lower actual capacity
  • ❌ Do not discharge LiPo below 3.0V — permanent damage and safety risk
  1. Per-press energy is ~0.058 mAh for XIAO ESP32-C3 with optimized WiFi
  2. Daily sleep consumption is ~0.12 mAh regardless of usage
  3. Usage frequency affects battery life linearly — more presses = proportionally shorter life
  4. 80% depth of discharge is a safe usable capacity limit
  5. Real life is 70-85% of calculated — add safety margins

Target Audience: Alibaba.com IoT Pre-sales Engineers
Status: ✅ Completed


Building a commercial IoT product?

We provide ESP32 ODM design-to-manufacturing services. From prototype to production — the team behind this tutorial can build it with you.

💡 Mention tutorial.imagrove.com in your Alibaba chat with us — get 10% off your custom project quote.

Talk to us →

Publicado por primera vez entutorial.imagrove.com/es/project-work-order-button/06-battery-life-calculation/Al citar o reproducir, indica la fuente Imagrove y enlaza a esta página.

¿Dudas o problemas con este tutorial?

Inicia sesión con GitHub para comentar. Si un paso te falla, avísanos: lo verificamos y actualizamos el tutorial.