viewof batteryCap = Inputs.range([100, 3000], {
value: 225,
step: 25,
label: "Battery Capacity (mAh)",
hint: "CR2032 coin cell = 225mAh, AA alkaline = 2500mAh"
})
viewof sleepCurrent = Inputs.range([0.1, 10], {
value: 0.8,
step: 0.1,
label: "Sleep Current (µA)",
hint: "Modern Cortex-M: 0.5-2 µA"
})
viewof activeCurrent = Inputs.range([1, 20], {
value: 8,
step: 0.5,
label: "Active Current (mA)",
hint: "MCU + BLE transmit: 5-15 mA"
})
viewof activeDutyCycle = Inputs.range([0.01, 10], {
value: 0.1,
step: 0.01,
label: "Active Duty Cycle (%)",
hint: "1 sec tx per 1000 sec = 0.1%"
})
sleepCurrentMA = sleepCurrent / 1000
avgCurrent = (sleepCurrentMA * (100 - activeDutyCycle) / 100) + (activeCurrent * activeDutyCycle / 100)
batteryLifeHours = batteryCap / avgCurrent
batteryLifeYears = (batteryLifeHours / (24 * 365)).toFixed(2)
html`
<div style="background: #f8f9fa; padding: 20px; border-radius: 8px; border-left: 4px solid #3498DB;">
<div style="color: #2C3E50; margin-top: 0; font-size: 1rem; font-weight: 700;">Battery Life Analysis</div>
<div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-top: 15px;">
<div style="background: white; padding: 12px; border-radius: 6px; box-shadow: 0 2px 4px rgba(0,0,0,0.1);">
<div style="color: #7F8C8D; font-size: 0.85em; margin-bottom: 4px;">Battery</div>
<div style="color: #2C3E50; font-size: 1.4em; font-weight: bold;">${batteryCap} mAh</div>
</div>
<div style="background: white; padding: 12px; border-radius: 6px; box-shadow: 0 2px 4px rgba(0,0,0,0.1);">
<div style="color: #7F8C8D; font-size: 0.85em; margin-bottom: 4px;">Avg Current</div>
<div style="color: #3498DB; font-size: 1.4em; font-weight: bold;">${avgCurrent.toFixed(3)} mA</div>
</div>
<div style="background: white; padding: 12px; border-radius: 6px; box-shadow: 0 2px 4px rgba(0,0,0,0.1);">
<div style="color: #7F8C8D; font-size: 0.85em; margin-bottom: 4px;">Battery Life</div>
<div style="color: #16A085; font-size: 1.4em; font-weight: bold;">${batteryLifeYears} years</div>
</div>
</div>
<div style="margin-top: 15px; padding: 12px; background: ${batteryLifeYears < 1 ? "#fff3cd" : "#d4edda"}; border-radius: 6px; border-left: 3px solid ${batteryLifeYears < 1 ? "#E67E22" : "#16A085"};">
<strong style="color: ${batteryLifeYears < 1 ? "#E67E22" : "#16A085"};">${batteryLifeYears < 1 ? "Short battery life" : "✓ Excellent battery life"}</strong>
<span style="color: #2C3E50; display: block; margin-top: 6px; font-size: 0.9em;">
${batteryLifeYears < 1 ?
`To extend life: reduce active duty cycle, optimize sleep mode, or use larger battery` :
`Multi-year operation on a ${batteryCap < 300 ? "coin cell" : "AA battery"} - this is why Cortex-M + BLE revolutionized IoT!`}
</span>
</div>
</div>
`IoT Battery Life Calculator
IoT Battery Life Calculator
animation
iot
Try Change Active Duty Cycle (%) from 0.1 to 1.
Observe Watch Avg Current and battery life as duty cycle changes from 0.1 to 1.
Explain Explain why increasing duty cycle from 0.1 to 1 reduces battery life.
Technical boundaries. Battery life divides battery capacity by average sleep and active current. Sleep and active currents remain constant for the selected duty cycle.
IoT Battery Life Calculator
Calculate how long your IoT device will run on battery power. This demonstrates why ARM Cortex-M + BLE was revolutionary for practical IoT.
Experiment: Try legacy values (sleep current = 10 µA, duty cycle = 1%) vs. modern Cortex-M values (sleep = 0.8 µA, duty cycle = 0.1%). The difference is measured in years of battery life.