ESP32 Battery and Charger: TP4056 Setup Guide

What is an ESP32 battery and charger setup?
Battery power for an ESP32 comes down to two halves: a single Li-ion cell, and a circuit that charges it while feeding the microcontroller. The two sources behind this guide show that split from different angles.
One project is a custom IoT PCB built around an ESP32-C3-02 SoC with a TP4056 Li-ion charger IC, a USB-C connector for charging and data, and a LiPo battery connector with onboard charging circuitry [1]. The other is an ESP32-S3 project whose maker had already fabricated a PCB with TP4056 charging logic plus battery protection circuitry, and found that it does charge the battery, but it squeals when no cell is attached and it cannot feed the ESP32 from the charger while the battery is charging [0].
So an ESP32 battery and charger setup is not a single product. It is a set of decisions: which cell, which charger IC, where the protection lives, and whether the load can share the charger input. Get those decisions right and the wiring and layout get much easier.
\2Figure from the ESP32 and TP4056 LiPo charging discussion on Electronics Stack Exchange, where an ESP32-S3 project could charge its cell but not run from the charger.
What does the TP4056 actually do?
The TP4056 is the charger IC that appears in both sources. The project summary for the KLP-5e board describes it most completely [1]:
| Function | What the source says |
|---|---|
| Charging target | Single-cell Li-ion battery |
| Charging behaviour | Charges with thermal regulation |
| Current setting | Programmable charging current using an external resistor |
| End of charge | Automatic charge termination |
| Protection listed | Under-voltage lockout and trickle charging |
| Status feedback | LED indicators for charging and full |
On the same board, the TP4056 handles battery charging and protection, while the power delivered to the ESP32-C3-02 is regulated for stability [1]. In other words, the charger IC is not the thing that feeds the ESP32 directly; there is a regulated stage in between.
One detail worth noticing: in the Stack Exchange thread the designer treats charging and protection as two separate blocks. The question describes "TP4056 charging logic + battery protection circuitry," and the accepted answer talks about disconnecting the PCM (protection circuit module) from the charger [0]. If you buy or design a charger, check which of those blocks is actually on it rather than assuming the TP4056 covers everything.
\2Another figure from the same ESP32 and TP4056 charging thread; the accepted answer recommends power switch ICs for power distribution applications.
Can you charge the battery and use the ESP32 at the same time?
That was exactly the goal in the Stack Exchange thread. The asker wanted to charge the battery while running the microcontroller, and wanted the charger, not the battery, to supply current to the ESP32 during charging. They called this load distribution [0].
The accepted answer does not hand over a finished schematic. Instead it points to a category of parts: ICs designed to switch inputs to an output with very little power loss, specifically for power distribution multiplexing, described as power switch ICs for power distribution applications. The advice is to look them up on distributor sites such as Digikey or Farnell and pick one that suits your application [0].
Meanwhile, the KLP-5e README states that USB-C provides power for both charging and system operation, that the TP4056 handles charging and protection, and that the supply to the ESP32-C3-02 is regulated [1]. That describes the intent of that board, but the source does not show the switching circuitry or name a power-path part, so treat it as a design description rather than proof that any TP4056 wiring behaves the same way.
If guaranteed charge-and-run matters to your project, the power switch IC route from [0] is the starting point the sources give you, and neither source names a specific chip, resistor value, or wiring topology for it.
What is an ESP32 battery charger module?
Within these sources, the closest thing to a ready-made "module" is the power-management section of the custom KLP-5e board [1]. Its parts list is a useful checklist for judging any charger module you consider:
- USB-C connector for charging and data transfer
- LiPo battery connector with onboard charging circuitry
- TP4056 for charging and protection
- LED indicators for charge status (charging and full)
- A regulated supply to the ESP32-C3-02
- Optimised PCB traces for minimal power loss
- Thermal management for the TP4056 and other components
The same repository ships the KiCad schematic and PCB layout, firmware source for the ESP32-C3-02, datasheets for the TP4056 and other components, assembly instructions, testing procedures, and an MIT licence [1].
The sources do not review off-the-shelf modules, do not list part numbers beyond the TP4056, and give no prices. What they give you instead is a way to evaluate a module: does it charge a single cell, does it terminate the charge, does it indicate charging and full, and how is the ESP32 actually fed?
Why does my charger squeal when no battery is attached?
This is a real symptom from the Stack Exchange thread: with no battery attached, the board produced a very loud high-pitched beeping noise, even though power was still delivered. The asker noted that the noise could not be right [0].
The accepted answer is a debugging suggestion, not a diagnosis. It says a faulty component somewhere may be responsible, and proposes disconnecting the PCM (protection circuit module) from the battery charger and connecting the battery directly to the charger to see whether the noise persists, taking care not to short the battery [0].
That is a bisection step: split the circuit into charger and protection, test again, and see which half the noise follows. The source does not identify the offending component, the frequency, or the mechanism, so do not treat any specific part as the known culprit. What it does tell you is that a board that works electrically can still have a fault worth chasing before you build on it.
How do you switch between battery power and 5V only?
The same thread asks for a three-pin switch with two states: first state, do not connect the battery and only use the +5V as an output; second state, connect the battery [0].
The answer folds this into the same solution as the charge-and-run problem: an input power distribution switch may also handle this third requirement without too much fuss, but the recommendation is to solve the first two problems first [0]. No schematic, pin assignment, or part number is given in the sources for that switch.
The practical order of work implied by the accepted answer is: fix the noise, sort out how the load gets powered while charging, and only then add the selector switch. Adding a switch to a circuit with an unresolved fault just gives you one more variable when something misbehaves.
Common pitfalls when building an ESP32 battery and charger
- Assuming a charger gives you load sharing. The designer in [0] had a working TP4056 PCB that charged the battery, yet still could not run the ESP32 from the charger during charging. The switch IC advice from the accepted answer exists precisely because the charger alone does not do it.
- Chasing noise by swapping parts. Start with the PCM disconnect test from [0] before replacing components at random.
- Confusing charger and protection. Both sources treat them as related but distinct: [0] names a PCM separately, and [1] lists under-voltage lockout and trickle charging as the protection behaviours on its board.
- Ignoring thermals and layout. The KLP-5e summary calls out thermal management for the TP4056 and other components, plus optimised PCB traces for minimal power loss [1]. The TP4056 itself charges with thermal regulation [1].
- Expecting the source to pick your switch IC. [0] tells you to browse distributor sites like Digikey or Farnell and pick one that suits your application. The part selection is on you.
- Expecting numbers the sources do not contain. Neither source gives pin numbers, resistor values, charging current figures, cell capacities, runtime estimates, or prices. Neither shows a complete charge-and-run schematic. For those details, the repository in [1] points to datasheets, and the distributor route in [0] is where the switching part is chosen.
Frequently asked questions
Can I power my ESP32 from a TP4056 while the battery charges?
Not automatically. The maker in [0] had a board that charged the battery fine but still could not feed the ESP32 from the charger during charging. The accepted answer suggests power switch ICs for power distribution applications to handle that switching, but names no specific part.
What causes a high-pitched noise when no battery is attached?
The sources do not identify the cause. The accepted answer in [0] says there may be a faulty component and suggests disconnecting the PCM (protection circuit module) from the charger and connecting the battery directly to the charger to see whether the noise persists, being careful not to short the battery.
What does a TP4056 do in an ESP32 battery charger design?
It charges a single-cell Li-ion battery with thermal regulation, uses an external resistor to set the charging current, terminates the charge automatically, and drives LEDs that show charging and full [1]. The same board lists under-voltage lockout and trickle charging as battery protection.
What is an ESP32 battery charger module made of?
In the KLP-5e board, the power section combines a USB-C connector for charging and data, a LiPo battery connector with onboard charging circuitry, a TP4056 for charging and protection, charge-status LEDs, and a regulated supply to the ESP32-C3-02 [1].
How do I switch between 5V-only and battery operation?
The thread in [0] asks for a three-pin switch to do exactly that. The answer suggests an input power distribution switch may handle it, but recommends solving the noise and load-distribution issues first, and gives no wiring diagram.
For a straightforward ESP32 battery and charger build, a TP4056-based design covers charging, termination and status indication, and the KLP-5e board shows how that slots into a real ESP32-C3 design with a USB-C input and a regulated supply. The hard part is running the ESP32 while the cell charges: the sources agree that plain charger wiring does not do load distribution, and their recommended direction is a power-distribution switch IC chosen from a distributor. Budget time for that, and debug any odd noise before adding more circuitry.
Sources
electronics.stackexchange.comESP32 and TP4056 lipo charginggithub.comfutureshocked/KLP-5e-ESP32-sensor-board (GitHub README)This guide summarises the public sources listed above in our own words. Check the original documentation before relying on exact figures.


