Fig. 1 Charger circuit using 12-volt DC relay. While it can handle a
lot of current, too many on/off cycles will wear down the contacts.
Solar Panel Charge Controller Using Arduino Microcontroller
by Lewis Loflin
To see the Picaxe version of this page see Solar Panel Charge Controller Using PICAXE Microcontroller
For an updated version of this page see Solar Panel Battery Charge Controller Using Arduino
Fig. 2 Charger circuit using PNP power transistor switch.
This is a good circuit for fairly low charging currents. I used a 2SA1803.
Fig. 2 Charger circuit using p-channel MOSFET transistor switch.
The zener diode is optional depending on the Vgs values of the MOSFET and the input voltage. In this case I used a IRF9530 with a Vgs of 20 volts. The MOSFET fully cuts on with a gate to source difference of 6-8 volts. If the input voltage is under 20 volts the zener can be left out and the 2.2K resistor can be changed to 10K.
But if over 20 volts the zener will be needed. Say the input is say 30 volts I'd use at least a 15-volt zener because it will drop the additional voltage and protect the MOSFET. Two 12 volt solar panels in series could easily go to 25-30 volts.
Purpose: to cycle the charge voltage on/off via relay or transistor and to check other aspects such as solar panel input voltage and battery voltage when charging lead-acid batteries.
The LED1 indicator 'bad' meaning the input voltage is below the charging voltage or below the charge point when on.
DP11 turns on charge switch transistor. Can use PWM or a simple timing routine. Will blink on/off with charge cycle. (Charge enable)
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 two resistor voltage dividers (15k and 2.2k) which produces a voltage of about 1.5 - 1.9 volts when fully charged. This equates to about decimal 346 - 388 (when divided by 4.9mV) from the ADC and is compared to the charge point variable CP.
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.
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.
Note the table below for the voltage divider at various voltages:
|Input V:||ADC Reading:|
The voltage input is connected to AD0 while the voltage on the battery is monitored at AD1. By experimentation I found a value of 310 worked well. This may vary due to resistor values.
This same circuit can be used with a 24-volt system by changing the 15K to 27K (recalculate CP) and using a 24-volt relay.
The power for the Arduino itself can be obtained from the battery bank under charge
through a 5-volt regulator or separate supply. Note if the battery bank is completely
dead the circuit won't function with no power to the Microcontroller.
A separate power source for the controller can be used.
This circuit will also work using a power supply instead of a solar panel as a simple battery charger.
Download code solar.cpp
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.
The formula is Iout = 1.25V / RE. For 500mA RE = 2.5 Ohms.
See Introduction to Constant Current Circuits
- Testing the Keyes IR Sensor Module with Arduino
- How to Connect Easy Driver Micro-Stepper Controller to Arduino
- Connect Arduino to LCD Display with 74164 Shift Register
- Arduino with LCD Display and DS18B20 Temperature Sensor
- Below has differing code from the above. Works the same.
- Arduino with LCD Display and DHT11 Temperature-Humidity Sensor
- In Depth Look at AC Power Control with Arduino
- Four part series:
- Experimenting with the PCA9555 32-Bit GPIO Expander with Arduino
- PCA9555 32-Bit GPIO Expander with Arduino and a 4X4 Keypad
- PCA9555 32-Bit GPIO Expander with Arduino Using Interrupts
- PCA9555 32-Bit GPIO Expander with Arduino and LCD Display
- YouTube Video Interfacing PCA9555 to Arduino
- Quick navigation main page:
- Arduino Microcontroller Projects
- General Electronics Learning and Projects
- Raspberry Pi and Linux
- Connecting a PC Printer Port to Electronics with Python
- Microchip PIC 18F2550
- PICAXE Microcontroller