Arduino Solar Battery Charge Controller
Arduino Solar Battery Charge Controller
This is a simplified version of my Solar Panel Battery Charge Controller Using Arduino. One
can easily add the ideas from that project to this one.
Visit Site
Above is a generic Arduino Nano, but the code will work on any Arduino style microcontroller. The
5V regulator is build into the unit I used and if not use a separate 5V supply.
The battery voltage is measured from the TP1. The 10V zener diode drops 10V leaving a voltage
value of 0v-5V at TP1. Normally the battery/charge voltages range from 12V-14V. The Arduino
ADC returns a 10-bit value from 0-1023 based on an input voltage of 0V-5V. A value of Vin should
return an ADC number of about 600 based on a 12.7 volt input. The idea is if the battery voltage
drops below 12.6V turn on the charge current from the solar panel, turn off the current then wait,
then measure again.
http://www.bristolwatch.com/solar_charger.htm 1/5
3/11/2019 Arduino Solar Battery Charge Controller
A HIGH from DP2 switches on Q1/Q2. Q1 is a PNP bipolar transistor. In addition by adjusting the
value of 1K resistor on Q1's base we can introduce current limiting in addition to acting as a power
switch. See Introduction to Constant Current Circuits. Note in the video I was charging a 12-
volt lead-acid sealed gel-cell type battery.
This is for small applications and if trying to charge a 1000-watt battery bank buy a commercial
unit. Add a heat sink to Q1 if needed - other PNPs will work if they have sufficient collector current.
See the following on various types of switching transistor circuits:
The above uses a transistor switching circuit to turn on the zener diode circuit to do a voltage
measurement. This prevents the small, but steady discharge of the battery. You will have to add
that to the following code.
/*
Solar cell battery charger/regulator
*/
#define Vin 0
#define CE 2 // charge enable
#define chon 4000 // charge on time
#define choff 4000 // charge off time
#define CP 600 // charge point variable
int val;
http://www.bristolwatch.com/solar_charger.htm 2/5
3/11/2019 Arduino Solar Battery Charge Controller
void setup() {
pinMode(CE, OUTPUT);
digitalWrite(CE, LOW);
Serial.begin(9600);
}
void loop() {
val = analogRead(Vin);
while (val > CP) {
val = analogRead(Vin);
Serial.print("Charge off val = ");
Serial.println(val);
Serial.print("Vbat = ");
Serial.println(val * .0048 + 10.0);
delay(2000);
}
digitalWrite(CE, HIGH);
delay(chon);
digitalWrite(CE, LOW);
delay(choff);
}
The above program will produce this out on the Arduino serial monitor.
I used this circuit to protect my solar panel charging system. The solar panel can produce a
maximum current of 500mA. A really drained lead-acid battery can look like a dead short so this
safely limits the current to protect the panel from possible damage.
» Webmaster
» Hobby Electronics
» US Constitution
http://www.bristolwatch.com/solar_charger.htm 4/5
3/11/2019 Arduino Solar Battery Charge Controller
Videos:
My YouTube Videos on Electronics
Introduction to the Arduino Microcontroller
Part 1: Programming Arduino Output
Part 2: Programming Arduino Input
Part 3: Arduino Analog to Digital Conversion
Part 4: Using Arduino Pulse-Width-Modulation
Repost Arduino AC Power Control
http://www.bristolwatch.com/solar_charger.htm 5/5