Solar panel charge controller using Arduino.


Solar Panel Battery Charge Controller Using Arduino


by Lewis Loflin

Above: Fig. 1 Schematic of solar panel charge controller using Arduino and a P-channel MOSFET.

Solar Panel Battery Charge Controller Switching Circuit

This is an updated version of Solar Panel Charge Controller Using Arduino.

ACS712 current sensor
Fig. 2 ACS712 Hall effect current sensor connected to Arduino AD2.


The output voltage of the ACS712 is 2.5V with no input while the spec sheet specifies 66 to 185 mV/A output sensitivity. That's a broad range and given the errors of Arduino's 10-bit ADC this gives approximate current output. Good enough for most applications.

The LED1 indicator 'bad' meaning the input voltage below the charging voltage when on.

DP3 turns on charge switch MOSFET transistor. Can use PWM or a simple timing routine. Will blink on/off with charge cycle. (Charge enable). The LED in the new circuit is merely an indicator.

LED2 indicator fully charged battery. (DP10)

A 10-bit analog-to-digital converter (ADC) has a step voltage of about 4.9 mV over a 5-volt range. This relates to the charge point (CP) variable.

To measure input voltage from the solar panel and the voltage on the battery we use a voltage divider to drop the voltage below 5-volts.

This uses 10 volt Zener diode resister combination producing 0-5 volts. The CP variable works around 600. Experiment with this.

Note the 4.9 mV was derived from the 10-bit ADC which equals 1023: 5V / 1023 = 4.9mV

Note line "chon = CP - y * 100" when uncommented the charge 'on' time will decrease gradually as battery is more charged. When fully charged the charge voltage is disabled.

Otherwise that part can be commented out and use a simple ON-OFF timing loop.

The variables chon (charge on time) and choff (charge off time) can be preset to any value.

One can experiment with this CP value. Too small, battery won't fully charge. Too large, battery will over charge. The formula is (Vin / 17,200) * 2200 / .0049.

The voltage input is connected to AD0 while the voltage on the battery is monitored at AD1. By experimentation I found a value of 600 worked well. The Zener diode setup works well.

The power for the Arduino itself can be obtained from the battery bank under charge through a 5-volt regulator. Note if the input voltage and battery is completely dead the circuit won't function with no power to Arduino.

A separate power source for the Arduino can be used. In this case a 13.5 external power supply will work for an input voltage to charge small batteries.

DP3 has pulse-width modulation built in and can be used to limit charge current (lower duty cycle) or even charging lower voltage batteries. CP or charge point will have to be changed. If one is unfamiliar with transistor switching circuits see the following:

Download the Arduino code solar1.txt.

Web site Copyright Lewis Loflin, All rights reserved.
If using this material on another site, please provide a link back to my site.