Become a subscriber (Free)

Join 29,000 other subscribers to receive subscriber sale discounts and other free resources.
:
:
Don't worry -- youre-mail address is totally secure. I promise to use it only to send you MicroZine.

TP4056


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, DWO1A and 8205A MOSFET).

TP4056 breakour board with DWO1A protection

What you can learn here:

  • How to use the TP4056 breakout board.
  • How to use the TP4056 safely.
  • How the DWO1A 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 DWO1A 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 at specific conditions.

Warning

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 can not detect when the charge current has fallen to C/10. So it carries on 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 schottkey 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

  Parameter
Value
  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 Breakout Board Schematic

TP4056 breakoutboard schematic

[ Source:www.sunrom.com/p/lithum-battery-charger-with-protection-microusb ]

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).

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
[ Source:www.tp-asic.com/res/tp-asic/pdres/201802/TP4056esop8.pdf ]

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 DWO1A battery protection IC (on the breakout board) is being used in the wrong way (or not in the best way)! If used correctly the DWO1A does provide reverse polarity protection for a battery.

DWO1A Battery Protector Chip

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

Learn more about the DWO1A Battery protector here.

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

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).

Follow this link for more details on the DWO1A operation and use.

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 DWO1A 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 DWO1A threshold is ~ 2.4V; So it will never activate.
  • Stops charging at voltages above 4.2V.
        The DWO1A 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.

Follow this link for more details on the DWO1A operation and use.

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 schottkey 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; 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 schottkey diode (D1) to the load.

    VG = VIN

    VGS = VPOWER - VD1FV

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


Device
Manufacturer
RDS(ON) mΩ @Vth=-2.5
VGS(th) V (max)
IDMAX (25°C)
(cont.)A

Pdiss
W
Package
AO3401 Alpha and Omega
Semiconductor
85
-1.3
-4
1.4
SOT23
FDN336P
On Semiconductor
270
-1.5
-5
0.5
SOT23
DMP1045U
Diodes Incorporated
45
-1.0
-4.3
0.8/1.5[1]
SOT23
IRF7329 (DUAL FET)
International Reftifier
21
-0.9
-9.2
2.0
SO-8
[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 Schottkey Diode

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

Note: The schottkey 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 accross it.

An alternative to the schottkey 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

Assumption:

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)

and

    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 Activestate.com.

# 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"


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:
To Visit Click Here


Recent Articles

  1. How to use the ADS1115

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

    Read more

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

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

    Read more

  3. DW01A Battery Protector IC

    The DW01A chip is a Lithium Ion battery protector commonly used on TP4056 boards.  Find out Exactly how it works and how to use it the correct way.

    Read more

  4. Arduino String: How to read commands from the serial port.

    For Arduino string operations you can use Object Class Strings or C style strings but which should you use? Also find out how to decode commands and control variables in your programs using strings.

    Read more

  5. A Real Time Clock design (DS1307) with a PIC microcontroller

    Real Time Clock Design (FREE): A Free and Complete RTC design using the DS1307 and a PIC micro (16F88) also re-targetable. This PIC project uses an I2C Clock chip and 7-segment display to create a fou…

    Read more

  6. How to use the ADXL345 for movement sensing and more.

    With the ADXL345 acellerometer you can detect up to 16g! You can also find out how to use it for tap detection and more.

    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

SUPERB and FANTASTIC."

- Ranish Pottath

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

- Milan

bursach<at>gmail.com<

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


- Matt
matt_tr<at>
wolf359.cjb.net


Learn Microcontrollers

"Interested in
Microcontrollers?"

Sign up for The
Free 7 day guide:

FREE GUIDE : CLICK HERE


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


- Dave

de_scott<at>bellsouth.net

"Your site is a great
and perfect work.
congratulations."


- Suresh

integratredinfosys<at>
yahoo.com

"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.
Regards."


- Anon

Back to Top

below 4