The TP4056 chip is a lithium Ion battery charger for a single cell battery, protecting the cell from over and under charging. It has two status outputs indicating charging in progress, and charging complete. It also has a programmable charge current of up to 1A.

You can use it to charge batteries directly from a USB port since the working input voltage range is 4V ~ 8V.

There are two types of common breakout boards for this chip:

  • One with only the charger chip on board.
  • One with three chips on board.

Here you are looking at the 3 chip breakout board (TP4056, DW01A and 8205A dual MOSFET).

TP4056 breakour board with DW01A protection

What you can learn here:

  • How to use the TP4056 breakout board.
  • How to use the TP4056 safely.
  • How the DW01A works on the TP4056 breakout board.
  • How to set temperature limits using the TP4056 TEMP input.

Note: You need to change the current programming resistor on the breakout board to match the lithium battery you are using - the default is 1.2k which is for a 1Ah (1000mAh) battery.

Note: Follow this link to learn how to use the DW01A correctly.

Lithium batteries can be dangerous if not charged properly and that's why the TP4056 is useful as it stops over voltage and current charging by detecting specific voltage conditions.


There are a lot of circuits out there that show the use of the TP4056 as both a charger and a load driver - Not Good. If a load is attached to the battery while charging, then the TP4056 may not detect when the charge current has fallen to C/10. So it could continue charging - this could be dangerous.

You should never use the TP4056 as a charger and as a load driver at the same time. When charging the battery, switch off the load, and when loading the battery, switch off the charger. Alternatively use a PMOSFET, a resistor and a Schottky diode.

Lithium batteries can not absorb overcharge - the current must be cut off after charging. If not there could be thermal runaway.

TP4056 Features

  • Constant Current / Constant voltage charging method.
  • C/10 Charge termination.
  • 2.9V trickle charge threshold (for deeply discharged batteries).
  • Upper charge stop voltage : 4.2V.
  • Soft start inrush current limit.
  • Automatic recharge (keeps batteries optimally charged when connected to a charger).

TP4056 module Datasheet

Download the TP4056 Datasheet here.

TP4056 Specifications

  Voltage Supply (Vs)
4V0 ~ 8V0
  Charge Voltage termination (accuracy) 4.2V(1.5%)
  Supply current (Rprog=1.2k: 1A chrg)
150uA (typ)
  Supply current (Chrg ended/ shutdown) 55uA (typ)
  Ibat (Rprog=1.2k: 1A chrg ) 1050mA (max)
  Ibat (Stand by mode; Vbat = 4.2V)-6uA (max)
  Vtrckl(Rprog=1.2k: Vbat:rising) 2.9V (typ)
  Itrckl (Rprog=1.2k: Vbat<Vtrckl ) 140mA max)
  Vtrhsy(Rprog=1.2k) 80mV (typ)
  Operating temperature
-40°C ~ 85°C

            [trckl = Trickle charge, trhsy = Trickle Charge Hysteresis]

TP4056 Current Programming Resistor

The programming resistor (R3 or Rprog) is set to 1k2 which provides 1A programming charge rate or 1C. If your battery is not 1000mAh (1Ah), then you need to remove R3 and replace it with the correct one following the information in the table on the right.

TP4056 Status indicator LEDs

The table on the left shows the state of LEDs for various charging states:

tp4056 led status and rprog table

TP4056 Charger Module Schematic

This is the schematic of the popular breakout board with label 03962A this shows the TP4056 pinout for the breakout board.

TP4056 breakoutboard schematic

[ ]

When charging a battery using the above board connect the battery to B+ and B- and disconnect OUT+ and OUT- from your circuit. When using the battery disconnect the 5V input and take the output voltage from OUT+ and OUT- to your circuit.

TP4056 Connections

The following diagram shows a typical setup (from the datasheet). The block diagram also shows the TP456 pinout for the 8 pin SMD device.

Typical circuit for tp4056
Here you can see the two status LEDs (CHRGn, STDBYn), Battery connection (BAT), Current control connection (PROG) and TEMP connection. Some LI batteries have an internal thermistor that you can connect as shown above. In the breakout boards available generally TEMP is not used and connected to Ground.

TP4056 Block diagram

TP4056 block diagram
[ ]

TP4056 reverse polarity protection

The TP4056 does not give you reverse polarity protection so if you wire up the battery the wrong way round then you'll get smoke!

Actually, there is no TP4056 reverse polarity protection and the DW01A battery protection IC (on the breakout board) is being used in the wrong way (or not in the best way)! If used correctly the DW01A does provide reverse polarity protection for a battery.

Note: Follow this link to learn how to use the DW01A correctly.

DW01A Battery Protector Chip

On some breakout boards there are an extra 2 chips. One is the DW01A and the other is a dual N Channel MOSFET required by the DW01A chip.

This chip provides battery protection but it is not used in the right way on this board and so only provides short circuit protection (and over current protection). It should provide all of the following:

Charger input protection

The CS pin is connected to the negative terminal of the charger input (via a 1k⦠resistor) and performs the following functions:
  • Short Circuit detector.
  • Over current detector.
  • Charger Detector.
  • Reverse charger detection (overstress high current?).

Battery monitoring

VCC and GND are connected across the battery where two voltages are detected:

  • Overcharge Detector (battery voltage too high).
  • Overdischarge Detector (battery voltage too low).

DW01A and TP4056 breakout Board

On the breakout board, the chip is soldered to the TP4056 so this can never be connected the wrong way round at the "charger input". At the other side the DW01A does not protect from connecting the battery the wrong way round!

This chip will not activate for battery voltage level problems (unless the TP4056 fails) since the TP4056:
  • Stops discharging at voltages below 2.9V; Here trickle charge activates.
         The DW01A threshold is ~ 2.4V; So it will never activate.
  • Stops charging at voltages above 4.2V.
        The DW01A threshold is  ~ 4.3V; So it will never activate.

The only function that will operate is the overcurrent protection and short circuit protection. These will activate at around 3A when using the 8205A dual Mosfet.

TP4056 Power Sharing Problem

One problem with this circuit is that you must disconnect the load when charging. The reason is that the charging circuit detects when the charge rate falls below C/10 (Constant current charge mode near the end of the charging cycle). C is the battery capacity in mAh.

If you have a load connected to the battery then this will change the current detected so the TP4056 may never terminate the charging process.

Using 3 Components to achieve safe charging

A way around this problem is to use a switching circuit employing a P Channel MOSFET - this is sometimes called load sharing or automatic power path control. it is a controlled switch that disconnects the battery when external power is applied.

The idea is that when a power source is connected to the Battery charger chip, the PMOSFET disconnects the battery from the load. The TP4056 still charges the battery but without a load. Power to the load is supplied from the power source directly.

When the power source is disconnected, the PMOSFET is turned on connecting the load to the battery.

With this configuration the TP4056 can safely charge the battery with the load connected, as the battery is isolated from the load during external power application.

PMOSFET power Sharing

The following diagrams show how the PMOSFET is used for power sharing.

To turn ON the PMOSFET, the Gate must be negative (<VGS(th)) w.r.t the Source.
To turn OFF the PMOSFET, the Gate must higher than VGS(th) w.r.t the Source.

Note: VGS(th) is the threshold voltage of the MOSFET.

PMOSFET ON (Just the battery)

Here the gate of Q1 is low (pulled down by RPULL) and the PMOSFET is on, so current flows from the battery to the load.

charger powerpath PMOSFET on
[Source: Microchip application note AN1149]

To see what is going on here start with the battery with no external power supplied:

State of D1 No Input Power

When the battery is connected to the circuit, the parasitic diode (of Q1) is forward biased and Vbat-0.6V appears at the negative side of D1. Since the other side of D1 is pulled to ground D1 is reversed biased so no current flows through it. So it can be ignored (except for leakage current = small so ignore anyway - but some Schottky diodes may leak a lot requiring lower RPULL).

State of Q1 No Input Power

The cathode of D1 is also connected to the Source of Q1. The gate of Q1 is also pulled to Ground by Rpull. So VGS is "0 - (Vbat-0.6V)" =  -(Vbat-0.6V). Vbat is between 2.9V and 4.2V. 

As long as VGS is more negative than the Gate Threshold voltage of Q1 (VGS(TH)), Q1 is on and conducts current between the Drain and the Source.

So the Gate to Source threshold voltage of Q1 (VGS(TH)) must be better than -2.3V -(2.9-0.6) to turn Q1 on. You can select this threshold by choosing the right MOSFET (See the table below for example MOSFETs).

Note: The TP4056 will trickle charge a very deeply discharged battery where Vbat is< 2.9V until it reaches that 2.9V so you will want a threshold voltage better than -2.3V. e.g. -1.0 ~ -1.5 would be good.

Once Q1 is on the parasitic diode is bypassed and Vbat is connected to the load via the internal resistance of Q1 (RDS).

Note: RDS is an important parameter here - it's the internal resistance of the PMOSFET from Drain to source i.e. the internal resistance of the MOSFET.

As more current is drawn by the load, more voltage is dropped across RDS. So the output voltage at the load is dependent on the current drawn by the load. Lower RDS gives higher output voltage.

PMOSFET OFF (Power source connected)

charger powerpath mosfet off state
[Source: Microchip application note AN1149]

Here the gate of Q1 is high and the PMOSFET is off. so the battery is isolated from the load. The power source drives current through the Schottky diode (D1) to the load.

    VG = VIN


Conditions for the PMOSFET to be OFF are:

    The Gate is higher voltage than the Source : Vgs > VGS(TH) i.e. more positive.

Since the Gate is equal to Vin (~5V) and the diode drops 0.4V, Vgs is positive by 0.4V, therefore the MOSFET is off.

Examples of P MOSFET Selection

RDS(ON) m⦠@Vth=-2.5
VGS(th) V (max)
IDMAX (25°C)

AO3401 Alpha and Omega
On Semiconductor
Diodes Incorporated
International Reftifier
[1] (Depends on mounting)

You would probably want to avoid the higher RDS(ON) device as you loose volts when drawing more current.

Example of a Schottky Diode

MBRS130LT3: Forward voltage drop of 0.395V (max for 1A and @ 25°C).

Note: The Schottky diode will heat up when the charger is externally powered. The Power used depends on the load attached to the output - current through it and voltage drop across it.

An alternative to the Schottky diode is to use the 2nd PMOSFET in the IRF7329 above to replace the diode. This would need controlling using a microcontroller or using the status outputs of the TP4056 (see the LTC4056 datasheet - which is a different chip but provides a design reference).

How to use the TP4056 TEMP control Input

Although the TEMP input is not used on most breakout boards, it can be used to disable charging of a battery when it reaches low or high internal temperatures. This is an important safety feature when the ambient temperature is below 10°C or above 45°C.

The diagram below (from the datasheet) shows use of the TEMP input with a battery that includes a NTC (Negative Temperature Coefficient) Thermistor:

Typical circuit for tp4056
The TEMP input is used to disable charging if the internal battery temperature becomes too high or too low. It is usually grounded at the chip pin on breakout board.

Using this input in your own designs ensures safer charging but you need a battery with an internal thermistor. The TP4056 can then shut down charging if the temperature inside the battery becomes too high or too low.

Working out R1 and R2 for the TP4056

R1 and R2 are not specified in the datasheet so you have to work these out based on the thermistor specification in your specific battery. From the datasheet:

" If TEMP pinâ¬"s voltage is below 45% or above 80% of supply voltage VIN for more than 0.15S, this means that batteryâ¬"s temperature is too high or too low, charging is suspended. "
[ source TP4056 Datasheet ]

Recommended operating temperature

Battery University recommends charging only from 5°C to 45°C.

Note: Use these calculations at your own risk. Also you must use the battery manufacturer's data on the thermistor for operational use. Also other standards suggest charging at even tighter temperature limits.

Temperature Limit Design Calculations


The battery's internal NTC  thermistor reads 10k at 25°C and has a Beta value of 3950 (this is for a type MF52 thermistor).

Note: You can charge outside these temperatures ( 5°C ~ 45°C ) but with a more complex chip than the TP4056, one that reduces charge/voltage at outside these temperatures but never charge below 0°C.

    For 45°C the thermistor resistance is about 4k2.
    For   5°C the thermistor resistance is about 26k.

Warning: This is just an example calculation. Always use the battery manufacturer data sheet for the thermistor inside the battery to ensure correct operation.

If Vtemp is below 45% of the supply (hotter) or above 80% of the supply (colder), this indicates an out of temperature condition. For an NTC thermistor, its resistance falls with increased temperature.

Typical circuit for tp4056
You can see that R1 is pulled high and R2 is pulled low and and they connect to one side of RNTC. The other side of RNTC is attached to ground.

So R2 is in parallel with RNTC. This parallel resistance forms the lower half of a voltage divider with R1. As temperature increases so RNTC falls pulling the TEMP input voltage down.

The trick is to select resistors that give you the correct %output when RNTC changes resistance at specific temperatures.

It can be a bit tricky selecting the correct resistors but remember the battery will heat up as current is drawn so the most important parameter is the high temperature cut off. You want to stop charging above 45°C (low NTC thermistor value).

You can scratch your head trying to figure out algorithms for a while as there are three variables to change and with two set points to get right. But an easier way is to write a program for a brute force method.

RNTC is in parallel with R2. Therefore:

    RPARALLEL = RP = ( RNTC * R2 ) / ( RNTC + R2)

    VTEMP = Vsup * (  RPARALLEL ) / ( RPARALLEL + R1)


    VRATIO = VTEMP / Vsup = (  RPARALLEL ) / ( RPARALLEL + R1)

Using the above equations in the program and stepping through resistance values from 100 to 250e3 with 100R steps and using the following input values gives quite a few output results. This one seems quite good.

Found 4900 86200 Ratio1 0.450 Ratio2 0.803 

The closest Standard resistors (E48) are:

        (E48) R2 = 86600

        (E48) R1 = 4870

These standard values result in the following ratios:

r1 4780 r2 86600 Rntc1 4.2e3 Rntc2 26e3
Ratio1  0.4559
Ratio2  0.8071

These will stop the TP4056 charging below 5°C and above 45°C (approx).

Note: Remember to account for resistor tolerance and thermistor accuracy.

Program to calculate Ratios

This is a tcl program. You can download (the completely free) tcl language at

# Inputs  for MF52 (B=3950)
set vratio1 0.45
set vratio2 0.80
set ratio_tol1 0.01
set ratio_tol2 0.05
set Rntc_min 4.2e3
set Rntc_max 26e3

# Stepping controls
set tpPriv(step) 100 ;# Step size
set tpPriv(startR)  100  ;#Step start
set tpPriv(maxR1R2) 250e3 ;# Step end
set tpPriv(stop) 0

console show

proc get_ratio { Rntc r1 r2 } {
   set Rpara   [expr { ( 1.0* $Rntc * $r2 )/( $Rntc  + $r2)} ]
   set Vratio  [expr { ( 1.0* $Rpara      )/( $Rpara + $r1)} ]
   return $Vratio

proc within_tol {num val tol} {
   if {$num >= ($val-$tol) && $num <= ($val+$tol)} {return 1}
   return 0

proc  testTP4056Temp {Rntc1 Rntc2 Ratio1 Ratio2 tol1 tol2} {
global tpPriv
   set op {}
   set tpPriv(found) 0
   for {set r1 $tpPriv(startR)} {$r1<$tpPriv(maxR1R2)} {incr r1 $tpPriv(step)} {
   puts "$r1" ; update
       for {set r2 $tpPriv(startR)} {$r2<$tpPriv(maxR1R2)} {incr r2 $tpPriv(step)} {

          set VratioCalc1  [ get_ratio $Rntc1 $r1 $r2]

          if { [within_tol $VratioCalc1 $Ratio1 $tol1] } { ;# if this is ok check the other ratio

             set VratioCalc2 [ get_ratio $Rntc2 $r1 $r2]

             if { [within_tol $VratioCalc2 $Ratio2 $tol2] } {

                set frat1 [format "%2.3f" $VratioCalc1]
                set frat2 [format "%2.3f" $VratioCalc2]
                puts "Found $r1 $r2 Ratio1 $frat1 Ratio2 $frat2" ; update
                lappend op  "Found $r1 $r2 Ratio1 $frat1 Ratio2 $frat2\n"
                incr tpPriv(found)
          if {$tpPriv(stop)} {break}
       if {$tpPriv(stop)} {break}
   set fh [open op.txt w]
   puts $fh [ join $op ]
   close $fh

proc stop {} {set ::tpPriv(stop) 1}

pack [ button .b -text Stop -command stop ]

testTP4056Temp $Rntc_min $Rntc_max $vratio1 $vratio2 $ratio_tol1 $ratio_tol2

puts "\nFound: $tpPriv(found)\n\n"


The TP4056 is designed for charging control of a Lithium Ion/Poly battery pack that you charge at home, and take out with you, just in case you run out of charge when you are out.

Note: The DW01A only provides current limit protection. See here.

For this battery pack you attach a cable at home from the charger socket (Flat USB) to the micro USB socket of the battery pack. You then wait until it has charged and remove the charging cable. When you are out and about, you plug in the Flat USB cable to the battery pack and from there to your phone's micro-USB socket (or whatever your phone uses) to charge the phone.

Notice that you never both charge the battery pack and charge the phone from the battery pack. You always charge the phone directly from the charger socket at home and you can't charge the battery pack when you are out.

This is the exact problem the TP4056 was designed to solve and it should not both charge a battery AND power a load (phone or circuit) at the same time. That is why adding the PMOSFET, Zener, and resistor makes it safe to use.

However, I have never heard of any problems in using the breakout board as it is commonly used - as a charger and power source at the same time. But it is far safer to tack on three components as discussed in this page.

P.S. If I was designing this in a commercial setting, I would definitely add these components - Would not want to be blamed for the consequences!

New! Comments

Have your say about what you just read! Leave me a comment in the box below.

Privacy Policy | Contact | About Me

Site Map | Terms of Use

Visit our Facebook Page:

   Click Here

Recent Articles

  1. The TP4056: Lithium Ion/polymer Battery Charger IC

    Learn how to use the TP4056 properly. There's a right way, and a wrong way, to use it to safely charge Lithium Ion batteries.

    Read more

  2. How to use the MCP4728, a versatile four channel DAC with built in voltage reference.

    The MCP4728 chip is a four channel 12 bit DAC, with memory that outputs voltage that you can use for calibration, anywhere you want a fixed voltage.

    Read more

  3. Secrets of the Hitachi HD44780 LCD: How to display text and bargraphs.

    Find out how to connect the Hitachi HD44780 and use it to display text and graphics in any of your projects.

    Read more

  4. INA219: A voltage and current sensing chip using I2C

    INA219: How to use the INA210 for maximum accuracy in current and power measurements

    Read more

  5. Arduino Oversampling: How to Get More ADC Bits with No Extra Hardware!

    Arduino oversampling is a technique to increase ADC resolution by reading more samples then decimating. It really does work!

    Read more

  6. How to use the ADS1115

    A tutorial on using the ADS1115 precision 16 bit ADC for low power use.

    Read more

Readers Comments

"I wanted to thank
you so so so much
for all the information
you have provided in
your site it's


- Ranish Pottath

"This site really is
the best and my favorite.
I find here many useful
projects and tips."

- Milan


"Awesome site,
very, very easy and nice
to navigate!"

- Matt

Learn Microcontrollers

"Interested in

Sign up for The
Free 7 day guide:


"I am a newbie to PIC
and I wanted to say
 how great your
site has been for me."

- Dave


"Your site is a great
and perfect work.

- Suresh


"I couldn't find the correct
words to define
yourweb site.

Very useful, uncovered,
honest and clear.

Thanks so much for
your time and works.

- Anon

Back to Top