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:

TP4065 circuit

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

Resistor to current table

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.

Example of solar panel IV

Here is the charging characteristic of the TP4065

TP4065 charging graph

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:

Other Solution

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?

  • 1
    \$\begingroup\$ 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. \$\endgroup\$ – mkeith Feb 7 '15 at 21:31
  • 1
    \$\begingroup\$ 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. \$\endgroup\$ – mkeith Feb 7 '15 at 21:35
  • \$\begingroup\$ 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. \$\endgroup\$ – mkeith Feb 7 '15 at 22:01
  • 1
    \$\begingroup\$ @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. \$\endgroup\$ – Pat Feb 7 '15 at 22:24
  • \$\begingroup\$ @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 \$\endgroup\$ – Pat Feb 7 '15 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:

revised PWM control

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!


  • 1
    \$\begingroup\$ I think I will power the Arduino directly on the solar panel so that I never run into a dead end problem. \$\endgroup\$ – Pat Feb 13 '15 at 4:36
  • \$\begingroup\$ 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 \$\endgroup\$ – Pat Feb 13 '15 at 4:38
  • \$\begingroup\$ 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. \$\endgroup\$ – mkeith Feb 13 '15 at 5:04

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

enter image description here

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


auto-charge current adjust

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.

  • \$\begingroup\$ 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? \$\endgroup\$ – Pat Feb 8 '15 at 5:17
  • 1
    \$\begingroup\$ No, but I just found this: sparkfun.com/products/12885 \$\endgroup\$ – mkeith Feb 8 '15 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.


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.

  • \$\begingroup\$ Are you sure it is linear? How could the same input voltage produce different charging current by changing a resistor? \$\endgroup\$ – Pat Dec 4 '15 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.

  • \$\begingroup\$ 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? \$\endgroup\$ – Pat Dec 4 '15 at 21:19
  • \$\begingroup\$ 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. \$\endgroup\$ – Atmega 328 Dec 5 '15 at 0:06
  • \$\begingroup\$ 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. \$\endgroup\$ – Pat Dec 5 '15 at 1:01
  • \$\begingroup\$ 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. \$\endgroup\$ – Atmega 328 Dec 5 '15 at 1:46
  • \$\begingroup\$ 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. \$\endgroup\$ – Pat Dec 5 '15 at 10:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.