loading

MERITSUN, the Best Lithium Energy Solution Provider.

arduino solar charge controller ( version 2.0) - integrated solar street light

arduino solar charge controller ( version 2.0)  -  integrated solar street light

[Play Video ]
A year ago, I started building my own solar system to power my country house.
Initially, I made a charging controller based on the LM317 and an electric energy meter for monitoring the system.
Finally, a PWM charging controller was made. In April-
2014 I posted my PWM solar charge controller design online and it became very popular.
Many people all over the world have their own buildings.
So many students have completed their university projects with my help.
I get a few emails every day asking people questions about hardware and software modifications to different rated solar panels and batteries.
A large part of the email deals with modifications to the charging controller for the 12 V solar system.
You can find all my items above and see my other version of the charging controllerVersion-3. 0)
ARDUINO solar charging controller (Version-1)
To fix this, I made this new version of the charging controller so that anyone can use it without changing the hardware and software.
In this design, I combine the electric energy meter with the charge controller.
Version specification-
2 charging controller: 1.
Charging Controller and energy meter.
Automatic selection of battery voltage (6V/12V)3.
Set the PWM charging algorithm for automatic charging according to the battery voltage.
LED indication of charging status and load status.
20x4 character LCD display for displaying voltage, current, power, energy and temperature. 6.
Lightning protection 7
Reverse current protection 8.
Short circuit and overload protection.
Temperature Compensation for electrical specifications: 1.
Rated Voltage = 6 v/12V2.
Maximum current = 10A3.
Maximum load current = 10A4.
Open voltage = 8-
11 v/15-6 v System-
12 v system components 25 V: 1. Arduino Nano (
Amazon/Bongo)2. P-MOSFET (
Amazon/IRF 9540x2)3. Power diode (
Amazon/MBR 2045 for 10A, IN5402 for 2A)4. Buck converter (
Amazon/Bongo)5.
Temperature Sensor (
Amazon/Bongo)6. Current Sensor (
Amazon/Bongo)7. TVS diode (
Amazon/P6KE36CA)8. Transistors (
2N3904 or Banggood)9. Resistors (
100 k x 2, 20 k x 2,10 k x 2,1 k x 2, 30 ohm x 5): Banggood 10.
Ceramic Capacitors (0. 1uF x 2): Banggood11.
Electrolytic capacitors (100uF and 10uF): Banggood12. 20x4 I2C LCD (
Amazon/Bongo)13. RGB LED (
Amazon/Bongo)14. Bi Color LED (Amazon )15.
Jumper/wire (Banggood)16. Header Pins (
Amazon/Bongo)17. Heat Sink (
Amazon/Bongo)18.
Fuse holder and fuse (Amazon / eBay)19. Push Button (
Amazon/Bongo)20.
Perforated plate (
Amazon/Bongo)21.
Engineering enclosure (Banggood )22.
Screw terminals (
3x 2pin and 1x6 pin): Banggood23.
Nuts/screws/bolts (Banggood )24.
Plastic base tools: 1. Soldering iron (Amazon )2.
Wire cutter and stripper (Amazon )3. Screw Driver (Amazon )4. Cordless electric drill (Amazon )5. Dremel (Amazon )6. Glue Gun (Amazon )7. Hobby Knife (Amazon )
The core of the charging controller is the Arduino nano board.
The Arduino MCU detects solar panel and battery voltage.
Based on these voltages, it determines how to charge the battery and control the load.
The size of the charging current is determined by the difference between the battery voltage and the charging set point voltage.
The controller adopts a two-stage charging algorithm.
According to the charging algorithm, p-to the side of the solar panel-MOSFET.
The frequency of the PWM signal is 490. 20Hz(
Default Frequency of pins3).
Duty cycle 0-
100% adjusted by the error signal.
The controller provides high or low commands to the load side p-
MOSFET according to dusk/Dawn and battery voltage.
A complete schematic diagram is attached below.
The charging controller is designed by handling the following points. 1.
Prevent overcharging of the battery: when the battery is fully charged, limit the energy provided by the solar panel to the battery.
This is the implementation of charge_cycle ()of my code. 2.
Prevent excessive discharge of the battery: disconnect the battery from the power load when the battery reaches a low charging state.
This is implemented in load _ control ()of my code. 3.
Provide load control function: Automatically connect and disconnect the electrical load at the specified time.
The load turns on at sunset and the load turns off at sunrise.
This is implemented in load _ control ()of my code. 4.
Monitor Power and Energy: monitor and display load power and energy. 5.
Prevent abnormal situations: protect the circuit from different abnormal situations such as lightning, over-voltage, over-current and short circuit. 6.
Indication and display: indicate and display various parameters s7.
Serial Communication: print various parameters in serial monitor 1.
Voltage sensor: the voltage sensor is used to sense the voltage of solar panels and batteries.
It is achieved by using two voltage divider circuits.
It consists of two resistors R1 = 100 k and R2 = 20 k for induction of solar panel voltage, again, R3 = 100 k and R4 = 20 k for battery voltage.
The output of R1 and R2 is connected to Arduino analog pin 0, and the output of R3 and R4 is connected to Arduino analog pin a1. 2.
Current Sensor: The current sensor is used to measure the load current.
This current is then used to calculate the power and energy of the load.
I'm using the Hall current sensor (ACS712-20A)3.
Temperature Sensor: temperature sensor is used to sense room temperature.
I used the LM35 temperature sensor with a rated temperature range of-55 °C to 150 °C.
Why is temperature monitoring required?
The chemical reaction of the battery changes with the temperature.
The gas will increase as the battery warms.
As the battery gets colder, it's more resistant to charging.
Depending on the degree of change in the battery temperature, it is important to adjust the charge to accommodate the temperature change.
Therefore, it is important to adjust the charge to consider the temperature effect.
The temperature sensor will measure the battery temperature and the solar charging controller will use this input as needed to adjust the charging setting point.
Compensation value is-
5mv/degC/cell for lead
Acid battery. (
The 12 V battery is 30 mV/°C and the 6 V battery is 15 mV/°C).
The negative sign of the temperature compensation indicates that the temperature increase requires a reduction in the charge setting point.
More details on understanding and optimizing the battery temperature compensation voltage sensor: 5 v = ADC count 10241 ADC count = (5/1024)Volt= 0.
0048828 v Vout = Vin * R2 /(R1+R2)Vin = Vout*(R1+R2)
/R2 R1 = 100, R2 = 20Vin = ADC count * 0. 00488*(120/20)
Volt current sensor: seller information based on ACS 712 current sensor sensitivity, = 100 mV/A = 0.
The test current by output voltage 100 V/ANo is VCC/2 = 2.
5ADC count = 1024/5 * Vin, Vin = 2. 5+0. 100*I (Where I = current)ADC count= 204. 8(2. 5+0. 1*I)=512+20. 48*I => 20. 48*I = (ADC count-512)=> I =(ADC count/20. 48)-512/20. 48Current (I)=0. 04882*ADC -
25 more details of the Acs712 temperature sensor: according to the LM35 sensitivity = 10 mV/°c temperature at °c = (5/1024)
* ADC count * 100 Note: the sensor is calibrated assuming arduino Vcc = 5 v reference.
But it's not always 5 v in practice.
Therefore, there may be wrong value from the actual value.
It can be solved in the following ways.
Measure the voltage between Arduino 5 v and GND with a multimeter.
Use the voltage of Vcc in the code instead of 5 v.
Click and try to edit this value until it matches the actual value.
I got four points.
47 V instead of 5 v.
So the change should be 4. 47/1024=0.
Instead of 0 0043652. 0048828. 1.
Batch: maximum constant current flow preset in this mode (amps)
Is fed into the battery because there is no PWM.
When the battery is charged, the voltage of the battery gradually increases.
Absorption: when the battery reaches the batch charge set voltage, the PWM starts to keep the voltage constant.
This is to avoid excessive
Heating and overheating
Deflate the battery
The current will gradually decrease to a safe level as the battery is fully charged. 3.
Float: reduce the charging voltage when the battery is fully charged to prevent the battery from further heating or deflating. This is the ideal charging procedure.
The current code charging cycle block does not realize stage 3 charging.
I used simpler logic in two stages. It works well.
I am trying the following logic to implement a charge for 3 stages.
Future planning of the charging cycle: when the solar panel voltage is greater than the battery voltage, the batch charging starts.
When the battery voltage reaches 14.
4 V, will enter the absorption charge.
The charging current will be regulated by the PWM signal to keep the battery voltage at 14. 4 V an hour.
In an hour, the float will enter.
The floating stage generates trickle charge, keeping the battery voltage at 13. 6V.
When the battery voltage is less than 13.
The charging cycle will be repeated for 6 v 10 minutes.
I am asking community members to help me write code that implements the logic described above.
In order to automatically connect and disconnect the load by monitoring dusk/Dawn and battery voltage, load control is used.
The main purpose of load control is to disconnect the load from the battery to prevent deep discharge of the battery.
Deep discharge can damage the battery.
DC load terminals are designed for low power DC loads such as street lamps.
The PV panel itself is used as an optical sensor.
Let's say the solar panel voltage> 5 v means dawn and dusk.
In conditions: at night, when the PV voltage level is lower than 5 v and the battery voltage is higher than the LVD setting, the controller will turn on the load and the load green led will shine.
Off condition: the load will be cut off in the following two cases. 1.
When the photovoltaic voltage is greater than 5 v in the morning, 2.
When the battery voltage is lower than the LVD setting, the red led on the load indicates that the load is cut off.
LVD is called low voltage disconnect power supply: the power supply is the product of the voltage (volt)and current (Amp)
P = VxIUnit of power is Watt or KWEnergy: Energy is the product of power (watt)and time (Hour)
E = the unit of energy is watt-hour or kilowatt-hour (kWh)
In the software, the load power and energy of the above logic are monitored and the parameters are displayed in the 20x4 character LCD. 1.
Reverse polarity protection for solar panels.
Overcharge Protection 3.
Deep discharge protection 4.
Short circuit and overload protection 5.
Reverse current protection at night.
Over-voltage protection at the input of the solar panel for reverse polarity and reverse current protection I used a power diode (MBR2045).
Power diodes are used to handle a large amount of current.
In my previous design, I used a normal diode (IN4007).
The software realizes the protection of overcharge and deep discharge.
Over current and overload protection by using two fuses (
One on the side of the solar panel and the other on the load side).
Temporary overvoltages occur in the power system for various reasons, but lightning can cause the most serious overvoltages.
This is especially true for photovoltaic systems due to exposed locations and system connection cables.
I used 600 in this new design-
Diode (Watt) two-way TVP6KE36CA )
Suppress lightning and over-voltage of photovoltaic terminals.
In my previous design, I used the Zener diode.
You can also use similar TVS diodes on the load side.
For a selection guide for TV diodes, click here to select the correct part number for the TV diode and click here for battery charge status (SOC)
LED: an important parameter that defines the energy content of the battery is the charging state (SOC).
This parameter indicates how much power is in the batteryAn rgb led to indicate the battery charging status.
For connection, please refer to the battery LED------------
> Battery Status--------------------
> Low voltage--------------------
The voltage is healthy--------------------
> Fully charged LED: doublecolor (red/green)
Led is used for load status indication.
Please refer to the schematic diagram above for connection. Load LED ---------------------
> Loading status green-------------------------> Connected (ON)RED ---------------------------
> Disconnect (OFF)
I include a third led indicating the state of the solar panel.
20x4 I2C LCD was used to display voltage, current, power, energy and temperature.
Disable LCD _ display if you do not want to display parameters ()
Loop from invalid ()function.
After Disabled, indicate that the led will monitor the battery and load status.
Download LiquidCrystal _ I2C Library from hereNote: in the code, you have to change the address of the I2C module.
You can use the address scanner code given in the link.
Before soldering the circuit together, it is always a good idea to test the circuit on the breadboard.
Upload the code after connecting everything.
The code is attached below.
For flexibility, the entire software is divided into small functional blocks.
Assume that the user is not interested in using the LCD display and is satisfied with the led indication.
Then disable LCD _ display ()
Loop from invalid (). That's all.
Similarly, he can enable and disable various functions according to the needs of the user.
Download code from my GitHub accountSOLAR-CHARGE-CONTROLLER-V-
2 terminals: Add 3 screw terminals for solar input, battery and load terminal connections. Then solder it.
I connect the battery with the screw terminal in the middle, the solar panel on the left and the load on the right.
Power supply: in my previous version, the power supply for Arduino was provided by a 9 v battery.
In this version, the power supply is taken from the rechargeable battery itself.
The voltage regulator reduces the battery voltage to 5 v (LM7805).
Weld the LM7805 voltage regulator near the battery terminal.
Then weld the electrolytic capacitor according to the schematic diagram.
At this stage, connect the battery to the screw terminals and check the voltage between the lm7805 pins 2 and 3.
Should be near 5 v.
The LM7805 works fine when I use the 6 v battery.
But for a 12 v battery, it will heat up after a while.
So I asked to use the radiator for it.
Efficient Power supply: After several tests, I found that the voltage regulator LM7805 is not the best way to power the Arduino because it wastes a lot of power in the form of heat.
So I decided to change it with a DC.
Efficient DC buck converter.
If you are going to do this controller, I would recommend using a step-down converter instead of the LM7805 voltage regulator.
Step-down converter connection: IN-------> BAT+IN---------> BAT-OUT+ -----> 5VOUT------
> Picture above GNDRefer.
You can buy from eBayCut 2 female headlines with 15 stitches each.
Place the nano board for reference.
Insert two heads according to the Nano pin.
Check if the nano board is suitable for it.
Then weld on the back.
Insert two rows of male heads on both sides of the Nano board for external connections.
Then connect the welding point between the Arduino pin and the head pin.
See above.
Initially I forgot to add the Vcc and GND titles.
At this stage, you can place titles with 4 to 5 pins for Vcc and GND.
As you can see, I connect the voltage regulator 5 v and GND to the nano 5 v and GND with red and black wires.
Later, I took it off and welded it on the back to better observe the board.
Before welding the assembly, drill holes in the corners for installation.
Weld all components according to the schematic diagram.
The radiator is applied to both mosfet and power diode.
Note: The power diode MBR2045 has two anode and one cathode.
The two anode is too short.
I use the thick line as the power cord, use the ground wire as the signal, and use the thin line as the signal. signal.
Since the controller is designed for a higher current, the thick line is mandatory.
After welding all components to two thick wires to the drain of the load MOSFET and the upper terminal of the load side fuse holder.
Then connect these wires to the screw terminals provided in the current sensor (ACS 712).
Two LEDs are shown in my schematic.
But I added a third led (bi-color)
Used to indicate the future State of the solar panel.
Prepare a small size perforated plate as shown in the figure.
Then two holes (3. 5mm)
Through around (for mounting).
Insert the LEDs and weld them to the back of the board.
Insert the 3-pin female connector for the temperature sensor and then weld it.
Weld 10 pin right angle joints for external connections.
Now connect the RGB led anode terminal to the temperature sensor Vcc (pin-1).
Welding the cathode terminals of two bicolor led.
The led terminal is then connected to the welding head.
You can paste the sticker with the pin name for easy identification.
Connect the charging controller to the battery first, as this allows the charging controller to be calibrated to a 6 v or 12 v system.
Connect the negative end first, and then the positive end.
Connecting solar panels (
Positive after negative first)
Finally connect the load.
Charging Controller load terminals are only available for DC loads.
How to Run AC load?
If you want to run the AC device then you have to need an inverter.
Connect the inverter directly to the battery.
See above.
After connecting the motherboard and the indicator board to the jumper (female-female)
Please refer to the schematic diagram during this connection.
A connection error may damage the circuit.
So be careful at this stage.
Plug the USB cable into the Arduino and upload the code.
Remove the USB cable.
If you would like to see the serial monitor, keep the connection.
Fuse rating: in the demo I put a 5A fuse in the fuse holder.
However, in actual use, a fuse with a short circuit current of 120 to 125% should be put in.
For example: 100 W solar panel with Isc = 6.
A fuse 6 is required. 32x1. 25 = 7.
How to Test 9 or 8? I used a buck-
Test the boost converter and black cloth of the controller.
The converter input terminal is connected to the battery and the output is connected to the charging controller battery terminal.
Battery Status: rotate the converter potentiometer with a screwdriver to simulate different battery voltages.
The corresponding led will turn off and on when the battery voltage changes.
Note: During this process, the solar panel should be disconnected or covered with black cloth or cardboard.
Dawn/dusk: simulate dawn and dusk with black cloth.
Evening: fully covered with solar panels.
Day: remove the cloth from the solar panel.
Transition: slow down the removal or coverage of cloth to adjust the voltage of different solar panels.
Load Control: the load will be turned on and off depending on the battery condition and Dawn/dusk conditions.
Temperature Compensation: keep the temperature sensor to increase the temperature and place anything cold like ice to lower the temperature.
It will be displayed on the LCD immediately.
The compensated charge setting value can be seen on the serial monitor.
In the next steps, I will describe the production of this charging controller housing.
Place the motherboard inside the housing.
Mark the position of the hole with a pencil.
Then apply hot glue in the marked position.
Place the plastic base on the glue.
Then place the board on the base and screw in the nut.
Mark the LCD size on the front cover of the housing.
Cut the marking section using Dremel or any other cutting tool.
After cutting with a hobby knife.
Drill holes for installing LCD, Led indication panel, reset button and external terminal Mount panel, 6 pin screw terminal and reset button after drilling.
Used to connect solar panels and use 6 pin screw terminals outside the battery and load.
Connect the external terminal to the corresponding terminal of the motherboard.
Connect the indicator panel and LCD to the motherboard according to the schematic diagram. (Use female-
Female jumper)
One terminal of the reset button goes to the RST of the Arduino and the other to the GND.
After all connections.
Close the front cover and screw it.
How to draw realtime graphs?
This is very interesting if you can draw the serial monitor parameters (
Such as battery and solar voltage)
On the chart on the laptop screen.
If you know a little bit about handling, it can be done easily.
For more information, you can refer to Arduino and Processing (Graph Example ).
How do I save this data?
This can be done easily with SD cards, but this includes more complexity and cost.
To solve this problem, I found a simple solution through Internet search.
You can save data in an Excel worksheet.
For more information, you can refer to view-sensors-how-to-visualize-and-save-arduino-sensed-
The picture above is downloaded from the Internet.
I want to know what I want to do and what you can do.
Future planning: 1.
Remote Data recording via Ethernet or WiFi. 2.
More powerful charging algorithm and load control 3.
Add a USB charging point to your smartphone/tablet and you like my instructions.
Please make any suggestions for improvement.
Please comment if there are any errors or errors.
Follow me with more updates and new interesting projects. Thanks :)

GET IN TOUCH WITH Us
recommended articles
Knowledge Successful case News
Dell mini 1012 battery is generally hailed because just in regards most strong along with high-performance pc add-ons across the world.
Basic Care And Problem solving Of the LiFePO4 E-Bike Battery
A typical selection for running the hyperlink motor products are commonly a LiFePO4 battery bunch (Lithium-Iron-Phosphate).
Choosing an Electric Motorcycle Battery Information on Getting Rechargeable Electric powered Bicycle Batteries
E-bikes are becoming popular being an environmentally friendly and also wholesome means of almost sweat-free carry.
External Battery also be called mobile power.
Lithium Phosphate (LIFEPO4) Rechargeable Batteries
Lithium Iron Phosphate (LiFePO4) Batteries that are launched providing 96.
State regulators have approved the purchase of battery storage to support energy supplies in southern California, and as Aliso Canyon gas storage facilities are in trouble, energy supplies in southern California face potential shortages.
Co-conjugated polymer molecules are considered as promising electrode materials for the next generation.
The battery in the home safety system is an important part of the system
Maybe the most important part.
BANGALORE (Reuters)-Makers of lead-
Acid batteries are developing new battery types to boost fuel growthEfficient, stop
Start technology
The car engine turns off when the vehicle is not moving, but when the driver steps down the throttle, the engine starts automatically.
no data
Established in 1999, we have 20+ years of energy professional experience and integrated solutions services in energy storage application industrial, and further reach the demands the smart & green energy era. 
Copyright ©1999-2025 MeriTech Power Limited | All Rights Reserved | Sitemap | Privacy Policy
Customer service
detect