Learning Goals 5 min
L03-46 introduced power budgeting. Now you pick batteries for the specific demands of a low-power IoT node. By the end of this lesson you will:
- Compare battery chemistries by energy density, peak current, shelf life, rechargeability, cost.
- Pick the right cell for: a 2-year sensor node, a 1-day wearable, a 5-second alarm beacon.
- Add a voltage divider on A0 to monitor battery state-of-charge from the sketch.
Warm-Up 10 min
From L03-46, you know to compute runtime = capacity / average current. Today we compare options.
The five chemistries
| Type | Voltage | Capacity | Peak A | Rechargeable | Shelf life |
|---|---|---|---|---|---|
| CR2032 coin cell | 3.0 V | 225 mAh | ~5 mA | No | 10 years |
| AA alkaline | 1.5 V | 2500 mAh | ~1.5 A peak, but sags hard | No | 10 years |
| AA NiMH (rechargeable) | 1.2 V | 2500 mAh | ~3 A | Yes (~500 cycles) | 5 years |
| 18650 Li-ion | 3.7 V | 2500–3500 mAh | ~10 A | Yes (~500 cycles) | 5 years |
| LiPo (e.g. 502535 = 500 mAh) | 3.7 V | various (200–10000 mAh) | varies by C-rate | Yes | 3 years |
For each: think about energy density (mAh per gram), peak current (peaks vs cruise), recharge cycles, leak rate.
New Concept · Pick batteries by use case 25 min
Use case 1 — 2-year sensor node (low duty cycle)
Sensor wakes every 15 minutes, samples, transmits, sleeps. Average current with proper sleep: ~30 µA.
Math: 30 µA × 8760 h × 2 years = 530 mAh consumed.
Battery options:
- AA alkaline (2500 mAh): 2 × AA in series = 3 V, but a single AA is 1.5 V — too low for a 3.3 V chip without a boost converter. Best: 2 × AA in series, runtime ~3 years.
- CR123A primary (1500 mAh, 3 V): right voltage, 5+ years runtime. Used in commercial IoT.
- LiPo + tiny solar (L04-40): infinite.
Use case 2 — 1-day wearable (high duty cycle)
Wearable with BLE + IMU + screen + button. Average current: ~30 mA.
Battery needs: 30 mA × 16 h (day of use) = 480 mAh.
Best: small LiPo (500–1000 mAh), 3.7 V — same voltage range as a phone, easy to charge via USB + TP4056 charger module.
Use case 3 — Beacon (rare, short transmits)
Sends a BLE advertising packet once every 30 s for 5 ms. Average current: ~50 µA average. Battery: CR2032 (225 mAh) → 4500 hours = 6 months. Many Bluetooth iBeacons run on CR2032.
Charging
Rechargeable cells need a smart charger. For LiPo + Li-ion, the standard is the TP4056 module — a £1 USB-C charger board that handles constant-current then constant-voltage charging safely. Don't skip; a dumb charge will set the cell on fire.
Battery monitor (voltage divider)
// Divider: battery+ -> 10k -> A0 -> 10k -> GND
// A0 sees half the battery voltage.
float readBatteryVoltage() {
int raw = analogRead(A0);
float vAtPin = raw * (3.3 / 1023.0); // assume 3.3 V VREF
return vAtPin * 2; // undo the 1:1 divider
}
void loop() {
float v = readBatteryVoltage();
Serial.print("battery "); Serial.print(v); Serial.println(" V");
if (v < 3.4) { // LiPo near-dead
digitalWrite(LOW_BATT_LED, HIGH);
}
delay(5000);
}Bigger resistors (100k + 100k) mean less current draw (33 µA at 3.3 V), but slower response. For battery monitoring, slow is fine.
Boost / buck regulators
Sometimes the battery voltage doesn't match what you need:
- 1 × AA (1.5 V) → 3.3 V: needs a boost converter.
- 2 × Li-ion (7.4 V) → 5 V: needs a buck.
- LiPo (3.7–4.2 V) → 3.3 V: tiny LDO or buck.
The cheapest hobby boost/buck modules (£1–3) are 80–90% efficient. Higher-quality TI / ADI modules reach 95%.
Worked Example · Spec a battery for the magic wand 20 min
Recall the wand from L04-36: Nano 33 BLE Sense + occasional BLE bursts + IMU sampling.
Estimate average current
- Idle (sleep): 1 mA average if you implement proper sleep.
- Inference + transmit: 30 mA for ~150 ms per gesture.
- ~6 gestures per minute typical use.
- Average: 1 mA + (30 mA × 0.15 s × 6 / 60 s) ≈ 1.45 mA.
Pick battery
Want: small, > 6 hours runtime, rechargeable, 3.7 V (matches Nano 33 BLE Sense's VBAT).
Options:
- 500 mAh LiPo (matchbox size): 500 / 1.45 ≈ 345 hours = 14 days. Way overspec.
- 200 mAh LiPo (lipstick-sized): 200 / 1.45 ≈ 138 hours = 5 days. Comfortable.
- CR2032: 225 mAh × 3 V ≈ similar energy to 200 mAh LiPo at 3.7 V. But peak current at 5 mA limits it. With a 100 µF bulk cap to handle BLE bursts, viable for ~5 days.
Pick the 200 mAh LiPo + TP4056 charger. Charge weekly via USB.
Add battery monitor
Voltage divider + A0 + low-battery LED on the wand tip. When V drops below 3.5 V, LED flashes red on every gesture.
Try It Yourself 15 min
Goal: Read your project's VBAT via a voltage divider. Print it every 5 seconds. Watch it drop slowly as the battery discharges.
Goal: Build a low-battery shutdown: when V drops below 3.3 V, save state to EEPROM and put the chip in SLEEP_FOREVER. Prevents over-discharge.
Goal: Add a TP4056 charger + LiPo + USB-C jack to your wand build. Press a button while charging to show charge state on an LED ring.
Mini-Challenge · Match battery to project 10 min
For each project, pick the battery + justify:
- L03-23 BT Car (50 mA cruise, 500 mA peak).
- L03-38 Doorbell (5 mA active, 5 µA sleep, ~10 presses/day).
- L04-12 IoT Room Monitor (continuous WiFi, ~80 mA).
Reveal
- 2S LiPo (7.4 V) for ~2 hours of driving. Or 4 × AA NiMH for moderate-budget.
- 2 × AA + boost converter → years on a single set.
- USB wall wart. Battery is wrong tool for always-on WiFi.
Recap 5 min
Battery choice = chemistry × capacity × voltage × peak current × rechargeable × cost. CR2032 for tiny low-rate beacons. AA / NiMH for years of low-rate sensing. LiPo for wearables. Always include charge management + over-discharge protection. Tomorrow we wire all of this into a complete low-power sensor node.
- Energy density
- Capacity per mass (Wh/kg). LiPo > NiMH > alkaline > coin cell.
- Self-discharge
- Capacity lost over time even with no load. Alkalines ~3%/year; NiMH ~30%/year (LSD types: 10%); LiPo ~3–5%/year.
- C-rate
- The discharge rate expressed as a multiple of capacity. 1C = full capacity in 1 hour. 10C = 1/10 of an hour.
- Peak current
- The max current a battery can supply briefly. Coin cells ~5 mA; LiPo 5–30 A.
- TP4056
- The classic cheap USB-C LiPo charger module. £1; safe for ~500 mA charge current.
- Boost / buck regulator
- DC-DC converter that steps voltage up (boost) or down (buck). Use to bridge battery voltage to chip needs.
- Battery monitor
- Voltage divider + ADC + threshold. Reports VBAT for user display or auto-shutdown.
- Over-discharge protection
- Software cutoff that stops drawing when V drops below the cell's safe limit. Required for LiPo.
Homework 5 min
- Pick a battery for one of your projects. Write the spec rationale in your notebook.
- Add a battery monitor to that project. Plot VBAT over a few hours.
- Read ahead to ARD-L04-39 (Low-Power Sensor Node).