Electronics

Battery life calculator: how long will my project run?

Work out how long a battery will run an electronics project from its mAh, the current awake and asleep, and self-discharge, with the working shown.

To work out how long a battery will run a project, divide the battery’s usable capacity in mAh by the project’s average current in mA. The answer is in hours. A project that wakes up, does a job and goes back to sleep has a very small average current, so the same battery can last hours or months depending on how long it stays awake and how little it draws while asleep. Enter your battery and your project below, and the calculator shows the battery life, the average current and where the battery’s energy goes, with the working.

The battery life calculator needs JavaScript switched on in your browser.

The formula, and why it works

A battery’s capacity in milliamp-hours (mAh) is the current it can supply multiplied by the time it can supply it. A 2,500 mAh cell can, in theory, supply 2,500 mA for one hour, 250 mA for ten hours, or 1 mA for 2,500 hours. So the battery life in hours is the capacity divided by the current.

Battery life (hours) = usable capacity (mAh) ÷ average current (mA)

Most battery projects do not draw a steady current. A weather sensor, for example, might wake up for two seconds to take a reading and send it, then sleep for ten minutes. The calculator turns this into one average current:

  1. Share of time awake = seconds awake ÷ seconds between wake-ups.
  2. Average current = current awake × share of time awake + current asleep × share of time asleep.
  3. Add the battery’s self-discharge as an extra current (explained below), then divide the usable capacity by the total.

This works because the battery only “sees” the total charge taken out of it over time. Two seconds at 80 mA takes out the same charge as 160 seconds at 1 mA.

Worked example: a sensor on an 18650 cell

These are the calculator’s starting values: a 2,500 mAh lithium-ion cell (the capacity of the LG cell in the guide to charging lithium cells with a bench power supply), and a project that draws 80 mA for 2 seconds every 10 minutes and 20 µA while it sleeps.

  1. Share of time awake: 2 s ÷ 600 s = 0.333%.
  2. Awake, averaged over time: 80 mA × 2 ÷ 600 = 0.267 mA.
  3. Asleep, averaged over time: 0.020 mA × 598 ÷ 600 = 0.020 mA.
  4. Self-discharge at 2% a month: 2,500 mAh × 2% ÷ 730.5 hours in a month = 0.068 mA.
  5. Total drain: 0.267 + 0.020 + 0.068 = 0.355 mA.
  6. Usable capacity: 2,500 mAh × 80% = 2,000 mAh.
  7. Battery life: 2,000 mAh ÷ 0.355 mA = 5,633 hours, which is 235 days, or about 7.7 months.

For comparison, the same project left awake all the time at 80 mA would flatten the same battery in 25 hours (2,000 mAh ÷ 80 mA).

What makes the biggest difference

The calculator shows what share of the battery goes on each part, because that tells you what to change.

  • Time awake. In the example, three quarters of the battery goes on the 2 seconds awake. Waking once an hour instead of every 10 minutes stretches the life from about 7.7 months to about 20.6 months (627 days).
  • Sleep current. A board that draws 1 mA while “asleep”, for example because a power LED or a voltage regulator stays on, cuts the example from 235 days to 63 days. Sleep current is easy to overlook because it looks tiny, but it runs for almost all of the time.
  • Self-discharge. When a project draws very little, the battery’s own slow loss of charge starts to decide its life. In the hourly example, self-discharge is the biggest single loss.

Why the calculator uses 80% of the capacity

The capacity on a datasheet is measured in good conditions: a new cell, at room temperature, discharged at a set current down to a set voltage. A real project usually gets less, for three reasons:

  • Cold. Batteries deliver less at low temperatures. One engineering guide gives about 90% of the rated capacity for an 18650 lithium-ion cell at 0 °C and about 75% at −10 °C, so a project in a garden in a UK winter loses some of its capacity.
  • Age. A rechargeable cell loses capacity as it is used; the same guide gives about 80% left after 300 to 500 full cycles for an 18650 cell.
  • The cut-off voltage. Your project, or its regulator, stops working before the battery is completely flat, so the last part of the capacity is never used.

The same guide suggests a design margin of about 80% for a finished product, which is why the calculator starts there. If the project will sit outside all winter, or the battery is old, use a lower figure.

Self-discharge, and why it is a current

Every battery slowly loses charge on its own, even with nothing connected. Battery University gives about 5% in the first 24 hours for lithium-ion, then 1 to 2% a month, and about 3% a month more when the pack has a protection circuit. Non-rechargeable lithium cells lose far less, about 10% in five years.

To compare self-discharge with your project’s current, the calculator turns it into a current: the capacity × the percentage lost per month ÷ 730.5, the average number of hours in a month (365.25 days × 24 hours ÷ 12). For 2% a month on a 2,500 mAh cell, that is 0.068 mA, which is more than three times the example’s 20 µA sleep current.

How to measure your project’s current

The calculator is only as good as the currents you enter, and a project’s real currents often differ from the figures on a board’s product page.

  • Measure in series. Break the positive wire from the battery and connect a multimeter, set to measure current, across the break, so that all the current flows through the meter.
  • Measure awake and asleep separately. Use the mA range while the project is awake. For the sleep current, switch to the µA range once it is asleep: a µA range has a higher resistance, which can stop the project from waking up properly, so do not leave it on that range while the project wakes.
  • Time the awake period. Watch an LED that lights while the project works, or measure how long the current stays high. Short bursts, such as a radio sending, are often higher than the average awake current, so if the reading jumps about, use the highest steady value to be safe.

If the battery is a lithium-ion cell, charge it correctly: the guide to charging lithium cells with a bench power supply explains the voltage and current to set, when to stop and the UK fire services’ advice.

Related tools and guides

If your project lights an LED, the LED resistor calculator works out the resistor and the LED’s current, which you can then enter here as the current awake. The breadboard LED guide runs an LED from a 9 V battery and explains the maths. All of the calculators are on the Free tools page.

FAQ

How do I calculate battery life from mAh?

Divide the usable capacity in mAh by the average current in mA, and the answer is in hours. For a 2,000 mAh battery and a steady 80 mA: 2,000 ÷ 80 = 25 hours. Use about 80% of the rated capacity as the usable capacity.

How do I include sleep current in a battery life calculation?

Work out the average current: current awake × the share of time awake, plus current asleep × the share of time asleep. For 80 mA for 2 seconds in every 600, and 20 µA the rest of the time, the average is 0.267 mA + 0.020 mA = 0.287 mA.

Why does my battery run out sooner than the calculation says?

The usual reasons are a higher sleep current than expected (a power LED or regulator that stays on), awake periods that last longer than planned, cold weather, an old battery, or a project that stops working before the battery is flat. Measure the sleep current with a multimeter on its µA range first.

Sources: Applied EE, battery life estimation (formula, temperature and ageing figures, 80% design margin); Battery University, BU-802b: self-discharge. Read on 16 November 2026. Calculations by Braindumps; checked with code.

Use this calculator on your own site

You are welcome to use this calculator on your own website. Copy the code below into a Custom HTML block in WordPress, or into any web page. It needs no other files. We only ask that you keep the link to Braindumps at the bottom.

<!-- Braindumps battery life calculator: how long a battery runs a project that wakes up, works and sleeps. Self-contained: no external files. -->
<div id="bd-blc">
<style>
#bd-blc{--bd-red:#d63333;--bd-line:rgba(127,127,127,.35);--bd-soft:rgba(127,127,127,.08);font:inherit;color:inherit;max-width:760px;margin:1.5em 0}
#bd-blc *{box-sizing:border-box}
#bd-blc [hidden]{display:none!important}
#bd-blc fieldset{border:1px solid var(--bd-line);border-radius:10px;padding:14px 16px 6px;margin:0 0 14px;min-width:0}
#bd-blc legend{font-weight:700;padding:0 6px}
#bd-blc .grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(150px,1fr));gap:0 14px}
#bd-blc label{display:block;font-size:.92em;margin-bottom:10px}
#bd-blc input{width:100%;padding:9px 10px;margin-top:4px;border:1px solid var(--bd-line);border-radius:6px;font:inherit;background:transparent;color:inherit}
#bd-blc .hint{display:block;font-size:.85em;opacity:.8;margin-top:3px}
#bd-blc .result{border:2px solid var(--bd-red);border-radius:10px;padding:12px 16px;background:var(--bd-soft)}
#bd-blc .big{font-size:1.6em;font-weight:700;margin:0 0 4px}
#bd-blc table{width:100%;border-collapse:collapse;margin:8px 0 0}
#bd-blc td{padding:6px 0;border-bottom:1px solid var(--bd-line);text-align:left}
#bd-blc td:last-child{text-align:right;font-variant-numeric:tabular-nums;font-weight:700;padding-left:8px;white-space:nowrap}
#bd-blc .note{margin:10px 0 0;font-size:.92em}
#bd-blc details{margin-top:10px}
#bd-blc summary{cursor:pointer;font-weight:700}
#bd-blc pre{white-space:pre-wrap;font-size:.85em;margin:8px 0 0;background:transparent;border:0;padding:0}
</style>

<fieldset>
<legend>The battery</legend>
<div class="grid">
<label>Capacity (mAh)<input id="bd-blc-cap" type="number" min="0" step="10" value="2500" inputmode="decimal"><span class="hint">From the datasheet or label. 2.5 Ah = 2,500 mAh.</span></label>
<label>Usable share of the capacity (%)<input id="bd-blc-use" type="number" min="1" max="100" step="5" value="80" inputmode="decimal"><span class="hint">80% allows for cold, age and the cut-off voltage.</span></label>
<label>Self-discharge (% per month)<input id="bd-blc-sd" type="number" min="0" max="50" step="0.5" value="2" inputmode="decimal"><span class="hint">Li-ion cell 1 to 2%; add about 3% for a pack with a protection circuit.</span></label>
</div>
</fieldset>
<fieldset>
<legend>The project</legend>
<div class="grid">
<label>Current when awake (mA)<input id="bd-blc-ia" type="number" min="0" step="1" value="80" inputmode="decimal"></label>
<label>Awake for (seconds each time)<input id="bd-blc-ta" type="number" min="0" step="0.1" value="2" inputmode="decimal"></label>
<label>Wakes every (minutes)<input id="bd-blc-per" type="number" min="0" step="1" value="10" inputmode="decimal"><span class="hint">For a project that never sleeps, enter 1 minute here and 60 seconds as the awake time.</span></label>
<label>Current when asleep (µA)<input id="bd-blc-is" type="number" min="0" step="1" value="20" inputmode="decimal"><span class="hint">1,000 µA = 1 mA.</span></label>
</div>
</fieldset>

<div class="result" aria-live="polite">
<p class="big" id="bd-blc-big"></p>
<table><tbody>
<tr><td>Average current of the project</td><td id="bd-blc-avg"></td></tr>
<tr><td>Battery life in hours</td><td id="bd-blc-hours"></td></tr>
<tr><td>Battery life in days</td><td id="bd-blc-days"></td></tr>
<tr><td>Share of the drain while awake</td><td id="bd-blc-pa"></td></tr>
<tr><td>Share of the drain while asleep</td><td id="bd-blc-ps"></td></tr>
<tr><td>Share lost to self-discharge</td><td id="bd-blc-pd"></td></tr>
</tbody></table>
<p class="note" id="bd-blc-tip"></p>
<details><summary>Show the working</summary><pre id="bd-blc-working"></pre></details>
</div>

<p class="bd-credit" style="font-size:.85em;opacity:.75;margin:10px 0 0">Battery life calculator by <a href="https://braindumps.co.uk/battery-life-calculator/">Braindumps.co.uk</a></p>
<script>
(function () {
  "use strict";
  /* BEGIN CALC */
  var HOURS_PER_MONTH = 730.5; // 365.25 days × 24 hours ÷ 12
  // cap mAh, usePct %, sdPct % per month, ia mA, ta seconds awake, perMin minutes between wake-ups, isUa µA asleep
  function batteryLife(cap, usePct, sdPct, ia, ta, perMin, isUa) {
    var n = [cap, usePct, sdPct, ia, ta, perMin, isUa];
    for (var i = 0; i < n.length; i++) { if (!(n[i] >= 0) || !isFinite(n[i])) { return { error: "Fill in every box with a number of 0 or more." }; } }
    if (cap <= 0 || usePct <= 0) { return { error: "The capacity and the usable share must be more than 0." }; }
    var period = perMin * 60;
    if (period <= 0) { return { error: "“Wakes every” must be more than 0 minutes." }; }
    if (ta > period) { return { error: "The awake time is longer than the time between wake-ups. For a project that never sleeps, enter 1 minute and 60 seconds." }; }
    var duty = ta / period;
    var aAwake = ia * duty;                  // mA, averaged over time
    var aSleep = isUa / 1000 * (1 - duty);   // mA, averaged over time
    var aSelf = cap * sdPct / 100 / HOURS_PER_MONTH; // mA equivalent
    var avg = aAwake + aSleep;
    var total = avg + aSelf;
    if (total <= 0) { return { error: "With no current at all, the battery would last for ever. Enter the currents." }; }
    var usable = cap * Math.min(usePct, 100) / 100;
    var hours = usable / total;
    return { duty: duty, aAwake: aAwake, aSleep: aSleep, aSelf: aSelf, avg: avg, total: total, usable: usable,
      hours: hours, days: hours / 24, months: hours / HOURS_PER_MONTH, years: hours / (HOURS_PER_MONTH * 12),
      share: { awake: aAwake / total, sleep: aSleep / total, self: aSelf / total } };
  }
  /* END CALC */
  function $(id) { return document.getElementById("bd-blc-" + id); }
  function num(v, d) { return v.toLocaleString("en-GB", { minimumFractionDigits: d, maximumFractionDigits: d }); }
  function sig(v) { // readable current in mA or µA
    if (v >= 1) { return num(v, v >= 100 ? 0 : 2) + " mA"; }
    return num(v * 1000, v * 1000 >= 100 ? 0 : 1) + " µA";
  }
  function life(r) {
    if (r.hours < 48) { return num(r.hours, 1) + " hours"; }
    if (r.days < 61) { return num(r.days, 1) + " days"; }
    if (r.years < 2) { return num(r.months, 1) + " months"; }
    return num(r.years, 1) + " years";
  }
  function pct(v) { return num(v * 100, 1) + "%"; }
  var ids = ["cap", "use", "sd", "ia", "ta", "per", "is"];
  function update() {
    var v = ids.map(function (k) { return parseFloat($(k).value); });
    var r = batteryLife(v[0], v[1], v[2], v[3], v[4], v[5], v[6]);
    var cells = ["avg", "hours", "days", "pa", "ps", "pd"];
    if (r.error) {
      $("big").textContent = r.error;
      cells.forEach(function (k) { $(k).textContent = "–"; });
      $("tip").textContent = ""; $("working").textContent = "";
      return;
    }
    $("big").textContent = "About " + life(r);
    $("avg").textContent = sig(r.avg);
    $("hours").textContent = num(r.hours, 0);
    $("days").textContent = num(r.days, 1);
    $("pa").textContent = pct(r.share.awake);
    $("ps").textContent = pct(r.share.sleep);
    $("pd").textContent = pct(r.share.self);
    var big = Math.max(r.share.awake, r.share.sleep, r.share.self);
    $("tip").textContent = big === r.share.awake ? "Most of the battery goes on the time awake: wake less often, or finish the job faster." :
      big === r.share.sleep ? "Most of the battery goes on sleep current: look for a power LED, a voltage regulator or a sensor that stays on." :
      "Self-discharge is the biggest loss: the project draws so little that the battery's own losses decide its life.";
    var L = [];
    L.push("Share of time awake = " + num(v[4], 1) + " s ÷ (" + num(v[5], 1) + " min × 60) = " + num(r.duty * 100, 3) + "%");
    L.push("Awake, averaged     = " + num(v[3], 2) + " mA × " + num(r.duty, 5) + " = " + num(r.aAwake, 4) + " mA");
    L.push("Asleep, averaged    = " + num(v[6] / 1000, 4) + " mA × " + num(1 - r.duty, 5) + " = " + num(r.aSleep, 4) + " mA");
    L.push("Self-discharge      = " + num(v[0], 0) + " mAh × " + num(v[2], 1) + "% ÷ 730.5 h = " + num(r.aSelf, 4) + " mA");
    L.push("Total drain         = " + num(r.total, 4) + " mA");
    L.push("Usable capacity     = " + num(v[0], 0) + " mAh × " + num(Math.min(v[1], 100), 0) + "% = " + num(r.usable, 0) + " mAh");
    L.push("Battery life        = " + num(r.usable, 0) + " mAh ÷ " + num(r.total, 4) + " mA = " + num(r.hours, 0) + " hours (" + num(r.days, 1) + " days)");
    $("working").textContent = L.join("\n");
  }
  ids.forEach(function (k) { $(k).addEventListener("input", update); });
  update();
})();
</script>
</div>

Get new Braindumps guides by email

One email a week with new guides, the best free 3D prints, LEGO news and tools. Unsubscribe at any time.

No spam. Read our privacy policy.