LiPo Battery Power Management
LiPo Battery Power Management
Overview
Section titled “Overview”This section covers LiPo (Lithium Polymer) battery integration for the e-paper display project. Proper battery management is essential for achieving long-term, maintenance-free operation. After completing this section, you will be able to:
- Select appropriate LiPo batteries for ESP32 projects
- Understand LiPo battery charging and protection circuits
- Integrate battery power with ESP32 boards that have built-in battery management
- Monitor battery voltage for low-battery warnings
Prerequisites
Section titled “Prerequisites”Before starting this section, please ensure:
- Deep sleep configuration is understood (see 02-08)
- Basic understanding of lithium battery safety
- ESP32 board with battery management (recommended: XIAO ESP32-C3 or similar)
Key Concepts
Section titled “Key Concepts”LiPo Battery Basics
Section titled “LiPo Battery Basics”LiPo (Lithium Polymer) batteries are the preferred power source for portable IoT devices due to their high energy density and light weight.
Key Specifications:
| Parameter | Description | Typical Values |
|---|---|---|
| Voltage (nominal) | Average voltage during discharge | 3.7V per cell |
| Voltage (full) | Maximum voltage when fully charged | 4.2V per cell |
| Voltage (cutoff) | Minimum safe voltage | 3.0-3.2V per cell |
| Capacity | Total energy storage | 500-5000 mAh |
| C-rating | Maximum discharge current | 1C-5C |
| Connector | Physical connection type | JST-PH, Molex, wires |
Voltage vs Charge Level:
4.2V ── 100% (Full)4.0V ── 80%3.8V ── 50%3.6V ── 20%3.4V ── 5%3.0V ── 0% (Empty — disconnect immediately)Warning: Discharging below 3.0V permanently damages LiPo batteries. Use a protection circuit or voltage cutoff.
Battery Management System (BMS)
Section titled “Battery Management System (BMS)”A BMS handles:
- Overcharge protection: Stops charging at 4.2V
- Over-discharge protection: Disconnects load at ~3.0V
- Short circuit protection: Instant disconnect
- Balancing: For multi-cell batteries (not needed for single-cell)
ESP32 Boards with Built-in BMS
Section titled “ESP32 Boards with Built-in BMS”Several ESP32 boards integrate battery management, making battery operation simple:
| Board | Battery Connector | Charging IC | Max Charge Current | Notes |
|---|---|---|---|---|
| XIAO ESP32-C3 | JST-PH (2-pin) | BQ25100 | 300 mA | Ideal for this project |
| ESP32-S3-DevKitC-1 | No built-in | External needed | — | Add external module |
| M5Stack Atom | JST-PH | IP5306 | 500 mA | Built-in power management |
| TTGO T-Display | JST-PH | TP4054 | 500 mA | With display included |
XIAO ESP32-C3 Battery Features:
- Built-in battery charging via USB-C
- Automatic power source switching (USB ↔ battery)
- Battery voltage monitoring via ADC
- Low quiescent current in sleep mode
Implementation Steps
Section titled “Implementation Steps”Step 1: Select the Battery
Section titled “Step 1: Select the Battery”For the E-Paper Display Project:
Calculate required battery capacity:
# Power consumption calculationactive_current = 120 # mA (WiFi + display refresh)active_time = 10 # seconds per cyclesleep_current = 0.05 # mA (50 µA deep sleep)sleep_time = 3590 # seconds (1 hour - 10 seconds)
# Energy per cycle (mAh)active_energy = active_current * (active_time / 3600) # 120 * 0.00278 = 0.333 mAhsleep_energy = sleep_current * (sleep_time / 3600) # 0.05 * 0.9972 = 0.050 mAhtotal_per_cycle = active_energy + sleep_energy # 0.383 mAh
# Daily consumptioncycles_per_day = 24daily_consumption = total_per_cycle * cycles_per_day # 9.2 mAh
# Battery life estimationbattery_capacity = 1200 # mAh (example)days_of_operation = battery_capacity / daily_consumption # 130 daysRecommended Batteries:
| Capacity | Dimensions | ESP32 Run Time (1hr refresh) | Weight | Price |
|---|---|---|---|---|
| 500 mAh | 30×20×5 mm | ~54 days | 12g | $5-8 |
| 1200 mAh | 50×35×6 mm | ~130 days | 25g | $10-15 |
| 2000 mAh | 65×40×6 mm | ~217 days | 38g | $15-20 |
| 5000 mAh | 100×40×8 mm | ~543 days | 80g | $25-35 |
Step 2: Connect the Battery
Section titled “Step 2: Connect the Battery”For XIAO ESP32-C3:
1. Prepare the battery ┌───────────────────┐ │ LiPo Battery │ │ 3.7V / 1200 mAh │ └──────┬──────┬─────┘ │ │ Red(+) Black(-) │ │ ↓ ↓ ┌───────────────────┐ │ XIAO ESP32-C3 │ │ (JST-PH header) │ └───────────────────┘- Connect the battery JST connector to the XIAO’s battery header
- The XIAO automatically detects the battery
- When USB is connected, the device runs on USB and charges the battery
- When USB is disconnected, the device seamlessly switches to battery power
For ESP32 without BMS:
Add an external TP4056 charging module:
USB Power ─→ [TP4056 Charger] ─→ LiPo Battery │ ↓ [ESP32 Vin]Wiring:
TP4056 ESP32────── ─────OUT+ ───→ Vin (5V)OUT- ───→ GNDBAT+ ───→ LiPo +BAT- ───→ LiPo -Step 3: Monitor Battery Voltage
Section titled “Step 3: Monitor Battery Voltage”Monitor battery level to alert users before shutdown:
// Battery monitoring for XIAO ESP32-C3// The XIAO has an internal voltage divider connected to GPIO 2
#define BATTERY_PIN 2 // XIAO ESP32-C3 battery measurement pin
void setup() { Serial.begin(115200);
// Configure ADC analogReadResolution(12); // 12-bit resolution (0-4095)
// Read battery voltage int rawValue = analogRead(BATTERY_PIN);
// Convert to voltage // XIAO uses a 2:1 voltage divider float voltage = (rawValue / 4095.0) * 3.3 * 2;
Serial.print("Battery voltage: "); Serial.print(voltage); Serial.println("V");
// Estimate battery percentage int batteryPercent = mapBatteryToPercent(voltage); Serial.print("Battery: "); Serial.print(batteryPercent); Serial.println("%");
// Low battery warning if (voltage < 3.4) { Serial.println("WARNING: Low battery!"); // Show low battery indicator on display }}
int mapBatteryToPercent(float voltage) { // Approximate mapping for LiPo if (voltage >= 4.2) return 100; if (voltage >= 4.0) return 80; if (voltage >= 3.8) return 50; if (voltage >= 3.6) return 20; if (voltage >= 3.4) return 5; return 0;}Step 4: Display Battery Status on E-Paper
Section titled “Step 4: Display Battery Status on E-Paper”Add a battery indicator to the display:
void drawBatteryIcon(int x, int y, int percent) { // Battery outline display.drawRect(x, y, 30, 15, GxEPD_BLACK); display.fillRect(x + 30, y + 4, 4, 7, GxEPD_BLACK); // Terminal
// Fill level int fillWidth = map(percent, 0, 100, 0, 28); if (fillWidth > 0) { display.fillRect(x + 1, y + 1, fillWidth, 13, GxEPD_BLACK); }
// Low battery indicator if (percent < 10) { display.setFont(&FreeMono9pt7b); display.setCursor(x, y + 25); display.print("LOW BAT"); }}
// Usage in display updatedrawBatteryIcon(210, 5, batteryPercent);Step 5: Charging Circuit Protection
Section titled “Step 5: Charging Circuit Protection”Safety Recommendations:
- ✅ Always use a protected battery — Batteries with built-in protection IC
- ✅ Charge in a fire-safe area — Never leave charging batteries unattended
- ✅ Use the correct charger — LiPo-specific charger with CC/CV profile
- ❌ Never puncture or short-circuit LiPo batteries
- ❌ Don’t charge below 0°C — Permanently damages the battery
- ❌ Don’t store fully charged for extended periods — Store at 3.7-3.8V (50-60%)
Verification
Section titled “Verification”- Device powers on from battery alone (USB disconnected)
- Device charges when USB is connected
- Battery voltage reading is within expected range (3.3V-4.2V)
- Low battery warning appears on display when voltage drops
- Device runs for at least 24 hours on battery
Troubleshooting
Section titled “Troubleshooting”Issue 1: Device Doesn’t Power On Battery
Section titled “Issue 1: Device Doesn’t Power On Battery”Symptoms:
- Device works on USB but not battery
Solutions:
- Check battery voltage with multimeter (>3.3V required)
- Verify JST connector polarity (red = positive, black = negative)
- Check if battery protection circuit has tripped (try charging for 10 minutes)
Issue 2: Battery Runs Out Quickly
Section titled “Issue 2: Battery Runs Out Quickly”Symptoms:
- Battery lasts less than expected
- Device draws >100 µA in sleep
Solutions:
- Verify deep sleep is actually active (measure current)
- Check for GPIO pull-up resistors draining power
- Disconnect external components during sleep
// Disable all peripherals before sleepdigitalWrite(EPD_CS, HIGH); // Deselect displaypinMode(EPD_RST, INPUT); // High-impedancepinMode(EPD_DC, INPUT);Issue 3: Battery Voltage Reading Inaccurate
Section titled “Issue 3: Battery Voltage Reading Inaccurate”Symptoms:
- Voltage reading is 0V or 4.2V constantly
Solutions:
- Check ADC pin configuration
- Calibrate ADC with known voltage
- Add averaging filter
// Averaged battery readingfloat readBatteryAverage() { int total = 0; for (int i = 0; i < 10; i++) { total += analogRead(BATTERY_PIN); delay(10); } float avg = (total / 10.0) / 4095.0 * 3.3 * 2; return avg;}Best Practices
Section titled “Best Practices”- ✅ Choose a battery with built-in protection IC — Prevents over-discharge
- ✅ Use JST-PH connectors — Standard for LiPo batteries
- ✅ Monitor battery voltage — Show status on the display
- ❌ Don’t mix battery chemistries — Stick to 3.7V LiPo
- ❌ Avoid batteries without protection — Risk of permanent damage
- ❌ Don’t draw more than 1C — Battery may overheat
Summary
Section titled “Summary”- LiPo batteries (3.7V) are ideal for portable ESP32 e-paper projects
- Boards with built-in BMS (like XIAO ESP32-C3) simplify battery integration
- Battery capacity selection depends on the wake interval and active power consumption
- Voltage monitoring provides low-battery warnings and prevents data loss
- Proper charging and handling is critical for LiPo safety
- With a 1200 mAh battery and 1-hour sleep interval, operation for ~130 days is achievable
References
Section titled “References”- LiPo Battery Safety Guide
- TP4056 Charging Module Datasheet
- XIAO ESP32-C3 Battery Management
- ESP32 ADC Calibration
Target Audience: Alibaba.com IoT Pre-sales Engineers
Status: ✅ Completed