In my previous instructables I described the details of energy monitoring of a off grid solar system.I have also won the 123D circuits competition for that.You can see this ARDUINO ENERGY METER.

Finally I post my new version charge controller.The new version has automatic battery voltage selection for 6/12 v .Automatically charge set point according to the battery.No need to change any hardware as well as software for 6V or a 12 V system.Solar panel up to 100w/12v can be used.You can see it by clicking the following link.


In solar power system, charge controller is the heart of the system which was designed to protect the rechargeable battery .In this instructables I will explain the PWM charge controller.

In India most of the people are living in rural area where national grid transmission line is not reached till now.The existing electric grids are not capable of supplying the electricity need to those poor people.So renewable energy sources ( photo voltaic panels and wind-generators) are the best option I think. I know better about the pain of village life as I am also from that area.So I designed this DIY solar charge controller to help others as well as for my home.You can't believe, my home made solar lighting system helps a lot during the recent Cyclone Phailin.

Solar power have the advantage of being less maintenance and pollution free but their main drawbacks is high fabrication cost, low energy conversion efficiency. Since solar panels still have relatively low conversion efficiency, the overall system cost can be reduced using a efficient solar charge controller which can extract the maximum possible power from the panel .

What is a Charge Controller ?

A solar charge controller regulates the voltage and current coming from your solar panels which is placed between a solar panel and a battery .It is used to maintain the proper charging voltage on the batteries. As the input voltage from the solar panel rises, the charge controller regulates the charge to the batteries preventing any over charging.

Types of Charge controller :


2. PWM


The most basic charge controller(ON/OFF type) simply monitors the battery voltage and opens the circuit, stopping the charging, when the battery voltage rises to a certain level.

Among the 3 charge controllers MPPT have highest efficiency but it is costly and need complex circuits and algorithm.As a beginner hobbyist like me I think PWM charge controller is best for us which is treated as the first significant advance in solar battery charging.

What is PWM:

Pulse Width Modulation (PWM) is the most effective means to achieve constant voltage battery charging by adjusting the duty ratio of the switches ( MOSFET ). In PWM charge controller, the current from the solar panel tapers according to the battery’s condition and recharging needs. When a battery voltage reaches the regulation set point, the PWM algorithm slowly reduces the charging current to avoid heating and gassing of the battery, yet the charging continues to return the maximum amount of energy to the battery in the shortest time.

Advantages of PWM charge controller :

1. Higher charging efficiency

2. Longer battery life

3. Reduce battery over heating

4. Minimizes stress on the battery

5. Ability to desulfate a battery.

This charge controller can be used for :

1. Charging the batteries used in solar home system

2. Solar lantern in rural area

3. Cell phone charging

I think I have described a lot about the background of the charge controller.let starts to make the controller.

Like my earlier instructables I used ARDUINO as the micro controller which include on-chip PWM and ADC.

Remove these adsRemove these ads by Signing Up
1-40 of 240Next »

sir why does the code doesnt work with my arduino uno?can you give the code for the 12v system?thanks in advance sir

deba168 (author)  anthony.pablo223 minutes ago

It may be due to the lequid Crystal library mismatch.

See my new charge controller, it is for 12 v.

Hi I'm Building the same project but I need to use a 4 by 20 lcd display and it has to display vols, current, pwr, enrgy and temperature. Can you advice me on that? By the way can i use a small solar panel?

deba168 (author)  imran.pancrazio25 minutes ago

Hey I have made my version -2 charge controller which have same feature what you are planning.

Hi, I am trying to connect a solar inverter to the load end of the charge controller circuit that you have designed, however connecting to the positive and negative terminals does not turn on the inverter. Any advice would be appreciated!

Specifically, is there a way to have a load budgeting function, with an inverter connected to each of the mosfets instead of directly to the battery?

deba168 (author)  premal.tailor5 days ago
Yes you can implement it.You have to modify the code and load MOSFET.
Good idea :)
deba168 (author)  premal.tailor7 days ago

Sorry for the late reply.

The load terminal will only activate when it is night.If you connect the load during day it will not work.To activate through out the whole day you have to modify the code.

If you want to connect the inverter directly to the load termina,l be sure that the load MOSFET has capability to giving the peak current drawn by the inverter.

Hey could you help me with solar micro inverter means what could be the steps to make the project?

deba168 (author)  trivedichandresh47 days ago

Sorry I don't have much knowledge on micro inverter.

Still now not tried :)

nnur124 days ago

If the battery is rated at 12V, and the supply is 21-25V, won't the high supply voltage damage the battery? At 100% duty cycle, the full 21-25V goes into the battery, right? So the full 25V is going into charging the 12V rated battery, or is the supply voltage needed to reduced to 12V?

I would love an answer because I am afraid of doing it if it'll damage the battery. Thank you!

deba168 (author)  nnur17 days ago

No it will not damage your battery. When the solar panel connect to battery it pulls the solar panel voltage to battery voltage. You can try without worrying. Best of luck.

sabah_s2823 days ago

what about during discharging, will there be any problem faced?

deba168 (author)  sabah_s287 days ago

Not observed.

hi , thanks for your work, i am making similar project except that am using magnets and coils to generate power. my question is that how does the arduino sends PWM to the base of the MOSFET if it there is no power coming from the source. lets say ARDUINO will only react if its powered, it can only be powered if the switch is closed. i want to know the initial process before ardiono sends PWM?

deba168 (author)  augustine.kyei7 days ago

Arduino takes power from the battery.According to Charging algorithm when it require to generate PWM signal,it do the same.This signal trigger the base of the MOSFET so that the switch is closed and power flow from solar panel to battery.

daro198210 days ago

Hi, what is the function diode D2, close to solar panel?

deba168 (author)  daro19827 days ago

It used for over voltage protection from lightening etc.

DidikA116 days ago

may be useful for all human

deba168 (author)  DidikA116 days ago
Glad you like it.
sabs.28117 days ago

Hello Sir,

Could you please tell me how much is the output current of the solar controller?

thank you very much.

deba168 (author)  sabs.28117 days ago

The out put can be increased to 5A by changing only the diode.I have used a IN4007 diode which can take maximum 1A.

hello..sir, im using solar Voc=21v and battery 12v, i have a question based on your adc calibration and arduino wondering,

1) how do you calculate (2.43 V is eqv to 520 ADC)? is it from the equation 1023/5 = adc value/voltage measured.?..if it yes, i have used this equation but i still cant get the answer..cant you explain it...


why do we have put an increment that is <150?

for(int i=0;i<150;i++)

{ sample1+=analogRead(A0); //read the input voltage from solar panel

sample2+=analogRead(A1); // read the battery voltage


} and lastly, why do we have to divide sample1/150?

and if the sample 1 is divided, is the answer for sample 1 will pass in the equation (solar_volt=(sample1*4.673* 3.127)/1000)..



solar_volt=(sample1*4.673* 3.127)/1000;

bat_volt=(sample2*4.673* 3.127)/1000;


Pantaleon1 month ago
Hello, I am working on a solar panel, but I am not sure if I can time the charge controller such that I can determine when it should stop charging a device even when the device is not detached
deba168 (author)  Pantaleon1 month ago

The logic is written in a software.When the battery voltage reaches the charge set point ,arduino gives a command to the gate of p-mosfet to made it off.Though at the same time both the solar panel and battery connection is remain same.

crazytekkie1 month ago
Excellent job...thanks
deba168 (author)  crazytekkie1 month ago

Thank you :)

hello..sir, i'm following your tutorial about this project..i used solar panel Voc = 21v and battery 12v 7Ah, i did what you said (at below), but how about the hardware part for example: zener diode? what value of that zener should i use? and what about other hardware component?

and for the software part..which part should i change?

Voltage divider for solar panel :

Input voltage: 21V to 25V (no load)
R1: 15k ohm or 150k
R2: 2.5k ohm or 25k

Output: 3.571 which is less than 5V

Voltage divider for battery :

Input voltage: nearly 14 to 15V ( for a fully charged battery)

R1: 15k ohm or 150k
R2: 4.7k ohm or 47k
Output voltage: 3.579

deba168 (author)  amy.ruslan.11 month ago

I have made a new charge controller.It is matching with your specification.No need to change any hardware or software change.

Hey friend, I'm not an expertise, but I'm making a similar project, but using PIC 12F675 which is small and very cheap nice uC.
I would sugest you to change D1 for a schottky diode, for such low current I know the 1N5817, it has lower voltage loss in the junction, so your project will be more power efficient.
For MOSFETs I chose the IRFZ48N which has 14 miliohms RDSon (the better I had at home) and I'm looking for the IRF3205 which is 8 miliohms RDSon.

deba168 (author)  Chico da Rave1 month ago

Thank you for your valuable suggestion.

112uto092 months ago

Good Morning, could you help me to make this project with my solar panel 10W Voc= 21.40V, Isc= 0.66A and battery 12V 1.3AH/20Hr with arduino Pro Mini. Is this your design is suitable for me or any change required in hardware and software.

Your project is excellent!, Reply me soon

Thanks in Advance

deba168 (author)  112uto092 months ago

Good Morning :)

I have designed a new charge controller.

You can see it.No need to change the hardware and software.

112uto09 deba1682 months ago

Thanks for your reply.

If you use LED display in place of LCD the life of the product may be good is my opinion.

K.Lakshmi Varaprasad

deba168 (author)  Lakshmi Varaprasad2 months ago

Thanks for suggestion.I will try to implement it.

ChứcN5 months ago

HI! Could you help me for my solar system, i use 12V 5A battery, 20W solar panel. I use your schematic is ok?

Thanks in advance!

deba168 (author)  ChứcN3 months ago
deba168 (author)  ChứcN5 months ago

My pleasure ..

You have to modify both in code as well as hardware..

Go through the comments I have explained for 12V system.

eric_s_lopez8 months ago

I enjoed very much your instructable. It looks not as hard to try for someone without electronics background. I am trying to build one for a 60 watt panel powering a 12 Volt marine deep cycle battery. What will be the values of the resistors for the voltage dividers? I will appreciate very much your reponse. The panel generates about 24V in open circuit.

Best regards from Guatemala.

1-40 of 240Next »