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.

Please vote for me.....

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(6/12/24v and 5A) 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 145Next »
alv0011 month ago

My solar battery generated about 18.5 V. Three parallel connected 12V 7Ah batteries.
My sketch modifications for 12V system:
if ((solar_volt> bat_volt) && (bat_volt <= 6.96 * 2))
analogWrite (PWM, 242.25); / / @ 95% duty / / Boost charging / / most of the charging done here
else if ((solar_volt> bat_volt) && (bat_volt> 6.96 * 2) && (bat_volt <= 7.2 * 2))
analogWrite (PWM, 25.5); / / 10% duty / / float charging
Battery charging voltage of 16-17V. It's too much! When working in this mode, the battery life is very limited.
I changed the sketch as follows:
if ((solar_volt> bat_volt) && (bat_volt <= 6.96 * 2))
analogWrite (PWM, 15); / / @ 5.9% duty / / Boost charging / / most of the charging done here
else if ((solar_volt> bat_volt) && (bat_volt> 6.96 * 2) && (bat_volt <= 7.2 * 2))
analogWrite (PWM, 10); / / 3.9% duty / / float charging
Now max battery charging voltage 14.5V. In this mode batteries will working live longer.
What is the battery charging voltage on your system?

ChứcN alv0012 days ago

i have system same to you. 20w solar panel, 21V Voc, 12V 5Ah battery. Can i use your code for my system

yes, of course

Could you please tell me change hardware!

Thank you in advance!

ChứcN2 days 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ứcN2 days ago

My pleasure ..

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

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

parth_bhat2 days ago


am planning to make this project. but my use for this project is really very different.

i want to power 2 net boxes 5v and 9v respectively .

and i want it running 24X7 with the 2X6v battery and one 10v solar pannel and one 5v solar pannel.

so can you please suggest me what modifications do i need to make in your project so that it can be used for this purpose.


Parth Y. Temkar

Moncer08.4 days ago

Hello! In this scheme, as the load may be a board arduino uno ??Thanx

ASCAS made it!14 days ago

Thank for the project! I finally finished my small scale solar conversion project. I removed the LCD to conserve electricity.


BTW, congrats on the home-automation contest! :D

deba168 (author)  ASCAS14 days ago


Hey its looking nice :)

volthaus23 days ago

What are you using for the load? Did you build it? I'll be starting to put this together soon with a 27v portable panel.
Thank you.

deba168 (author)  volthaus17 days ago

I used led light for load.Yes I have build it.If you made this please share pics or any modification.

if my solar panel open circuit voltage is 22v i can change a diode maybe for 25v zener diode?

deba168 (author)  richard.cornejo.31527 days ago

Yes you can use it ..It is used for over voltage protection.If the voltage is more than 25v then it will grounded.

and now, can i connect 2 145watts solar panels in the same charger?, i will put 2 zener diodes? o it will grounded?

iman28aban1 month ago

I just have read this "mini solar power energy system" very enthusiastically and as an electronic engineering student I would say it's amazing, it contributed me a lot. congratulation to you, this is a cutting edge and breaking the ice...

I'm interested in DC-DC buck and boost converters and more in designing inverters and will be very glade to help you if you want.

I hope I can give you a something in return for this step by step tutorial.

god bless you man!

deba168 (author)  iman28aban1 month ago

Thank you so much..

I want to make a arduino based pure sine wave inverter .can you help me ?

Hi deba168!

very nice, simple and clean explanation for your instructable!

I'm working on an Arduino YUN based anemometer and your instrctions are very useful!

one thing I would like to know, indeed. I use a 6V battery but I would
like to use a 22V peak voltage solar panel, since this is what I've got.

made the circuit on a breadboard and it seems to work fine but these
days the sun is not so shiny, so I'm not so sure... If I measure the
voltage on the solar panel during charge I can see 7.25V, while the
battery is 6.59V (discharged, ok!). The difference, well, across the
diode. That's ok.
So, the battery forces the panel to work at
(battery voltage + diode drop), is it right? if so, using a 22V peak
voltage solar panel shouldn't be a good idea for 6V charging because
its MaximumPowerPoint (MPP) is around 15V, so far from 6V.
So, the question: which solar panel is best fitting? the one with MPP near battery voltage?

second question: if I use, however, a higher peak voltage panel, the
only things I need to pay attention to are the maximum current flowing
and the voltage drop across the diode? is this right?

deba168 (author)  supermarioprof1 month ago

As per my knowledge I think 22 volt peak solar panel is not good for charging the 6V battery.You are right when a 22V panel is used the current delivered by it is more but the problem is that it charges the battery very quickly.Lead acid battery chemistry is not suitable for quick charging.

Another option is step down the solar panel voltage by using a voltage regulator or a buck converter.But all these involves losses in the system.So your overall efficiency will be reduced.

I request you to use a solar panel with peak voltage 10 to 12 v.

ASCAS1 month ago

Hey friend! Want to do a collaboration together of a revamped version? Recently, we bought a $90 - 150W solar panel for our grandparents. The original plan was to buy a charge controller but your brilliant tutorial inspired me to design & build one. What do you think? :D

deba168 (author)  ASCAS1 month ago

We can combine my energy meter and chargee controller together.. Instead of using a 16x 2 char LCD we can use a 20x4 char LCD for display..

ASCAS deba1681 month ago

Great idea! I'll go to the shop and buy some parts. In the meantime, I'll design a PCB for the whole controller. BTW, if I were to use a 150W - 22v solar panel, should I regulate the voltage by lowering it? Is the 22v pulse safe for the 12v?

deba168 (author)  ASCAS1 month ago

No I think it will not create any problem..

Angelo see what I am thinking for the new version lcd display :)

deba168 (author)  ASCAS1 month ago

Sure ..we can make a better version :)

BLR_RAVI2 months ago
deba..just some panel is a current controlled if we select the solar cell which can give 10%of battery ah...then we only need a comparator to stop charging once the battery is fully charged..another oscillator comparator just float is very cheap..then why so much complicated circuit??also in pwm we are just reducing the voltage ...but how we control current precisely ...?
deba168 (author)  BLR_RAVI2 months ago

what you are talking is known as on off charge controller. But in pwm charging it improves the battery life due to less stress and sulphation.In my case corrunet is not controlled precisely if you need then use a lm317 regulator after the pwm output.

deba..i am talking about the float charge...when you make pwm as 10% float ..the output voltage will be ..10/100x10 volts=1volt...then how can it float charge a 6volt battery..

Hello, I want to make AC Solar Panel. I wish to connect Solar panels to input of inverter and get 220v AC at the output to power fans or lights. Is there any way to achieve it? Please guide me.

deba168 (author)  Ravundra Pardeshi1 month ago

Yes u can connect your solar panel directly to any inverter it will work.But just keep in mind to maintain appropriate voltage range.The output of the solar panel is not a fixed voltage tarher it varies according to the sun light.

So you can use a charge controller to control the voltage.

sorry, I have forgotten to mention that I don't want to use battery anywhere.

deba168 (author)  Ravundra Pardeshi1 month ago

Though I have not tried yet, but I think if you connect the charge controller out put to the inverter instead of battery,it will work.

Thanks Deba

raveltan241 month ago

sir can you indicate what is the number of pwm? cause my aceduino has pwm1, pwm3, pwm5,pwm7,pwm9.

raveltan241 month ago

sir @deba168, i just want to ask, i try to compile and upload your code in my aceduino but there is a red text appearing when i finished the uploading of the code.. can you help with this sir??here is the image

deba168 (author)  raveltan241 month ago

There are several reason for getting the highlited error.The most common is COM port.

Go through the following link ,I think you will fix your problem.

thank you very much sir. i did it now and it runs! thank you sir

joly khan2 months ago

I am designing solar charge controller for 12V battery.Charge controller is DC-DC step up inductor less converter in which BJT switches used.This charge controller output should be fixed at 14V i.e. battery charging at constant voltage.I need assistance in this design,can you guide

deba168 (author)  joly khan1 month ago

Sorry I am not getting your question.Can you please describe in details.

Congratulations!!! for winning double contests :) and all the best for the third one :).

deba168 (author)  Tarun Upadhyaya2 months ago

Thank you tarun bhai..

1-40 of 145Next »