LiPo Battery Integration
LiPo Battery Integration
Overview
Section titled “Overview”This section covers the selection, connection, and safe operation of LiPo batteries with the ESP32-XIAO for IoT button applications. By the end of this section, you will be able to:
- Select the appropriate LiPo battery capacity for button applications
- Connect and secure LiPo batteries with the XIAO board
- Understand battery safety considerations
- Estimate battery requirements based on usage patterns
Prerequisites
Section titled “Prerequisites”Before starting this section, please ensure:
- Completed 04-01. ESP32-XIAO Hardware Overview
- Completed 04-02. Battery Management System
- Basic understanding of battery capacity (mAh) terminology
Key Concepts
Section titled “Key Concepts”LiPo Battery Characteristics
Section titled “LiPo Battery Characteristics”LiPo (Lithium Polymer) batteries are the standard choice for IoT button applications due to their high energy density and flexible form factors.
| Parameter | Typical Value | Notes |
|---|---|---|
| Nominal voltage | 3.7V | Average voltage during discharge |
| Full charge voltage | 4.2V (±0.05V) | Voltage when charging completes |
| Discharge cutoff | 3.0V - 3.3V | Below this, battery may be damaged |
| Storage voltage | 3.7V - 3.85V | For long-term storage |
| Operating temperature | 0°C to 60°C | Reduced performance at extremes |
| Self-discharge rate | ~5% per month | At room temperature |
| Cycle life | 300-500 cycles | Until capacity drops to 80% |
Battery Capacity Selection
Section titled “Battery Capacity Selection”For IoT button applications, the most common capacities are:
| Capacity | Dimensions (approx) | Weight | Typical Button Presses |
|---|---|---|---|
| 150 mAh | 25 × 12 × 5 mm | ~5 g | ~1,500 (at 60mA / 20s each) |
| 300 mAh | 30 × 20 × 5 mm | ~8 g | ~3,000 |
| 500 mAh | 35 × 25 × 5 mm | ~12 g | ~5,000 |
| 1000 mAh | 50 × 30 × 5 mm | ~20 g | ~10,000 |
Selection guidance:
Battery capacity (mAh) = Daily energy consumption (mAh/day) × Desired days between charges ÷ 0.8 (80% usable capacity)Example: For a button used 2 times/day with 20s active time per press:
- Daily consumption = 2 × (60mA × 20s / 3600) + (24h - 40s) × 0.005mA ≈ 0.67 mAh + 0.12 mAh ≈ 0.79 mAh
- For 100 days: 0.79 × 100 / 0.8 ≈ 99 mAh
- Selected: 150 mAh battery (smallest commonly available size)
Connector Types
Section titled “Connector Types”LiPo batteries for the XIAO use JST connectors. Two common variants:
| Connector | Pitch | Typical Use | Notes |
|---|---|---|---|
| JST PH 2.0mm | 2.0mm | XIAO series | Standard on Seeed batteries |
| JST SH 1.0mm | 1.0mm | Smaller connectors | Less common, verify compatibility |
The XIAO uses a 2-pin JST PH (2.0mm pitch) connector. When sourcing batteries:
- Ensure the connector matches (JST PH 2.0mm, 2-pin)
- Polarity is typically: Red (+) on the left, Black (-) on the right when looking at the connector’s locking tab
┌───────────────────────────────────────────────┐│ XIAO Backside ││ ││ ┌────────────────────────┐ ││ │ │ ││ │ JST PH 2.0mm │ ││ │ Connector │ ││ │ [Red] [Black] │ ││ │ (+) (-) │ ││ └────────────────────────┘ ││ ││ ┌────────────────────────────────────────┐ ││ │ Battery (LiPo 3.7V) │ ││ └────────────────────────────────────────┘ │└───────────────────────────────────────────────┘Implementation Steps
Section titled “Implementation Steps”Step 1: Select the Battery
Section titled “Step 1: Select the Battery”For the work order button project, the recommended specifications are:
Minimum Requirements:- Chemistry: LiPo (Lithium Polymer)- Nominal Voltage: 3.7V- Capacity: 150-500 mAh (depending on usage frequency)- Connector: JST PH 2.0mm, 2-pin- Protection: Built-in protection circuit (recommended)Recommended batteries:
| Model | Capacity | Size | Weight | Supplier |
|---|---|---|---|---|
| Seeed 303060 | 500 mAh | 30×30×6 mm | 14 g | Seeed Studio |
| AIKADO 401230 | 150 mAh | 25×12×5 mm | 5 g | Various |
| Adafruit 258 | 350 mAh | 35×20×6 mm | 9 g | Adafruit |
| Generic 502030 | 300 mAh | 25×20×5 mm | 8 g | Various |
Step 2: Connect the Battery
Section titled “Step 2: Connect the Battery”- Identify polarity: Verify JST connector orientation — the XIAO board has polarity markings
- Insert connector: Gently push the JST connector onto the board header. It should click into place
- Secure battery: Place the battery in the enclosure away from sharp edges or moving parts
- Avoid strain: Route the battery wires to avoid stress on the connector
// Firmware verification — battery connected correctlyvoid setup() { Serial.begin(115200); pinMode(BATTERY_ADC_PIN, INPUT);
float voltage = analogRead(BATTERY_ADC_PIN) / 4095.0 * 3.3 * 2;
if (voltage > 0.5) { Serial.println("Battery detected"); Serial.print("Voltage: "); Serial.print(voltage); Serial.println("V"); } else { Serial.println("No battery detected - check connection"); }}Step 3: Charge the Battery
Section titled “Step 3: Charge the Battery”- Connect USB-C cable to the XIAO
- Observe the red charging LED
- A full charge cycle (0% to 100%) takes approximately:
- 150 mAh battery: ~30 minutes
- 350 mAh battery: ~60 minutes
- 500 mAh battery: ~90 minutes
Step 4: Monitor Battery Level in Firmware
Section titled “Step 4: Monitor Battery Level in Firmware”float getBatteryPercentage() { float voltage = readBatteryVoltage();
// Simple linear approximation for LiPo // 4.2V = 100%, 3.3V = 0% float percentage = (voltage - 3.3) / (4.2 - 3.3) * 100.0;
// Clamp to valid range if (percentage > 100.0) percentage = 100.0; if (percentage < 0.0) percentage = 0.0;
return percentage;}Battery Safety
Section titled “Battery Safety”Safe Handling Guidelines
Section titled “Safe Handling Guidelines”- Never short-circuit LiPo terminals — this causes rapid discharge and fire risk
- Do not puncture or physically damage the battery casing
- Charge only in a fire-resistant container or on a non-flammable surface
- Discontinue use if the battery shows swelling, deformation, or odor
- Store at 3.7-3.85V for long-term storage (partial charge is safest)
Protection Circuits
Section titled “Protection Circuits”Many LiPo batteries include a PCM (Protection Circuit Module):
| Protection Feature | Threshold | Action |
|---|---|---|
| Over-discharge | < 2.5V | Disconnects battery |
| Over-current | > 2-3A | Disconnects load |
| Short-circuit | Instant | Immediate disconnect |
| Over-charge | > 4.25V | Disconnects charger |
Important: The XIAO’s TP4054 charger also provides over-charge protection. Having both is redundant but provides additional safety.
Battery Life Estimation
Section titled “Battery Life Estimation”For quick estimation during buyer consultations:
| Usage Pattern | 150 mAh | 300 mAh | 500 mAh |
|---|---|---|---|
| 1 press/day | ~200 days | ~400 days | ~650 days |
| 5 presses/day | ~100 days | ~200 days | ~300 days |
| 20 presses/day | ~30 days | ~60 days | ~100 days |
| 50 presses/day | ~12 days | ~25 days | ~40 days |
Note: These estimates assume deep sleep (~5 µA), 20-second active time per press, and 80% usable capacity.
Summary
Section titled “Summary”- LiPo batteries are the optimal choice for button applications: high energy density, compact size
- 150-500 mAh range covers most use cases from daily to infrequent pressing
- JST PH 2.0mm connector is the standard for XIAO boards
- Safety is critical — use protected batteries and monitor voltage in firmware
- 80% usable capacity is a safe assumption for estimating battery life
References
Section titled “References”Target Audience: Alibaba.com IoT Pre-sales Engineers
Status: ✅ Completed