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.

ParameterTypical ValueNotes
Nominal voltage3.7VAverage voltage during discharge
Full charge voltage4.2V (±0.05V)Voltage when charging completes
Discharge cutoff3.0V - 3.3VBelow this, battery may be damaged
Storage voltage3.7V - 3.85VFor long-term storage
Operating temperature0°C to 60°CReduced performance at extremes
Self-discharge rate~5% per monthAt room temperature
Cycle life300-500 cyclesUntil capacity drops to 80%

For IoT button applications, the most common capacities are:

CapacityDimensions (approx)WeightTypical Button Presses
150 mAh25 × 12 × 5 mm~5 g~1,500 (at 60mA / 20s each)
300 mAh30 × 20 × 5 mm~8 g~3,000
500 mAh35 × 25 × 5 mm~12 g~5,000
1000 mAh50 × 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:

ConnectorPitchTypical UseNotes
JST PH 2.0mm2.0mmXIAO seriesStandard on Seeed batteries
JST SH 1.0mm1.0mmSmaller connectorsLess 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:

ModelCapacitySizeWeightSupplier
Seeed 303060500 mAh30×30×6 mm14 gSeeed Studio
AIKADO 401230150 mAh25×12×5 mm5 gVarious
Adafruit 258350 mAh35×20×6 mm9 gAdafruit
Generic 502030300 mAh25×20×5 mm8 gVarious
  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 FeatureThresholdAction
Over-discharge< 2.5VDisconnects battery
Over-current> 2-3ADisconnects load
Short-circuitInstantImmediate disconnect
Over-charge> 4.25VDisconnects 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 Pattern150 mAh300 mAh500 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