Interactive: Battery Life Estimator
Try Change Duty Cycle (%), then press Calculate battery life.
Observe After Calculate battery life, watch Average Power and Expected battery life.
Explain Explain why Duty Cycle (%) changes Expected battery life after Calculate battery life.
Calculate battery life
Reset
Technical boundaries. The calculation uses a fixed 3.7 voltage and averages transmit and sleep power by duty cycle. Technology suitability depends on calculated battery life.
Interactive: Battery Life Estimator
Calculate expected battery life based on power consumption and duty cycle:
viewof transmitPowerMw = Inputs. range (
[10 , 250 ],
{
label : "Transmit Power (mW)" ,
value : 50 ,
step : 10 ,
format : x => ` ${ x} mW`
}
)
viewof dutyCycle = Inputs. range (
[0.01 , 10 ],
{
label : "Duty Cycle (%)" ,
value : 1 ,
step : 0.1 ,
format : x => ` ${ x. toFixed (1 )} %`
}
)
viewof batteryCapacityMah = Inputs. select (
[1000 , 2000 , 3000 , 5000 , 10000 ],
{
label : "Battery Capacity (mAh)" ,
value : 3000 ,
format : x => ` ${ (x/ 1000 ). toFixed (0 )} Ah ( ${ x} mAh)`
}
)
viewof sleepPowerMw = Inputs. range (
[0.001 , 5 ],
{
label : "Sleep Power (mW)" ,
value : 0.05 ,
step : 0.01 ,
format : x => x < 0.1 ? ` ${ (x* 1000 ). toFixed (0 )} µW` : ` ${ x. toFixed (2 )} mW`
}
)
batteryCalculation = {
const voltage = 3.7 ; // Standard Li-ion voltage
const batteryCapacityMwh = batteryCapacityMah * voltage; // Convert to mWh
// Calculate average power consumption
const dutyCycleFraction = dutyCycle / 100 ;
const avgPowerMw = (transmitPowerMw * dutyCycleFraction) + (sleepPowerMw * (1 - dutyCycleFraction));
// Battery life in hours
const batteryLifeHours = batteryCapacityMwh / avgPowerMw;
const batteryLifeDays = batteryLifeHours / 24 ;
const batteryLifeYears = batteryLifeDays / 365 ;
// Determine technology suitability
let techRecommendation, techColor;
if (batteryLifeYears >= 10 ) {
techRecommendation = "LoRaWAN / Sigfox" ;
techColor = "#16A085" ;
} else if (batteryLifeYears >= 5 ) {
techRecommendation = "NB-IoT" ;
techColor = "#3498DB" ;
} else if (batteryLifeYears >= 1 ) {
techRecommendation = "Bluetooth LE" ;
techColor = "#E67E22" ;
} else if (batteryLifeDays >= 7 ) {
techRecommendation = "Wi-Fi (rechargeable)" ;
techColor = "#9B59B6" ;
} else {
techRecommendation = "Requires Mains Power" ;
techColor = "#E74C3C" ;
}
// Format display
let lifetimeDisplay;
if (batteryLifeYears >= 1 ) {
lifetimeDisplay = ` ${ batteryLifeYears. toFixed (1 )} years` ;
} else if (batteryLifeDays >= 1 ) {
lifetimeDisplay = ` ${ batteryLifeDays. toFixed (0 )} days` ;
} else {
lifetimeDisplay = ` ${ batteryLifeHours. toFixed (0 )} hours` ;
}
return {
avgPowerMw : avgPowerMw,
batteryLifeHours : batteryLifeHours,
batteryLifeDays : batteryLifeDays,
batteryLifeYears : batteryLifeYears,
lifetimeDisplay : lifetimeDisplay,
techRecommendation : techRecommendation,
techColor : techColor
};
}
html `
<div style="background: linear-gradient(135deg, #2C3E50 0%, #34495E 100%); padding: 24px; border-radius: 8px; color: white; margin: 20px 0;">
<h3 style="margin-top: 0; color: #16A085; font-size: 1.3em;">Battery Life Analysis</h3>
<div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-top: 16px;">
<div style="background: rgba(255,255,255,0.1); padding: 16px; border-radius: 6px; border-left: 4px solid #16A085;">
<div style="font-size: 0.85em; opacity: 0.9; margin-bottom: 4px;">Average Power</div>
<div style="font-size: 1.8em; font-weight: bold;"> ${ batteryCalculation. avgPowerMw . toFixed (2 )} mW</div>
</div>
<div style="background: rgba(255,255,255,0.1); padding: 16px; border-radius: 6px; border-left: 4px solid #E67E22;">
<div style="font-size: 0.85em; opacity: 0.9; margin-bottom: 4px;">Expected Battery Life</div>
<div style="font-size: 1.8em; font-weight: bold;"> ${ batteryCalculation. lifetimeDisplay } </div>
<div style="font-size: 0.75em; opacity: 0.8; margin-top: 4px;"> ${ batteryCalculation. batteryLifeHours . toFixed (0 )} hours total</div>
</div>
<div style="background: rgba(255,255,255,0.1); padding: 16px; border-radius: 6px; border-left: 4px solid ${ batteryCalculation. techColor } ;">
<div style="font-size: 0.85em; opacity: 0.9; margin-bottom: 4px;">Recommended Technology</div>
<div style="font-size: 1.4em; font-weight: bold; color: ${ batteryCalculation. techColor } ;"> ${ batteryCalculation. techRecommendation } </div>
</div>
</div>
<div style="margin-top: 20px; padding: 16px; background: rgba(22, 160, 133, 0.2); border-radius: 6px; border-left: 4px solid #16A085;">
<strong style="color: #16A085;">Key Insight:</strong>
${ batteryCalculation. batteryLifeYears >= 10 ? `With ${ dutyCycle. toFixed (1 )} % duty cycle and ${ transmitPowerMw} mW transmit power, you achieve ${ batteryCalculation. batteryLifeYears . toFixed (1 )} years - ideal for remote agricultural or environmental monitoring using LoRaWAN.` : batteryCalculation. batteryLifeYears >= 1 ? `Battery life of ${ batteryCalculation. lifetimeDisplay } is suitable for ${ batteryCalculation. techRecommendation } . Consider reducing duty cycle or transmit power to extend lifetime.` : `Short battery life ( ${ batteryCalculation. lifetimeDisplay } ) requires frequent recharging or mains power. Wi-Fi consumes ${ transmitPowerMw} mW at ${ dutyCycle. toFixed (1 )} % duty cycle - this is why agriculture uses LoRaWAN instead.` }
</div>
</div>
`
Back to the chapter