ESP32 LiPo Battery Power: Safe Wiring Guide
In this article
This guide explains how to safely power an ESP32 development board from a single-cell LiPo battery, including the essential protection circuitry and wiring steps. You'll learn how to connect the battery, add a charge controller, and verify the setup works without damaging the board or the battery.
What You'll Need
- ESP32 development board (most common ones with a USB port)
- Single-cell LiPo battery (3.7V nominal, 4.2V fully charged)
- TP4056 charging module with protection (the one with DW01A and FS8205 chips)
- Breadboard and jumper wires (or soldering iron and wire)
- Multimeter for voltage checks
- Micro USB cable (for initial setup and charging)
Step-by-Step
- Understand the voltage requirements. The ESP32 operates at 3.3V logic, but most development boards have an onboard voltage regulator that accepts 5V from USB or a battery voltage in the range of about 3.7V to 4.2V. The regulator drops this down to 3.3V for the chip. Some boards have a dedicated battery input pin (often labeled BAT or VBAT) that connects directly to the regulator.
- Check your board's schematic. Look for the pin labeled '5V' or 'VIN' and the pin labeled '3.3V'. On most dev boards, the 5V/VIN pin is connected to the input of the voltage regulator, and it can accept a LiPo voltage. If your board has a 'BAT' pin, that is the best connection point. If you are using a bare ESP32 module (not a dev board), you will need a separate 3.3V regulator, but this guide assumes a dev board.
- Prepare the TP4056 module. The TP4056 module has two sides: one for the battery (B+ and B-) and one for the output (OUT+ and OUT-). The module also has a micro USB port for charging. If your module does not have the protection ICs (DW01A and FS8205), buy one that does—protection against over-discharge, over-charge, and short circuits is critical for LiPo safety.
- Connect the battery to the TP4056. Solder or plug the LiPo battery's positive lead to B+ and the negative lead to B-. Double-check polarity: red is positive, black is negative. If you reverse this, you will damage the protection circuit or the battery.
- Connect the TP4056 output to the ESP32. Take two jumper wires from OUT+ and OUT- on the TP4056. Connect OUT+ to the ESP32's 5V or VIN pin (or BAT if available). Connect OUT- to any GND pin on the ESP32. Do not connect the battery directly to the 3.3V pin—the onboard regulator will not be used, and you risk feeding 4.2V directly to the chip, which can destroy it.
- Verify the voltage before powering. Use a multimeter to measure the voltage between OUT+ and OUT-. It should read between 3.7V and 4.2V, depending on the battery's charge. If it reads 0V, check the connections and the battery's own protection circuit (some batteries have a separate PCB that may need a small charge to activate).
- Power on the ESP32. Connect the ESP32 to your computer via USB only if you need to upload code or monitor serial output. Otherwise, the ESP32 should power on from the battery alone. Look for the onboard LED to light up or check the serial monitor if connected.
- Charge the battery safely. When the battery is low, connect a 5V USB charger to the TP4056's micro USB port. The red LED indicates charging, and the blue LED indicates full. The TP4056 automatically stops charging at 4.2V. Never leave the battery charging unattended for long periods, and use a charger that provides 5V at 1A max.
- Test the full system. Disconnect the USB charger and run your ESP32 code from the battery. Measure the current draw with a multimeter in series to ensure it's within the battery's discharge rating (usually 1C, so a 1000mAh battery can supply 1A). If your project draws more than 1A, use a battery with a higher C rating or a larger capacity.
Common Mistakes
- Connecting the battery to the 3.3V pin. This bypasses the regulator and can fry the ESP32 chip. Always use the 5V/VIN/BAT pin.
- Using a TP4056 module without protection. The bare TP4056 only charges; it does not prevent over-discharge. Over-discharging a LiPo below 3.0V can permanently damage it or cause swelling.
- Reversing the battery polarity. Even with protection, reversing the battery on the TP4056 can blow the protection IC. Always double-check.
- Drawing too much current. The ESP32 with Wi-Fi on can draw peaks of 500mA or more. If your battery cannot supply that, the voltage will sag and cause resets.
- Ignoring the voltage drop. Some TP4056 modules have a diode that drops the output voltage by 0.3V. If your battery is at 3.7V, the output might be 3.4V, which is still enough for the ESP32 regulator, but check the specs. Use a module with a 'low dropout' or no diode if possible.
Tips
- Add a power switch between the battery and the TP4056 to avoid draining the battery when the project is off.
- Use a LiPo battery with a JST-PH connector for easy disconnection.
- Monitor the battery voltage in your code using the ESP32's ADC (analog-to-digital converter) to shut down gracefully before the battery is too low.
- If your ESP32 board has an LDO regulator with a low dropout voltage (like the AMS1117), it can accept a battery voltage down to about 3.6V, but the ESP32 may reset if the voltage drops below that during Wi-Fi transmission. Consider a buck-boost converter if you need stable 3.3V.
- For long battery life, use deep sleep mode on the ESP32. The current draw can drop to under 10µA.
Troubleshooting
- ESP32 does not power on. Check the voltage at the ESP32's 5V pin with a multimeter. If it's below 3.3V, the regulator may not work. Also check that the battery is not over-discharged (below 3.0V) – if so, the protection circuit will cut off output. Recharge the battery via the TP4056.
- ESP32 resets when Wi-Fi is enabled. This is usually a voltage drop issue. Measure the voltage at the 5V pin during a Wi-Fi transmission. If it dips below 3.6V, your battery cannot supply the current. Use a higher C-rated battery or add a large capacitor (e.g., 1000µF) across the power pins.
- Battery does not charge. Check the USB cable and charger. The TP4056 only charges at 1A max; if your charger cannot supply that, it may not charge. Also check the battery connections on B+ and B-.
- Battery gets hot. Stop using it immediately. This could indicate a short circuit or over-discharge. Disconnect everything and let it cool. If the battery is swollen, dispose of it properly.
- Voltage at OUT is 0V even with a charged battery. The protection circuit may have tripped. Connect a USB charger to the TP4056 for a few seconds to reset it.
Frequently Asked Questions
Can I use a 2S LiPo battery (7.4V) to power the ESP32?
No, not directly. The ESP32's onboard regulator typically accepts up to 5V or 6V max. A 2S battery at 8.4V will damage the regulator. You would need a buck converter to step down to 5V.
How long will my battery last?
It depends on your current draw. For example, a 2000mAh battery with an average draw of 80mA (ESP32 in deep sleep with occasional wake-ups) would last about 25 hours. For continuous Wi-Fi use (200mA), it would be around 10 hours.
Can I charge the battery while the ESP32 is running?
Yes, the TP4056 allows simultaneous charging and discharging. The load (ESP32) will draw from the battery while it charges, but the charging current is limited to 1A, so if your load draws more than that, the battery may not charge fully.
Do I need a separate voltage regulator?
Most ESP32 dev boards have a built-in regulator. If you are using a bare ESP32 module, you will need a 3.3V LDO regulator, but then you lose the ability to use a LiPo directly because the regulator needs at least 3.6V input. A buck-boost converter is better in that case.
Can I power the ESP32 from a LiPo without a TP4056?
You can, but you lose the charging and protection features. You would need to charge the battery externally with a dedicated charger and ensure you never over-discharge it. It's safer to include the TP4056.
What is the maximum battery voltage I can connect to the 5V pin?
Check your board's datasheet. Most boards use an AMS1117 regulator which has an absolute maximum input of 15V, but the recommended is below 6V. A single-cell LiPo at 4.2V is safe.