# How to autoregulate a TP4056 for maximum solar power extraction

I'm using a solar panel (6V - 600mA at peak power) to charge a Li-Ion (3.7V) battery using a TP4065. The TP4065 I'm using has this configuration:

Where the value of the resistor Rprog determines the charging current.

The issue is that the current the solar panel provides is proportional to the light it received and the only way to keep extracting the maximum power from the solar panel is to adjust the load to keep to solar panel voltage around 6V which in my case is controlled by reducing the charging current.

What would be the best circuit to automatically adjust the Rprog resistor to keep the TP4056 Vcc at a constant voltage of around 6V?

Here is an example of a solar panel IV curve showing the voltage where the maximum power is extracted.

Here is the charging characteristic of the TP4065

UPDATE 13-02-2015

The voltage a the PROG pin vary between 1V to 0.2V

My project will use an Arduino micro controller. I could use the Arduino to monitor the solar panel voltage and regulate the TP4056 current with the following circuit:

Rprog and Rarduino would be 600 ohms and the 100uF capacitor and Rarduino will act as a low pass filter for the Arduino analog out that output a 3.3V 500Hz PWM signal.

When digital out is 0V, the TP4056 will see a 1.2K resistor and behave normally. As we increase the analog out voltage, the voltage at Rprog will decrease which will decrease the current in the TP4056 PROG pin and finally reduce the battery charging current.

Does this solution can work?

• Your question is in error. Modulating the charge current using RPROG will not help you charge your battery faster at all. Just set RPROG for the sunny day maximum (whatever that is). If you want to extract maximum power from the solar panel, you need to use at least one DC-DC converter, and in that case, it would probably not make sense to use a linear charger. Feb 7, 2015 at 21:31
• The battery, solar panel, and charger are all in series (except for the small quiescent current consumed by the charger). So maximizing solar panel power output is not the goal. You want to maximize current output. Hopefully you see my point now. Feb 7, 2015 at 21:35
• Take a look at this: cds.linear.com/docs/en/datasheet/3652fd.pdf The idea is that you would adjust your Vin to the maximum power point (note that maximum power point voltage does not change much with light level). It may not work with your 5V solar panel, but if you could consider getting a higher voltage panel it could work. Feb 7, 2015 at 22:01
• @mkeith It will charge faster because when the solar panel can only deliver 100mA and the charger wants 1000mA, the solar panel voltage drop to a voltage that the TP4056 can't work properly and doesn't charge at all.
– Pat
Feb 7, 2015 at 22:24
• @mkeith it would make sense to maximize the current as a priority but as you can see in the charging graph image, the current is not constant to a high value to charge the battery. So the only solution left is to control the charging current to not overload the solar panel
– Pat
Feb 7, 2015 at 22:27

I like the answer you suggested a lot. I think it is a good idea. I would suggest just a slight variation as follows:

Also, please work through the corner cases and unusual circumstances such as when the battery is dead, and arduino cannot power on. Will the charger be stuck in a zero charge current mode? Maybe a strategic pullup or pulldown somewhere, or a large resistor in parallel with RPROG and 100uF cap to insure small charge current even when PWM is off.

Great job!

McKenzie

• I think I will power the Arduino directly on the solar panel so that I never run into a dead end problem.
– Pat
Feb 13, 2015 at 4:36
• Also the maximum current the PROG pin can give is 1.2mA. The arduino analog out can give or sink 20mA so I don't think the mosfet is required
– Pat
Feb 13, 2015 at 4:38
• I am not worried about the current. The problem is that the PWM output (assuming it is totem pole) is a higher voltage than the PROG pin voltage. If you go to 100% duty cycle accidentally, it will cause current to flow into the PROG pin. Not sure what effect this would have. It could damage the chip. On the other hand, if you can configure the PWM output to be "open drain" or "open collector" then it should be fine. Feb 13, 2015 at 5:04

I have been looking at the same question lately. My solution was a bit different than yours:

By selecting D10, D11, D12 to be either OUTPUT/LOW or INPUT (High-Z, no pullup) I can vary Rprog from 16k (D10/11/12 all High-Z) down to 1050 Ohm (D10/11/12 all LOW) and via A0 monitor the charging current to find the MPP.

The funny thing is, that from all my testing, I found that the TP4056 seems to do MPPT itself, i.e. even if you set Rprog too low, Vprog seems to autoregulate itself to keep the current at MPP. So that would mean that just setting Rprog to the max current the solar panels can provide would be all that's needed.

BTW this confirms my empiric finding, having used simple TP4056 modules with my foldable solar panels without any problems for the last 2 years. (It's a bit disappointing though, since I took all the trouble constructing my Arduino MPPT just to find out that I don't really need it ...)

I would use another chip. However, if you want to use this one, you can try this circuit. Put a current mirror in place to adjust the program current. I assume that internally, the current flowing out through PROG is mirrored (with gain) to set the external charge current. So what you have here is a current source which increases current value as VCC increases. Adjust R200 to get the desired current at whatever you consider to be the minimum VCC. As VCC goes up, the charge current will go up, too.

I am too lazy to figure out a good starting point for R200. But if you can find out what is the voltage at PROG, then, from the table, you can surmise the current amplification factor and come up with a good start point for R200. I am thinking it will be like 47k-ish.

Variations on this might work even better. For example if you add a voltage reference and a comparator or some more transistors, you could actually keep the charge current pegged at the maximum until VCC fell below a certain point, then it would back off the charge current to maintain VCC at that level. But in my opinion, when you get to that level of complexity, you should just use an IC that does it all for you like the bq24210.

I am open to discuss this further. Just tag me to get my attention.

• That look great! The BQ24210 is a pretty small IC for a hobbyist project. Do you know any other bigger chip that perform similar function?
– Pat
Feb 8, 2015 at 5:17
• No, but I just found this: sparkfun.com/products/12885 Feb 8, 2015 at 7:44

I'm looking into doing exactly this. I think the capacitor on Vin helps a lot because when it is charging, it draws less current and stops drawing too much current from the photocell which is the point when the power output plummets. Once the capacitor drops below 4v, I believe the TPS4056 will disable itself until the cap is charged back up high enough. When it charges back up to 4v, it acts like a flywheel.

One other idea I'm thinking about trying, is using a photoresistor for Rprog.

• Personally, I'd go for a different more efficient IC.. Say the Texas TPS61200 (see my answer above). The TP4056 has an efficiency of only around 70% while the TPS61200 is around 90%. For solar applications, it means a lot Apr 29, 2023 at 12:06

Just to remember... this charger IC is linear. It means that if your battery is ~4V and your solar panel is ~6V you are wasting around 2V*current as heat. Even if you manage to extract the maximum from the panel, the energy loss is high. Consider using a switching regulator, or make your own (buck) with atmega, it is a simple circuit and can have an efficiency of about 90% in any load case. Have fun.

• Are you sure it is linear? How could the same input voltage produce different charging current by changing a resistor?
– Pat
Dec 4, 2015 at 21:22

is maximum solar power extraction more important or How to correctly using a TP4056 more important? if maximum solar power extraction is more important, then all your circuits and all the answers so far are incorrect. Your 6v solar panel will give you 2-4v in dimmer light situation, and you can't expect it to charge a 4.2v battery fully in these situation, so your charger will not be a maximum solar power extraction unit regardless what charging value you use.

Instead, you need a low start up pre-stage boost converter with voltage regulation at 5v. done, you don't need to worry about anything else. don't use a micro-controller for a simple charger like that, it wastes more energy than it makes in dimmer light. as a matter of fact, you should remove the TP4065 from the equation if maximum solar power extraction is the most important thing.

• Obviously my ultimate goal is to extract as much power as possible. But I also have two more goals, being cheap to build and being simple to build. What would be your recommendation to replace the TP4065?
– Pat
Dec 4, 2015 at 21:19
• cheapest will be just using a schottky diode, and best will be using a dc-dc boost converter. I recommend the CE8301. This tiny guy is awesome because its startup voltage is 0.9v. You can find one by typing 5v usb boost converter in ebay. most of these kind of boost converter use this IC. After you got it, hack it a little to get the output to 4.2v, namely by changing the feedback resistor and done.
– user83582
Dec 5, 2015 at 0:06
• Would charging with a flat 4.2V rather than with the many stages of TP4056 cause problems to the battery? Many says that the 4.2V need to be very precise and it seems the CE8301 can only be adjusted with 0.1V increments.
– Pat
Dec 5, 2015 at 1:01
• If you apply a simple 4.2v to a li-ion battery, it will go through those many stages regardless. It's how the chemical battery works, and have nothing to do with the IC. The IC is there to detect these stages and stop charging the battery when it think the battery is fully charged. Tickle charging a li-ion battery is bad in textbook, but it's totally fine in real life, especially with your solar input. last but the least, some charger will set the cut off voltage at 4.3v. It will increase the capacity and reduce the lifespan, but it's not explosive and it is safe.
– user83582
Dec 5, 2015 at 1:46
• Where would the solar panel IV curve sit when connected directly to a dc-dc boost converter? Would it maximize the power from the solar cell? I can't imagine what would the converter input impedence look like.
– Pat
Dec 5, 2015 at 10:56

You don't autoregulate a TP4056 for maximum solar power extraction. MPPT is only applicable to switching DC-DC converters (not lineal). TP 4056 is a lineal charger and input current is roughfly equal to battery charge current no matter what you do. Only thing you can to - minimize power dissipation of an TP4056 IC itself ( = minimize voltage loss on it - use 1.2 kOhms Rprog resistor - also make solar panels produce a bit more current)

The TPS61200 IC from Texas, on its datasheet has a great circuit schematic for what you're looking for here. Instead of installing a MCU, one can simply add a secondary circuit with an opamp for maximum efficiency of the solar cell.

• Miguel Tomás - Hi, Please remember the site rule which requires that when a post includes content (e.g. text, image, photo etc.) copied or adapted from elsewhere, that copied content must be correctly referenced. As a minimum, the source webpage or PDF etc. should be linked (references for books / articles should include title, author(s), publisher, edition, page numbers etc.). In order to help you, I found what I believe to be the source PDF link in this case and added it for you. For the future, please remember it's your responsibility to do that :) Thanks. Apr 28, 2023 at 14:14
• It's a datasheet that is available to everyone on Google.. Apr 28, 2023 at 16:39
• Miguel Tomás - Re: "It's a datasheet that is available to everyone on Google" That does not change the site rule on Stack Exchange. As I said, complying with that rule is a requirement here. I have confirmed with SE staff that it always applies for content copied onto SE from elsewhere. Please follow It in future. Thanks for your cooperation. Apr 28, 2023 at 16:50
• @samGibson, the site rule was already fulfilled before you started this ... go read deeper on why that site rule is there in the first place. Apr 29, 2023 at 12:04