Introduction: Arduino Powered Solar Battery Charger

Picture of Arduino Powered Solar Battery Charger

The following design is for a Solar battery charger ran by an Arduino Nano. It can handle a standard lead acid 12V battery, like for a scooter or a car. Furthermore the design has been tested and runs with 90% efficiency under 70ᵒC (158ᵒF). It can take up to 20V on the input site of the charger. Also in order to improve the efficiency a MPPT tracker is implemented in the code to ensure that the maximum power of the panel is being used.

Step 1: Basic Principle of Operation

Picture of Basic Principle of Operation

The basic operation of our selected circuit can be represented by the block diagram. The design consists of a buck converter regulated by the Arduino that measures voltage and current in the system and the voltage of the battery. Based on the measurements the Arduino controls the duty cycle with which the buck converter is driven and so it calculates the current output to the battery.

Step 2: Circuit

Picture of Circuit

Circuit (intro)

The indication is done by 4 LEDs as visible on the circuit schematics. Also there is a reset button pulled onto the front board for easy access, if the code gets stuck. This button was very useful during initial testing.

Also in this build for the current measurement an AD8212 current sensing OP-AMP is used. This device proved to be unreliable for the application and is recommended to be replaced with an ACS712 breakout board.

Description of circuit operation (refer to Charger circuit V1.pdf)

Q2 is the main switching MOSFET for the buck converter and Q3 is the synchronous switching MOSFET. The MOSFET are driven by U2 which is an IR2104 MOSFET driver. The IR2104 takes the PWM signal (Digital_pin_9) from the Arduino input on pin 2 and uses it to drive the switching MOSFETs. The IR2104 can also be shut down with setting pin 3 to low. Since Q2 is an NFET it needs a gate drive voltage that is 10V higher than the source voltage which is the solar input. So the IR2104 uses a charge pump circuit made of D2 and C6 to boost the gate drive voltage to turn on the high side MOSFET. D3 is a fast switching diode that should start conducting before Q3 and in that way increase the efficiency (Increase of 1-2%).

Q1 keeps the battery from being discharged at night. Q1 turns on when Q2 is on from voltage through D1. R4 drains the voltage off the gate of Q1 so it turns off when Q2 turns off.

L1 is the main inductor that smooth’s the switching current and along with C8 smooth’s the output voltage.

In order to measure the battery and solar panel voltages R2, R3, C1 and R6, R7, C9 are set as voltage dividers. In this case the capacitors C1 and C9 smooth any pulses in the signal and give a clean measurement to the ADC. C4 is the input filter capacitor that smooth’s any input current pulses.

In order to read the current in the system there is an Rshunt resistor. The voltage drop across is amplified 100 times by U1 and fed to the ADC of the Arduino.

The 3 LEDs are connected to the digital pins of the microcontroller and serve as an output interface to display the charging state.

Charging Data Serial Monitor

The current code is designed so it can display the data on to the Arduinon serial monitor. It will display the input voltage of the panel the current voltage of the battery and the Current that the charger is currently drawing.

In V2 a I2C 16x2 line display is added to display the data.

Parts list

The parts list for the entire circuit with the designators is contained within the "Parts list V1" file.

For the micro controller any arduino running on the AtMega168/AtMega328/32u4 (Arduion Uno, Nano, Micro) can be used, as long as it runs on a 5V logic level and at at least 16Mhz. An Arduino Mega can be used however the core for the timer will need to be rewritten so the MOSFETs in the circuit run at 10khz frequency.

All of the components can be ordered from Farnell / RS online / or your favorite hobby shop. Furthermore some components like mosfets and the Arduino board can be bought very cheaply on Ebay.

For the current sensing as mentioned before a ACS712 hall effect sensor will provide more linear and stable data compared to the OP-AMP. Also a breakout board won;t be necessary since the chip is easily sold-arable on a proto shield.

Furthermore a I2C display like this can be used for displaying the measured data. An I2c display is necessary since on a standard Adruino UNO there will be not enough available pins.

Step 3: Heat Calculations

Picture of Heat Calculations


In order to ensure that the mosfets will stay within proper operation temperature and handle the power passing trough them a heat sink is required. In the current case a single heat sink of 5.5C/W is used for the 3 MOSFETs.

Step 4: Code

Picture of Code

The code works a a simple state machine. The flowchart describes the basic principle of operation.

For the MPPT the program basically compares the current power output to the previous one, in the previous iteration of the code. The power is calculated based on the current and voltage measured from the arduino. If the voltage is then too big, compered to the current, the duty cycle decreases and vice versa.

Important note: The maximum duty cycle is set to be 99.9%, due to the charge pump in the mosfet driver which needs a frequency to operate.

For the switching frequency timer 1 is used tithe the timer library included in the code. This is needed to achieve the frequency of 10kHz. Furedermore in the Charger code archive file the two libraries for the LCD are included. The I2C LCD needs to be connected to analog pin 4 and 5 of the Arduino and the Serial.print statements in the code need to be changed to lcd.print.

I am also uploading the main ino file as a request, separately. Note that you will need the libs requested in order to for it to compile and run.

Step 5: BOX

Picture of BOX

For the current prototype a custom box was designed and build using a laser cutter. However since a laser cutter is not easily available everywhere, it is better for a standard hardware box to be used. Example box . The size can be as big as you want as long as the circuit fits inside.

It is important for the circuit to be protected from accidental touch, since it handles quite a large amount of power and could cause bodily harm if not handled properly and if something goes wrong. Furthermore the heat sink can get quite hot at high power.

Step 6: Testing the Charger

Picture of Testing the Charger

Solar Panel Test

The build circuit was tested with an actual solar panel, in order to ensure that the it can handle the power of 50W.

Temperature Test

The temperature test was carried out in a small temperature chamber at 70 ⁰C. The charger setup was placed in the chamber and turned on. The circuit was in operation until the chamber reached 70⁰C. After that the charger was left to operate at 70⁰C for 30min. After the test the temperature of the heat sink was measured with a laser thermometer that showed a temperature of 77.2⁰C (IMAGES).

User Manual

Finally an user manual is available in the attached PDF files.

Step 7: Final Toughs

The final build functioned perfectly, although there were many issues during the development processes and more that a few burned parts :).

As mentioned before a few improvements can be made, mainly in the displaying of the charge data on a display.

Finally this is a good project for anyone that wishes to get some experience with power electronics and arduino programing.


skygate (author)2014-09-06

HI all

If you like the project vote for it on the contest pages.

Best Regards


bret.tschacher (author)skygate2014-11-29

Skygate, I like the instructables a lot but I am having issues with the downloaded codes not compiling as they are. I would like to know why that is. I have posted comments on a couple of other projects that I really need to get working. If you can help , it would sure be appreciated. I look at the circuits and can see that they are viable but I have almost no experience with code writing, and that is holding me up.

kimnguu (author)bret.tschacher2014-12-05

Hello Bret.

his code worked fine without problem when i compile it

bret.tschacher (author)kimnguu2014-12-05

KImnguu, I have looked at many different projects on Arduino and have copied codes by download and also by hand from the pages and to this day I have yet to get any of them to compile, and get the circuits to work. I get errors like undefined parameter, error expected this or that. I have worked with some of this and gotten some errors to go away but only get so far and stopped with another error I cannot clear. There has to be something either in the download files that is not coming through cause of me not having pro access or something. Like I said, I have hand written them, and downloaded and gone directly to Arduino Suite with the file and hit the compile tab and they don't work.

Ok , it took me a little bit of time and I now have some progress. I have a compiled code that I need to go back to and look closer at it. I am not exactly sure about some of it cause the language is not all in English but I think it will do what I need to do. I'm pretty sure now it was cause I didn't have the latest version of Arduino which I went to the official site and downloaded new stuff. L

ChrisS8 (author)bret.tschacher2014-12-21

bret.tschacher, do you import the libraries correctly? I have just downloaded the code and compiled it first time, with nothing else done than adding the libraries to the correct place

a58585 (author)2016-04-08

I seen a 6 to 12V 3A with max output 4A for sale. Would anyone know how to make an 8A version? Or can you just use 2 or 3 of these in parrallel on the same panel and charging 2 or 3 batteries? Is there anyone who can explain how to build a charger controller to someone who has not build them before? I see on this instructable here I have not enough knowledge to build the arduino one. If you buy them online they are too small capacity and usually can handle even less than what they claim.

Akshay KumarJ1 (author)2016-02-22

I have a doubt
Can I use 150w solar panel
Plz do reply

hank7725 (author)2016-02-18

anyone now how to increase the amp capacity from 5A to 20A?

ghandig (author)2016-01-05

by changing the Inductor 33µH 5A to 33µH 10/20A and the two fuse into 10/20A could make the output high enough to drive 100 - 200 watts of solar right?

teenagehero0001. (author)2015-08-29

Hi, I really need this project to passed may subject. It is mu 3rd take to that subj. can you please help me. but can you add a LCD, so that there is a indicator on what percentage if the battery is charge ?

KnuthH (author)2015-07-21


can you give me the eagle .sch files ?

noelgeorgi (author)2015-06-08

Can i use an rectified transformer output as the input to this MPPT, rather than the solar panel???

mayureshrao (author)2014-12-16

hello sir can share the complete design details of this project

jlj0425 (author)2015-01-18

do you have code that use ACS712 instead of AD8212

bret.tschacher (author)2014-11-29

I have been trying to work with some of these projects posted on the net at Instructables for a while now in an attempt to learn something about coding. I have downloaded a couple of projects with the code files and Everytime I get a source code I run it through the verification and they NEVER work! There are always errors in the files as I download them. Why? How can anyone be impressed with these projects if none of them will work? I thought I was doing something wrong but as I said, I am downloading the codes from the given links and none of them have worked yet. The last one I was working with had so many errors in it, I started going over it and I have managed to reduce the number of errors but there is one I cannot get past yet. That project is the dual axis solar tracking system with servos. I can get compiled up to only one servo and then it refuses to recongnize the second set of instruction for the other servo. I need to have a functional code and then get this charging system working so I can finish my off grid power system. I want to use multiple charge controllers so if something goes wrong with the system it isn't All down but only the section that failed, the rest of them will continue working, sort of like micro inverters - micro chargers for each panel in the system then connect them in parallel. If one goes down it will be indicated by the LEDs.

I think I'm making some progress with it. I just need to get back to it without any distractions. I got a compiled code that is not all in English in the notes section so it is tough figuring out what the guy is trying to do.

If anyone has any help to give on these please go to facebook and find me or email me at

mayureshrao (author)2014-12-16

hello sir can share the complete design details of this project

mayureshrao (author)2014-12-16

hello sir can share the complete design details of this project

ChargerE (author)2014-09-27


I want to add a LCD and follow your suggestion to replace all the Serial.print with lcd.print, but the code seem to not work (i.e. the code can't compile). I have already added your given lib "__MACOSX" & "LiquidCrystal" but it still can not compile.

Could you teach me how to do so, thanks!

bret.tschacher (author)ChargerE2014-11-29

I see you are also having issues with compiling code for these projects. There is something wrong with the files that you downloaded. I have been fighting this for awhile myself. If you learn anything please let me know as I think we both are working with the same problem.

beppe2810 (author)2014-11-25

hi dear,

I am very much interested in your design, bat my battery bank is 2x12v 100ah battery in series outputing 24v (Charging current 10A).

Can you suggest the change to be made to the power section?

Tanks - Beppe

ibenkos (author)2014-10-18

Smart idea! I really like this project. Thanks for shearig :)

xalpage (author)2014-09-26

Thanks for sharing!

I have a question. Can you use this to charge a LIC( Lithium Ion Capacitor)?

Randy Lahey (author)2014-09-14

This is Tim Nolan's design.

deba168 (author)Randy Lahey2014-09-15

Yah it is Tim Nolan's design.The author modified according to his requirement.

deba168 (author)2014-09-06

Its looks really nice and professional
Thanks for sharing..

About This Instructable




More by skygate:Arduino powered Solar Battery Charger
Add instructable to: