ARDUINO SOLAR CHARGE CONTROLLER ( Version 2.0)

580,945

1,983

590

Published

Introduction: ARDUINO SOLAR CHARGE CONTROLLER ( Version 2.0)

About: I am an Electrical Engineer.I love to harvest Solar Energy and make things by recycling old stuffs. I believe, IF YOU TRY YOU MIGHT,IF YOU DON'T YOU WON'T. www.opengreenenergy.com

[ Play Video ]

One year ago, I began building my own solar system to provide power for my village house.Initially I made a LM317 based charge controller and an Energy meter for monitoring the system.Finally I made PWM charge controller.In April-2014 I posted my PWM solar charge controller designs on the web,it became very popular. Lots of people all over the world have built their own. So many students have made it for their college project by taking help from me.I got several mails every day from people with questions regarding hardware and software modification for different rated solar panel and battery. A very large percentage of the emails are regarding the modification of charge controller for a 12Volt solar system.
You can see my other version charge controllers

ARDUINO MPPT SOLAR CHARGE CONTROLLER ( Version-3.0)
ARDUINO SOLAR CHARGE CONTROLLER (Version-1)

To solve this problem I made this new version charge controller so that any one can use it without changing the hardware and software. I combine both the energy meter and charge controller in this design.

Specification of version-2 charge controller :


1.Charge controller as well energy meter

2. Automatic Battery Voltage Selection (6V/12V)

3.PWM charging algorithm with auto charge set point according to the battery voltage

4.LED indication for the state of charge and load status

5. 20x4 character LCD display for displaying voltages,current,power,energy and temperature.

6.Lightning protection

7.Reverse current flow protection

8.Short Circuit and Over load protection

9. Temperature Compensation for Charging


Electrical specifications :

1.Rated Voltage= 6v /12V

2.Maximum current = 10A

3.Maximum load current =10A

4.Open Circuit Voltage = 8-11V for 6V system /15 -25V for 12V system

Step 1: Parts and Tools Required :

Parts:

1.Arduino Nano (Amazon / eBay)

2.P-MOSFET ( Amazon / IRF 9540 x2 )

3.Power diode ( Amazon / MBR 2045 for 10A and IN5402 for 2A)

4.Buck Converter ( Amazon / eBay) or Voltage Regulator (LM7805)

5.Temperature Sensor( Amazon / LM35)

6.Current Sensor ( Amazon / ACS712)

7.TVS diode ( Amazon / P6KE36CA)

8.Transistors ( 2N3904 or 2N2222)

9.Resistors( 100k x 2, 20k x 2,10k x 2,1k x 2, 330ohm x 5)

10.Ceramic Capacitors (0.1uF x 2)

11.Electrolytic Capacitors ( 100uF and 10uF)

12. 20x4 I2C LCD ( Amazon / eBay)

13.RGB LED ( Amazon / ebay)

14.Bi Color LED ( Amazon )

15.Jumper Wires/Wires(eBay)

16.Header Pins (Male,Female and right angle)

17.Heat Sink ( Amazon / eBay)

18.Fuse Holder and fuses ( Amazon / eBay)

19.Push Button ( Amazon )

20.Perforated Board (Amazon / eBay)

21.Project Enclosure

22.Screw terminals ( 3x 2pin and 1x6 pin)

23.Nuts/Screws/Bolts

24.Plastic Base

Tools :

1.Soldering Iron ( Amazon )

2.Wire Cutter and Stripper ( Amazon )

3.Screw Driver ( Amazon )

4.Cordless Drill ( Amazon )

5.Dremel ( Amazon )

6.Glue Gun ( Amazon )

7.Hobby Knife ( Amazon )


Step 2: How the Charge Controller Works :

The heart of of the charge controller is Arduino nano board.The arduino MCU senses the solar panel and battery voltages.According to this voltages it decides how to charge the battery and control the load.

The amount of charging current is determined by difference between battery voltage and charge set point voltages. The controller uses two stages charging algorithm.According to the charging algorithm it gives a fixed frequency PWM signal to the solar panel side p-MOSFET. The frequency of PWM signal is 490.20Hz(default frequency for pin-3). The duty cycle 0-100% is adjusted by the error signal.

The controller gives HIGH or LOW command to the load side p-MOSFET according to the dusk/dawn and battery voltage.

The full schematic is attached bellow.

Step 3: Main Functions of Solar Charge Controller:

The charge controller is designed by taking care of the following points.

1.Prevent Battery Overcharge: To limit the energy supplied to the battery by the solar panel when the battery becomes fully charged.This is implemented in charge_cycle() of my code.

2.Prevent Battery Over discharge: To disconnect the battery from electrical loads when the battery reaches low state of charge.This is implemented in load_control() of my code.

3.Provide Load Control Functions: To automatically connect and disconnect an electrical load at a specified time. The load will ON when sunset and OFF when sunrise.This is implemented in load_control() of my code.

4.Monitoring Power and Energy : To monitor the load power and energy and display it.

5.Protect from abnormal Condition: To protect the circuit from different abnormal situation like lightening,over voltage,over current and short circuit etc.

6.Indicating and Displaying: To indicate and display the various parameters

7.Serial Communication: To print various parameters in serial monitor

Step 4: Sensing Voltages,Current and Temperature :

1.Voltage Sensor:

The voltage sensors are used to sense the voltage of solar panel and battery.It is implemented by using two voltage divider circuits.It consists of two resistors R1=100k and R2=20k for sensing the solar panel voltage ans similarly R3=100k and R4=20k for battery voltage.The out put from the R1and R2 is connected to arduino analog pin A0 and out put from the R3 and R4 is connected to arduino analog pin A1.

2.Current Sensor :

The current sensor is used for measuring the load current.later this current is used to calculate the load power and energy.I used a hall effect current sensor (ACS712-20A)

3.Temperature Sensor :

The temperature sensor is used to sense the room temperature. I used LM35 temperature sensor which is rated for −55°C to +150°C Range.

Why Temperature monitoring is Required ?

The battery’s chemical reactions change with temperature.As the battery gets warmer, the gassing increases. As the battery gets colder,it becomes more resistant to charging. Depending on how much the battery temperature varies, it is important to adjust the charging for temperature changes.So it is important to adjust charging to account for the temperature effects. The temperature sensor will measure the battery temperature, and the Solar Charge Controller uses this input to adjust the charge set point as required.The compensation value is - 5mv /degC/cell for lead acid type batteries.(–30mV/ºC for 12V and 15mV/ºC for 6V battery).The negative sign of temperature compensation indicates,increase in temperature require a reduction in charge set point.

For more details on Understanding and Optimizing Battery Temperature Compensation

Step 5: Sensors Callibration

Voltage Sensors :

5V = ADC count 1024

1 ADC count = (5/1024)Volt= 0.0048828Volt

Vout=Vin*R2/(R1+R2)

Vin = Vout*(R1+R2)/R2 R1=100 and R2=20

Vin= ADC count*0.00488*(120/20) Volt

Current Sensor:

As per seller information for ACS 712 current sensor

Sensitivity is =100mV / A =0.100V/A

No test current through the output voltage is VCC / 2= 2.5

ADC count= 1024/5*Vin and 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.48

Current (I) =0.04882*ADC -25

More details on ACS712

Temperature Sensor :

As per data sheet of LM35

Sensitivity=10 mV/°C

Temp in deg C =(5/1024)*ADC count*100

Note : The sensors are calibrated by assuming the arduino Vcc= 5V reference.But in practical it is not 5V always.So there may be chance of getting wrong value from the actual value.It can be solved by following way.

Measure the voltage between arduino 5V and GND by a multimeter.Use this voltage instead of 5V for Vcc in your code.Hit and try to edit this value until it matches the actual value.

Example: I got 4.47V instead of 5V.So the change should be 4.47/1024=0.0043652 instead of 0.0048828.

Step 6: Charging Algorithm

1.Bulk :At this mode, a preset maximum constant amount of current (amps) is fed into the battery as no PWM is present. As the battery is being charged up , the voltage of the battery increases gradually

2. Absorption: When the battery reaches the bulk charge set voltage, the PWM begins to hold the voltage constant. This is to avoid over-heating and over-gassing the battery. The current will taper down to safe levels as the battery becomes more fully charged.
3. Float: When the battery is fully recharged, the charging voltage is reduced to prevent further heating or gassing of the battery

This is the ideal charging procedure.

The present charge cycle block of code is not implements 3 stages charging.I use a easier logic in 2 stages.It works good.

I am trying the following logic for implementing the 3 stages charging.

Future Planning for Charging Cycle :

The bulk charge begins when solar panel voltage is larger than battery voltage. When the battery voltage reaches 14.4V, absorption charge will be entered. The charging current will be regulated by PWM signal to maintain the battery voltage at 14.4V for one hour. Float charge will then enter after one hour. The float stage generates a trickle charge to keep the battery voltage at 13.6V. When the battery voltage falls below 13.6V for 10mins, the charging cycle will be repeated.

I request community members to help me for writing the piece of code to implement the above logic.

Step 7: Load Control

To automatically connect and disconnect the load by monitoring dusk/dawn and battery voltage,load control is used.

The primary purpose of load control is to disconnect the load from battery to protect it from deep discharging. Deep discharging could damage the battery.

The DC load terminal is designed for low power DC load such as street light.

The PV panel itself is used as the light sensor.

Assuming solar panel voltage >5V means dawn and when < 5V dusk.

ON Condition:

In the evening, when the PV voltage level falls bellow 5V and battery voltage is higher than LVD setting, the controller will turn on the load and the load green led will glow.

OFF Condition:

The load will cut off in the following two condition.

1.In the morning when the PV voltage is larger than 5v,

2.When the battery voltage is lower than the LVD setting

The load red led ON indicates that load is cut off.

LVD is refers to Low Voltage Disconnect

Step 8: Power and Energy

Power :

Power is product of voltage (volt) and current (Amp)

P=VxI

Unit of power is Watt or KW

Energy:

Energy is product of power (watt) and time (Hour)

E= Pxt

Unit of Energy is Watt Hour or Kilowatt Hour (kWh)

To monitor the load power and energy above logic is implemented in software and the parameters are displayed in a 20x4 char LCD.

Step 9: Protection

1.Reverse polarity protection for solar panel

2. Overcharge protection

3. Deep discharge protection

4. Short circuit and Overload protection

5.Reverse current protection at night

6.Over voltage protection at solar panel input

For reverse polarity and reverse current flow protection I used a power diode (MBR2045).Power diode is used to handle large amount of current.In my earlier design I used a normal diode(IN4007).

Overcharge and Deep discharge protection is implemented by the software.

Over current and overload protection is implemented by using two fuses ( one at the solar panel side and other at load side).

Temporary over voltages occur in power systems for a variety of reasons, but lightning causes the most severe over voltages. This is particularly true with PV systems due to the exposed locations and system connecting cables.In this new design I used a 600 watt bidirectional TVS diode (P6KE36CA ) to suppress the lightning and over voltage at the PV terminals.In my earlier design I used a zeener diode.You can also use a similar TVS diode on the load side.

For selection guide of TVS diode click here

For choosing a right part no for TVS diode click here

Step 10: LED Indication

Battery State Of Charge (SOC) LED:

One important parameter that defines the energy content of the battery is the State of Charge (SOC). This parameter indicates how much charge is available in the battery

A RGB LED is used to indicate the battery state of charge.For connection refer the above schematic

Battery LED ------------>Battery Status

RED --------------------> Voltage is LOW

GREEN --------------------> Voltage is Healthy

BLUE --------------------> Fully Charged

Load LED :

A bi color (red/green) led is used for load status indication.Refer the above schematic for connection.

Load LED --------------------->Load Status

GREEN -------------------------> Connected (ON)

RED ---------------------------> Disconnected (OFF)

I include a third led for indicating the solar panel status.

Step 11: LCD Display

To display the voltage,current,power,energy and temperature a 20x4 I2C LCD is used.If you do not want to display the parameter then disable the lcd_display() from the void loop() function.After disable you have indication led to monitor the battery and load status.

You can refer this instructable for I2C LCD

Download the LiquidCrystal _I2C library from here

Note : In code you have to change the I2C module address.You can use the address scanner code given in the link.

Step 12: Bread Board Testing

It is always a good idea to test your circuit on a breadboard before soldering it together.

After connecting everything upload the code.The code is attached bellow.

The entire software is broken into small functional block for flexibility.Suppose the user is not interested to use a lcd display and happy with the led indication .Then just disable the lcd_display() from the void loop().Thats all.

Similarly according to the user requirement he can enable and disable the various functionality.

Download the code from my GitHub Account

ARDUINO-SOLAR-CHARGE-CONTROLLER-V-2

Step 13: Power Supply and Terminals :

Terminals :

Add 3 screw terminals for solar input,battery and load terminal connections.Then solder it.I used the middle screw terminal for battery connection,left to it is for solar panel and the right one is for load.

Power Supply:

In my previous version the power supply for arduino was provided by a 9V battery.In this version the power is taken from the charging battery itself.The battery voltage is step down to 5V by a voltage regulator(LM7805).

Solder LM7805 voltage regulator near to the battery terminal.Then solder the electrolytic capacitors as per schematic.At this stage connect the battery to the screw terminal and check the voltage between pin 2 and 3 of LM7805.It should be near to 5V.

When I used a 6V battery the LM7805 works perfectly.But for 12V battery it heated up after some time.So I request to use a heat sink for it.

Efficient Power supply :

After few testing I found that the voltage regulator LM7805 is not the best way to power the arduino as it waste lots of power in the form heat.So I decide to change it by a DC DC buck converter which is highly efficient.If you plan to make this controller, I advice to use a buck converter rather than LM7805 voltage regulator.

Buck Converter Connection:

IN+ -------> BAT+

IN- --------> BAT-

OUT+ -----> 5V

OUT- -----> GND

Refer the above pictures.

You can buy it from eBay

Step 14: Mount the Arduino :

Cut 2 female header strips of 15 pins each.Place the nano board for reference.Insert the two headers according to the nano pin.Check it whether the nano board is perfect to fit into it.Then solder it back side.

Insert two rows of male header on both sides of nano borad for external connections.Then join the solder points between arduino pin and header pins.See the above picture.

Initially I forgot to add Vcc and GND headers.At this stage you can put headers with 4 to 5 pins for Vcc and GND.

As you can see I connected the voltage regulator 5V and GND to the nano 5V and GND by red and black wire.Later I removed it and soldered at the back side for better look of the board.

Step 15: Solder the Components

Before soldering the components make holes at corners for mounting.

Solder all the components as per schematic.

Apply heat sink to two MOSFETs as well as power diode.

Note: The power diode MBR2045 have two anode and one cathode.So short the two anode.

I used thick wire for power lines and ground and thin wires for signal.signal. Thick wire is mandatory as the controller is designed for higher current.

Step 16: Connect the Current Sensor

After connecting all the components solder two thick wire to the load mosfet's drain and upper terminal of load side fuse holder.Then connect these wires to the screw terminal provided in current sensor( ACS 712).

Step 17: Make the Indication and Temperature Sensor Panel

I have shown two led in my schematic.But I added a third led(bi color) for indicating the solar panel status in future.

Prepare small size perforated board as shown.Then make two holes (3.5mm) by drill on left and right( for mounting).

Insert the leds and solder it to the back side of the board.

Insert a 3 pins female header for temperature sensor and then solder it.

Solder 10 pins right angle header for external connection.

Now connect the RGB led anode terminal to the temperature sensor Vcc(pin-1).

Solder the cathode terminals of two bi color led.

Then join the solder points the leds terminal to the headers.You can paste a sticker with pin name for easy identifications.

Step 18: ​Connections for Charge Controller

Connect the Charge Controller to the Battery first, because this allows the Charge Controller to get calibrated to whether it is 6V or 12V system. Connect the negative terminal first and then positive. Connect the solar panel(negative first and then positive) At last connect the load.

The charge controller load terminal is suitable for only DC load.

How to run an AC Load ?

If you want to run AC appliances then you must need an inverter. Connect the inverter directly to the battery.See the above picture.

Step 19: Final Testing :

After making the main board and indication board connect the header with jumper wires(female-female)

Refer the schematic during this connection.Wrong connection may damage the circuits.So be care full in this stage.

Plug the usb cable to the arduino and then upload the code.Remove the usb cable.If you want to see the serial monitor then keep it connected.

Fuse Rating: In demo I have put a 5A fuse in the fuse holder.But in practical use, put a fuse with 120 to 125% of short circuit current.

Example :A 100W solar panel having Isc=6.32A needs a fuse 6.32x1.25 = 7.9 or 8A

How to test ?

I used a buck boost converter and black cloth to test the controller.The converter input terminals are connected to battery and the output is connected to the charge controller battery terminal.

Battery status :

Rotate the converter potentiometer by a screw driver to simulate different battery voltages.As the battery voltages change the corresponding led will turn off and turn on.

Note: During this process Solar panel should be disconnected or covered with a black cloth or card board.

Dawn/Dusk : To simulate dawn and dusk use a black cloth.

Night : Cover the solar panel entirely.

Day: Remove the cloth from the solar panel.

Transition : slow the remove or cover the cloth to adjust different solar panel voltages.

Load Control : According to the battery condition and dawn/dusk situation the load will turn on and off.

Temperature Compensation :

Hold the temperature sensor to increase the temperature and place any cold things like ice to decrease the temp.It will be immediately displayed on the LCD.

The compensated charge set point value can be seen on the serial monitor.

In the next step onward I will describe the making of enclosure for this charge controller.

Step 20: Mounting the Main Board:

Place the main board inside the enclosure.Mark the hole position by a pencil.

Then apply hot glue to the marking position.

Place the plastic base over the glue.

Then place the board over the base and screw the nuts.

Step 21: Make Space for LCD:

Mark the LCD size on the front cover of the enclosure.

Cut out the marked portion by using a dremel or any other cutting tool.After cutting finish it by using a hobby knife.

Step 22: Drill Holes:

Drill holes for mounting the LCD,Led indication panel,Reset button and external terminals

Step 23: Mount Everything:

After making holes mount the panels, 6 pin screw terminal and reset button.

Step 24: Connect the External 6 Pin Terminal :

For connecting the solar panel,battery and load a external 6pin screw terminal is used.

Connect the external terminal to the corresponding terminal of the main board.

Step 25: Connect the LCD, Indicator Panel and Reset Button :

Connect the indicator panel and LCD to the main board as per schematic.(Use female-female jumper wires)

One terminal of the reset button goes to RST of Arduino and other goes to GND.

After all connections.Close the front cover and screw it.

Step 26: Ideas and Planning

How to plot real time graphs ?

It is very interesting, if you can plot the serial monitor parameters (like battery and solar voltages) on a graph on your laptop screen.It can be done very easily, if you know little bit on Processing.

To know more you can refer Arduino and Processing ( Graph Example ).

How to save that data ?

This can be done easily by using SD card but this include more complexity and cost.To solve this I searched through internet and found a easy solution.You can save data in Excel sheets.

For details you can refer seeing-sensors-how-to-visualize-and-save-arduino-sensed-data

The above pictures downloaded from web.I attached to understand what I want to do and what you can do.

Future Planning :

1. Remote data logging via Ethernet or WiFi.

2. More powerful charging algorithm and load control

3.Adding a USB charging point for smart phone/tablets

Hope you enjoy my instructables.

Please suggest any improvements.Raise a comments if any mistakes or errors.

Follow me for more updates and new interesting projects.

Thanks :)

Tech Contest

Runner Up in the
Tech Contest

Microcontroller Contest

Runner Up in the
Microcontroller Contest

13 People Made This Project!

Recommendations

  • Casting Contest

    Casting Contest
  • Oil Contest

    Oil Contest
  • Woodworking Contest

    Woodworking Contest
user

We have a be nice policy.
Please be positive and constructive.

Tips

25 Questions

0

sir can i use 5 watt 6volt solar panel. please gudie me sir

Ciao

first of all, I apologize for my English! :-(

great idea and great project: thank you!

I have two questions for you: can you help me?

I am not an engineer, only an Arduino's fan and my knowledge in electronics is poor, so I apologize for the inaccuracies.

first question:

If I look the parts list, you write two mosfet IRF 9540, the circuit scheme tell the same number of misfit but I you look the photos, there are 3 mosfet (see the screen shot): can you explain me, please, what's the matter?

If I want to recharge 3,7 volts battery, what changes must be made to the circuit?

thank you for your attention

Michele

Schermata 2018-05-21 alle 17.43.51.pngSchermata 2018-05-21 alle 17.45.37.png

Hi Michele, That 4th TO220 device is the 7805 voltage regulator, that takes in battery voltage (12V) and puts out the regulated 5V supply for the Arduino, ACS712, LEDs etc.

Keith

2 more answers

Thank Keith for your complete answer, but I have a doubt: in the image I have attached, I see 4 component: 1 diode, 2 mosfet and...

Can you help me, please, to find the answer?

FVR401TI1FQ7KI7.LARGE (1) copia.jpg

Hi Michele,

The 3 TO220 packages you can see in your photo are 2 MOSFETs and 1 diode (the MBR2045, D1 in the schematic). Physically the diode looks the same as a MOSFET - it even has 3 leads, because this part is actually MBR2045CT which means it is 2 diodes in the same package. See Step 15.

This circuit is designed for either a 6 volt or 12 volt lead acid battery. It can be adapted to other voltages, but not as low as 3.7 Volts. If you want to charge a 3.7V Lithium battery, I suggest the best way is to build the circuit for either 6 or 12 volts, and add an additional battery charging circuit for your Lithium battery.

I think the best way is to use a small buck converter which you can adjust for an output of around 4.5 volts or so, and a TP4096 Lithium battery charging board.

Or you can connect a small solar panel directly to the TP4096 charging board. See this Instructable for how to go about this. https://www.instructables.com/id/Solar-Powered-WiF...

Of course these suggestions are only appropriate for small size Lithium batteries - like AA or 18650 size. If you have a very large 3.7 Volt battery, you will need a different solution, but you still cannot use this PWM charging circuit directly because 3.7 volts is not enough to turn on the charging MOSFET.

Keith

hello sir i am also doing the same proeject but there is some modification like i should use 230v suplly also means whenever the solar battery gets low then automaticaly battery should get charge from the 230v supply using dc converter. so i am not getting how switch automaticaly from solar to supply if you suggest me or if you give some details it will be very helpfull for me.....

Hi sunita patil,

I think you need to think carefully about the logic you use to connect and disconnect the mains supply.

You can find an example of the sort of hardware connections required in this schematic:

https://github.com/farmerkeith/SolarCharger20AmpAs...

The bit you need to look at is in the middle part of the diagram. The key components are Q8 and Q9 and the control from Arduino Pin D3 (which can of course be any pin you choose). You can replace the 230V transformer and rectifier with an AC adapter of suitable output voltage and current capacity for your needs.

If this is not clear feel free to ask more.

0

Hi sir, after connecting the battery (without PV panel), the result shows the current is negative. Also, the voltage of solar side is not equal to 0V. Please help me. Thank you

IMG-4327 (1).JPG

Hi Ben_21,

I think the panel voltage of 0.67 volts is there because of a little bit of reverse leakage current through the MBR2045 diode, and is not a concern.

As for the -0.55 Amps of load current showing, and assuming you do not have any load connected, it must be the calibration point of the ACD712 needs adjusting.

The ACS712 puts out Vcc/2 on its data pin when the current is zero. This should be 2.5 volts when the Vcc is 5 Volts. The calibration point is set in the software in line 158 (in my copy) which reads "load_current = (read_adc(CURRENT_ADC)*.0488 -25);"

The literal value 25 represents the offset current. If you are getting -0.55Amps, and you adjust that literal value to 24.45, you should get a reading of 0 when there is no current.

So now the line will read: "load_current = (read_adc(CURRENT_ADC)*.0488 -24.45);"

There are "better" ways to do this, from a software usability perspective, However this is the minimal change that should get you a good result.

Incidentally, the scaling constant, set at 0.0488, should really be 0.048828. I don't think the difference is significant, but you could make the correction at the same time.

Please report back if this solves your issues.

Hi sunita patil, you can find the schematic diagram at the end of Step 2. There is a link there where you can download the pdf. If you have trouble with the link, please ask again.

sir, please suggest me which watt of solar panels and battery also use in version 2.0.....please sir..a

Hi bipul027, In Step 1, the author specifies battery voltage of 6 or 12 Volts and current of up to 10 Amps. I am a bit doubtful about using it for 10 amps, because the MBR2045 power diode will be dissipating about 10 Watts at that current. I think a more prudent limit for a project that will keep working for a long time would be more like 5 amps.

The rated maximum power point voltage of your solar panel has to be about 40% higher than the battery voltage - 17 V for a 12V battery, or 8.5V for a 6 V battery.

So, using a limit of 5 Amps and a battery of 12 Volts, your solar panel should be up to 5*17=85 Watts. If you are using a 6V battery, your solar panel can be up to 42.5 Watts.

You can probably get away with somewhat higher panel ratings if you live in a climate where perfectly clear days with bright sunlight are unusual.

The storage capacity of your battery can be as high (or as low) as you like. That just determines how long it can supply the load current when the sun is not shining.

Hi TeddyGG, I am sorry to hear you have some problems. I don't know for sure but I think it is likely that the little buck converter (just to the right of the Nano) is responsible for your measurement of 68 K instead of 100 K. Another possibility is that, with the Nano removed from its socket, that the D2 and D3 pins are floating and may get a little bit of current from thermal noise and allow a few electrons to flow through R6 and/or R8. I don't think this is your main problem.

It is not really possible to check your connections from the photos, even though they are quite clear. I think you need to do the following:

a) check your wiring with a multimeter to make sure that nothing is shorted to ground that should not be.

b) with the Arduino Nano out of its socket and the ACS712 disconnected, connect the batery to the battery terminals and check that its 12V appears in the right places. Also check that the buck converter is putting out 5V, and adjust it if not. It may be worth while also pulling out the fuses, checking the voltages on the fuse terminals, then replacing the fuses.

c) you can also check the functioning of transistor T2 by connecting the driver terminal D2 to ground (to turn the transistor off) and +5V (to turn the transistor on). If you have a 12V light bulb you can connect to the load terminals that may help your testing.

d) if all the above tests are OK, it should be safe to put in a working ACS712.

e) if that is all OK, you should measure the voltages on all the Arduino pins, to make sure they make sense. Then you should be OK to put in your (working) Arduino.

I hope you can find the problem.

How we can add into this code, fully charging time and discharging time according to load?

Hi victory282,

I understand you want to calculate and display on the LCD the estimated time to the battery being fully charged (when it is being charged) and the estimated time to the battery being fully discharged (when it is being discharged).

These things are possible, at least as an approximation, but are not just a matter of software.

Hardware: In the schematic v2.0 the current meter module (ACS712) is in the path between the load control MOSFET and the output fuse. In this position it can measure the load (discharge) current but not the charging current. This means that you can get an estimate of discharge time to empty, but not charge time to full. Either you have to add a second current meter module to measure the charging current, or move the existing one into the path to and from the battery. If you move it to this position, it can give you positive current for charging, or negative current for discharging. That seems to me to be the best approach.

Software: Quite a few things need to be added. You need a function that calculates battery state of charge (SOC) based on the battery voltage and the current into or out of the battery. Then you need a constant for the capacity of the battery in amp-hours (AH), and (probably) a SOC value that you will consider to be "fully discharged". This is because if you discharge thte battery below about 30% SOC it is likely to affect its life, so you could consider something like the 30% discharge point as being fully discharged. This is a matter of how you want to use the displayed value.

Given these things, the time to full charge when charging is

(100%-SOC%)*AH/100/Current (result in hours)

Similarly, the time to full discharge when discharging is

(SOC%-30%)*AH/100/(-Current) (result in hours)

Finally, you need to figure out what the LCD display should look like. The existing software uses all the spaces on the display, so you will need to give up something, or alternate between different display modes. If you want to alternate, you could do it using a timer, or you could add a button to switch between the alternatives (another hardware change).

I hope this gives you an idea of what is involved. If you want to do it, I can give you support with any problems you may encounter. Please let me know what you decide to do.

1 more answer

Hi victory282, I find your question a bit hard to understand. The answer will depend on exactly what you want to do. In the software you will see there are calculations of amp hours and watt hours, and the watt hours are displayed on the LCD and also on the serial monitor when connected. Can you clarify what you want to display, and where?

Hi sir, I made the circuit using Arduino uno.
I am having some troubles with it.The lcd is showing load current even though the load is not connected & the value of current displayed is in negative.
Please help me.

Hi ashks, It should work with a Uno.

I think there is some connection problem with your ACS712 for measuring the load current. Use your multimeter to check that you have +5v and Ground connected to the correct pins on the ACS712. Then check that you have 2.5V on the data pin, and also on pin A2 of your Uno.

hi sir, i got the problem with the circuit. When i connect the circuit, i already got 2-5v and i do not know where it come from. I connect my circuit with the battery, then i got higher than measurement using multimeter. Please help sir.tq

IMG_20180415_230848.jpgIMG_20180415_230711.jpgIMG_20180415_232653.jpg

590 Comments

sir can i use 5watt 6v solar panels...... please provide me full rating of solar panels...plz sir

Hello,
I apologize for my English and I congratulate for the job.
I built my regulator and it seems to work well, but when the voltage
reaches 14.4 and the duty cycle goes to 0 the voltage drops suddenly. At this point the duty increases and the voltage on the battery also reaches 14.8 or 15 volts. What are these peaks for? is it possible to solve?
Thanks for your help

2 replies

Thanks for the reply. But there is still doubt if this creates any damage to the battery, the maximum voltage should not be 14.4? is there a way to avoid these sudden peaks? thank you

same here!... as battery voltage is less than solar.. pwm goes to 255... due to this battery voltage get read as 15v... therefore pwm goes to 0...

I have found with charge controllers that the problem is sensing the present battery voltage correctly. It needs to be switched off for at least half an hour and then measured . Have you made any allowances for this or do you think instant measurement is sufficient ?

3 replies

Hi tytower, the purpose of measuring the battery voltage is to decide the charging rate, so as to avoid overcharging. The battery voltage rises when under charge, but that does not invalidate the decision making process.

A battery on charge does not reflect its actual charge until the charger is turned off for at least half an hour so the battery can stabilise. The microcontroller can read a voltage on the battery with or without its charging process being on . If it is on then the reading will be the voltage of the charger. If the charger is off for a few tenths of a second then the battery will show its actual voltage if there are no other components on the line . it will be much higher than a stable voltage obtained in half an hour.

unsigned long readTime = 0;
unsigned long readDelay = 2000;
void READ_ADC_DATA(void) {
//I SET THIS TO READ ONE A SECOND PASS. NOT MUST SHOULD CHANGE IN A SECOND.
if ((millis() - readTime) > readDelay) {
// reset the debouncing timer
readTime = millis();
//I SWITCHED SOLAR OFF IN THIS FUNCTION TO GET A MORE PRESIZE READING
//ON THE BATTERY. IT HAPPENS VERY FAST
analogWrite(PWM_PIN, 0);

delay(2);
//3.3v = ADC value 4095 => 1 ADC value = (3.3/4095)Volt= 0.805861Volt
// Vout=Vin*R2/(R1+R2) => Vin = Vout*(R1+R2)/R2 R1=1m and R2=15k
solar_volt = read_adc(SOL_ADC) * 0.86695 * (1015 / 1000) / 100;
bat_volt = (read_adc(BAT_ADC) * 0.86695 * (1015 / 1000) / 100) + 0.7; //0.7 for diode

if (atmega) analogWrite(PWM_PIN, duty);
else pwmWrite(PWM_PIN, duty);
}
}

HI CAN I EMAIL YOU CODE. ITS FOR STM32F1 AND ATMEGA. AND I CHANGED YOUR CODE A LITTLE TO GET BETTER BATTERY READING. WELL IT WORK FOR ME.

can anyone explain difference btw LM317 and Arduino controller

1 reply

Look them up man . Arduino is a computer with memory

When you have three components in your component, IRF 9504 and MBR2045, you wonder why you have four complete products and why you need them more.

1 reply

Hi av1483110, your comment is a bit puzzling. In the circuit there are 2 MOSFETs IRF9504 and one power diode MBR2045. They all have a function, which I can explain if that is your question.

when i am connecting D3 pin of arduino to the 1 k resistance as mentioned in circuit, i am getting only 2 V across battery terminal instead of 12v what should i do. also i am getting 12 volt across source and gate of first power mosfet (MBR9540).

IMG_20180320_131949.jpgIMG_20180320_131920.jpg
3 replies

Hi PrakashC19, I have had a good look at your photos. It is a bit hard to be sure, but I suspect there are some wrong connections.

Also you say in your message "first power mosfet (MBR9540)". The connection from the solar panel goes from the fuse, to the power diode MBR2045, and then to the mosfet IRF9540. There is no such thing as MBR9540.

From the fuse the connection goes to the MBR2045 pins 1 and 3.

Then from the MBR2045 pin 2 the connection goes to Pin 3 of the IRF9540. Looking at the IRF9540 with the tab to the back, the source is the right-most pin.

The collector of T1 goes to the Gate, which is the left-most pin of the IRF9540.

I hope this helps. Good luck. Please post again with results of your checking.

Use 2N2222 transistor instead of N3904 you may get the results. Even I have faced the same problem when i replaced the transistor i got the results

Can i use your design for my project, but this time i need to use windmill as source of my project. If not compatible can you teach me how to do? thanks in advance.

1 reply

Hi KentG26, The charger should work with a windmill just the same as for a solar panel.

Hy, I'm Giacomo from Italy

i'm tryng to realize my own solar panel regulator, so i'm very happy to compare my creature with your. THANK YOU SO MUCH FOR YOUR SHARING !!!!!!

when i'll finish i'll send you my project