Skip to content

LiPo Battery Integration

LiPo Battery Integration

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

Before starting this section, please ensure:

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%

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)

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) │ │
│ └────────────────────────────────────────┘ │
└───────────────────────────────────────────────┘

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
  1. Identify polarity: Verify JST connector orientation — the XIAO board has polarity markings
  2. Insert connector: Gently push the JST connector onto the board header. It should click into place
  3. Secure battery: Place the battery in the enclosure away from sharp edges or moving parts
  4. Avoid strain: Route the battery wires to avoid stress on the connector
// Firmware verification — battery connected correctly
void 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");
}
}
  1. Connect USB-C cable to the XIAO
  2. Observe the red charging LED
  3. A full charge cycle (0% to 100%) takes approximately:
    • 150 mAh battery: ~30 minutes
    • 350 mAh battery: ~60 minutes
    • 500 mAh battery: ~90 minutes
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;
}
  • 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)

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.

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.

  1. LiPo batteries are the optimal choice for button applications: high energy density, compact size
  2. 150-500 mAh range covers most use cases from daily to infrequent pressing
  3. JST PH 2.0mm connector is the standard for XIAO boards
  4. Safety is critical — use protected batteries and monitor voltage in firmware
  5. 80% usable capacity is a safe assumption for estimating battery life

Target Audience: Alibaba.com IoT Pre-sales Engineers
Status: ✅ Completed


Building a commercial IoT product?

We provide ESP32 ODM design-to-manufacturing services. From prototype to production — the team behind this tutorial can build it with you.

💡 Mention tutorial.imagrove.com in your Alibaba chat with us — get 10% off your custom project quote.

Talk to us →

First published attutorial.imagrove.com/project-work-order-button/03-lipo-battery-integration/Please credit Imagrove and link back to this page when quoting or republishing.

Questions or issues with this tutorial?

Sign in with GitHub to leave a comment. If a step fails for you, tell us — we verify it and update the tutorial.