What is the TP4056?
The TP4056 module is the standard way to add rechargeable power to a project. Plug in a 5 V USB cable, connect a single 3.7 V lithium-ion cell (an 18650 or a LiPo pouch), and it charges the cell safely to 4.2 V at up to 1 A, then stops. The red LED shows charging, the blue or green LED shows full.
There are two versions and the difference matters. The basic board has only the TP4056 charger chip. The more common protected board adds a DW01A protection chip and an FS8205A dual MOSFET that disconnect the battery if it is over-discharged, over-charged or shorted. This page explains both, how the charge cycle works, how to change the charge current for small batteries, and how to power an Arduino or ESP32 from the cell.
Specifications
- Charger chip
- TP4056 linear Li-ion charger (NanJing Top Power)
- Input voltage
- 4.5–5.5 V (USB 5 V); absolute maximum 8 V
- Charge voltage
- 4.2 V ±1.5 %
- Charge current
- 1 A with the stock R3 = 1.2 kΩ; adjustable to about 130 mA
- Charge method
- Trickle below 2.9 V, then constant current, then constant voltage
- Charge termination
- When current falls to 1/10 of the set value (about 100 mA)
- Over-discharge cut-off
- about 2.4–2.5 V (DW01A, protected boards only)
- Over-charge cut-off
- about 4.3 V (DW01A)
- Over-current trip
- about 3 A load (DW01A + FS8205A)
- Input connector
- Micro-USB or USB-C, plus IN+/IN− pads
- Board size
- about 26 × 17 mm
Charger figures from the TP4056 datasheet; protection thresholds from the DW01A datasheet. Exact values vary slightly between module makers.
TP4056 module pinout
| Pad | Connect to | Notes |
|---|---|---|
| IN+ | 5 V input | Same as the USB connector; use one or the other |
| IN− | Input ground | Shared with B− and OUT− |
| B+ | Battery + | Directly to the cell's positive terminal |
| B− | Battery − | Through the protection MOSFETs on the protected board |
| OUT+ | Load + | Same node as B+; feed your boost converter or regulator |
| OUT− | Load − | Protected negative: switched off when the cell is empty or shorted |
Wiring & code
Setting up TP4056 with Arduino Uno
Library
None needed by Arduino core
No library required: the battery meter uses analogRead(), which is built into Arduino.
This guide runs an Arduino Uno from a rechargeable 18650 cell. The TP4056 charges the cell from USB, an MT3608 boost converter lifts the cell's 3.3–4.2 V to a steady 5 V, and the Uno reads its own battery level on A0. The same wiring works for a Nano or Pro Mini (5 V). Read the TP4056 overview for what each pad does.
Parts
Arduino Uno (or Nano)
- Qty
- 1
- Notes
- 5 V board
TP4056 module, protected version
- Qty
- 1
- Notes
- Six pads: IN, B and OUT
MT3608 boost converter
- Qty
- 1
- Notes
- Set to 5.0 V before connecting the Uno
18650 cell with holder
- Qty
- 1
- Notes
- Use a genuine cell, 2000 mAh or more
10 kΩ resistor
- Qty
- 1
- Notes
- Series resistor for the A0 battery input
Multimeter
- Qty
- 1
- Notes
- To set the boost output
Warning
Set the MT3608 first. New boost modules often ship set to 9–12 V, which destroys an Uno on its 5V pin. Connect the battery, measure the MT3608 output, and turn its trimmer until it reads 5.0 V before the Uno is connected. Full steps are in the MT3608 guide.
Wiring
Wiring: TP4056, MT3608 and Arduino Uno
| From | To | Note |
|---|---|---|
| 18650 + | TP4056 B+ | Battery positive |
| 18650 − | TP4056 B− | Battery negative |
| TP4056 OUT+ | MT3608 VIN+ | Protected battery output |
| TP4056 OUT− | MT3608 VIN− | Protected ground |
| MT3608 VOUT+ | Uno 5V | Exactly 5.0 V, set beforehand |
| MT3608 VOUT− | Uno GND | Common ground |
| TP4056 OUT+ | 10 kΩ → Uno A0 | Battery voltage for the meter |
Tip
Unplug the battery supply before connecting the Uno's own USB for uploading. Feeding the 5V pin while the USB cable is also connected puts two 5 V sources in parallel. Charging through the TP4056's USB port is fine at any time.
Battery meter sketch
The cell's voltage (at most 4.2 V) is below the Uno's 5 V reference, so A0 can read it without a divider; the 10 kΩ resistor only limits current if something goes wrong. The sketch averages 20 readings, converts them to volts and estimates the charge from a typical 18650 discharge curve.
// Battery meter: 18650 via TP4056 OUT+ -> 10k -> A0, Uno powered at 5.0 V
const int BATTERY_PIN = A0;
const float VREF = 5.00; // measure the Uno's 5V pin and put the real value here
// Typical 18650 resting voltage vs remaining charge
const float VOLTS[] = {4.20, 4.05, 3.95, 3.85, 3.78, 3.72, 3.65, 3.50, 3.30};
const int PERCENT[] = { 100, 85, 70, 55, 40, 30, 20, 5, 0};
float readBattery() {
long sum = 0;
for (int i = 0; i < 20; i++) { sum += analogRead(BATTERY_PIN); delay(2); }
return (sum / 20.0) * VREF / 1023.0;
}
int toPercent(float v) {
if (v >= VOLTS[0]) return 100;
for (int i = 1; i < 9; i++) {
if (v >= VOLTS[i]) {
// straight line between the two nearest points
float f = (v - VOLTS[i]) / (VOLTS[i - 1] - VOLTS[i]);
return PERCENT[i] + f * (PERCENT[i - 1] - PERCENT[i]);
}
}
return 0;
}
void setup() {
Serial.begin(9600);
}
void loop() {
float v = readBattery();
Serial.print("Battery: ");
Serial.print(v, 2);
Serial.print(" V ~");
Serial.print(toPercent(v));
Serial.println(" %");
if (v < 3.4) Serial.println("Low battery - plug in USB to charge");
delay(5000);
}The percentage is an estimate: a cell's voltage drops under load and rises while charging, so read it with the project idle for the most stable value. For accuracy, measure the Uno's 5V pin with a multimeter and enter that value as VREF.
How long will it run?
An Uno draws about 45–50 mA on its own, and the boost converter loses about 15 %. From a 2000 mAh cell that gives roughly 30–35 hours. Add a display, LEDs or a servo and it drops quickly. For projects that must last weeks, use a Pro Mini or ESP32 with deep sleep, which can sleep at microamps.
Troubleshooting
Uno doesn't start
- Likely cause
- MT3608 output not 5 V, or the boost isn't on OUT
- Fix
- Measure VOUT; check OUT+/OUT− go to VIN+/VIN−
Uno resets under load
- Likely cause
- Weak cell or long, thin wires
- Fix
- Use a good 18650 and short wires; add 100 µF at the Uno's 5V pin
Battery reading too high or too low
- Likely cause
- VREF not the real 5 V value
- Fix
- Measure the 5V pin and set VREF
Reads about 0 V
- Likely cause
- A0 wired to OUT− or B−
- Fix
- Connect the 10 kΩ to OUT+








