Development of an Algorithm Based on a Mechanism for Managing the Charge and Discharge of Lead Acid Batteries to Optimize the Solar Energy Produced in Burundi ()
1. Introduction
In the context of sustainable development, in response to the dual global challenge posed by the depletion and future of fossil energy resources, solar energy is considered to be the source of the majority of energy. To harness solar energy, batteries are needed to store the energy. Since the first development of a rechargeable lead-acid battery by Gaston Planté in 1859, batteries have revolutionised the way energy is stored [1]. Several authors have carried out different studies on battery charging and discharging systems. [2] USA shows a fuzzy logical-based state-of-charge meter for li-ion batteries used in portable defibrillators and [3] describe the fuzzy logic-enhanced electrochemical impedance spectroscopy to determine battery state of charge. They develop a fuzzy logic based smart battery controller for automotive batteries. [4], in his study, presents an overview of next-generation BMSS. [1] and [5] of Quebec City find that estimating a battery’s state of charge helps keep a battery in good condition to avoid any deterioration problems due to too high a temperature or too high or too low a charge/charge voltage. According to [6] and [7] Saudi Arabia, BMS varies from application to application. It is a management system that monitors, controls and optimises the performance of an individual or multiple battery modules in an energy storage system. According to [8] during the charge/discharge cycle of a battery, heat is generated inside the battery. This phenomenon causes an increase in the temperature at the surface of the battery and consequently accelerates its aging in France. [9] detailed the challenges of developing a new battery operating system suitable for future applications and described the details of some of the solutions he has developed. [10] Show the comparison of life prediction models for lead-acid and Li-Ion batteries in stand-alone photovoltaic systems in Spain.
[11]-[13] describe the state of the art of lead acid solar batteries and their regeneration. The best lead-acid solar batteries can achieve a service life of between 7 and 15 years, and lead-acid batteries can be recycled. [14] describe how impedance measurements, combined with fuzzy logic data analysis have been used to estimate the SOH of lead acid batteries used in portable defibrillators. [15] has carried out research into optimising the life of lead acid batteries. For him, the State of Charge (SOC) is an indication of the level of charge of a battery in percentage. It is important to understand that the State of Charge of the battery is the opposite of the Depth of Discharge. Depth of Discharge (DoD) indicates the stage of discharge of the battery. [16] study fuzzy logic based determination of Lead Acid battery state of charge by impedance interrogation methods. Burundi has already started using solar energy. For the photovoltaic (PV) fields already installed, only two are grid-connected photovoltaic systems without batteries. The others are photovoltaic systems with lead-acid battery storage. We note that battery ageing and temperature have an influence on battery charge. We also found that for different periods of the year, depending on the season, the sized batteries could be fully charged as long as the sun is shining. On the other hand, during the rainy season, it is difficult to charge all the batteries. Figure 1 shows how batteries are stored in a closed room.
![]()
Figure 1. Photo of the battery storage site for the PV system installed at Bugendana Parish.
In this case, the temperature in the room may exceed the threshold temperature of the batteries. This leads to a considerable loss of energy, which could be recovered by an automatic system.
Hypothesis 1: There is a way of recovering the energy lost when the battery is fully charged by developing an intelligent microcontroller mechanism that can manage the charging and discharging of several batteries in a photovoltaic system.
Hypothesis 2: It is possible to manage the charge, discharge, overcharge and temperature of a battery using a microcontroller.
The aim of this project is to develop an algorithm based on a battery charge and discharge management mechanism for the optimization of photovoltaic energy using a microcontroller. We will develop an algorithm based on a cascade battery charge and discharge management mechanism using a microcontroller, develop a temperature control algorithm, design a cascade battery charge and discharge control circuit, design a temperature control circuit and finally carry out an experiment using a prototype.
2. Method and Materials
In this section, we will develop the methodology to be used and the components required. Taking into account the problem raised, the methodology consists of developing an algorithm for managing the state of charge/discharge of two groups of batteries in cascade with temperature control. The technique involves dividing all the batteries obtained using the photovoltaic system sizing method into two groups. The first group of batteries is called battery 1 (Bat1) and the second group is called battery 2 (Bat2). We will use the DHT11 temperature sensor to monitor the temperature and a fan for air conditioning.
The technique involves cooling the battery to an operating temperature of 25˚C to ensure a battery life of 15 years because if the temperature reaches 25˚C, it is a high temperature [14] [15]. We will design a program with Arduino IDE (Integrated Development Environment) software whose control and command element are Arduino UNO. The control and command circuit will be designed using Proteus Professional v8.10 SP3 software. The method also involves designing the algorithm developed using MATLAB2020a software and comparing the results with those obtained using the Arduino IDE and Proteus software [17]. Figure 2 illustrates the block diagram of the system under study.
Figure 2. System block diagram.
Figure 3 shows algorithm for the battery charge and discharge management system with temperature control.
Figure 3. Algorithms of battery charge and discharge management system with temperature control.
where, VBAT1 MIN: Minimum battery voltage 1, VBAT1: Battery voltage 1, VBAT12 MAX: Maximum battery voltage 2, VBAT1: Battery voltage 2, VBAT2 MIN: Minimum battery voltage 2, VBAT1 MAX: Maximum battery voltage 1.
2.1. Photovoltaic Generator
In another way, when a semiconductor is illuminated by sunlight, a free electron-hole bond circulates in the material. Under the effect of the electric field, the electron goes to the N side and the hole to the P side. The holes behave in different ways, like particles with a positive charge equal to that of the electron. The potential difference can be measured between the positive and negative terminals of the cell. The maximum cell voltage is approximately 0.6 V at zero current. This voltage is known as the open circuit voltage (VCO). The maximum current produced is called the short-circuit current (ICC) [18].
2.2. Charge Controller MPPT
Charge Controller MPPT prevents overcharging and excessive discharging of the battery. In the case of lead-acid batteries, overcharging is prevented by charging the batteries in three stages (bulk, absorption, or boost and float).
2.3. The Microcontroller Arduino UNO
The microcontroller is a microprocessor-type information processing unit to which internal peripherals have been added to facilitate interfacing with the outside world without requiring the addition of external components. With the Arduino board, we can write programs, create interface circuits and develop algorithms to control switches, sensors, etc.
2.4. The Switch
In this study, we will use relay. A relay is a pre-actuator consisting of at least an electromagnet, a moving leg supporting the moving contact, a fixed contact and a moving contact return spring. By energizing the coil from an electrical source, the moving contact is moved, thus closing the electrical contact.
2.5. DHT11 Temperature Sensor
The DHT11 sensor is a module for detecting the temperature and a microcontroller can process the humidity of an object that sends an analogue voltage output. Compared with other types of sensors, it is more responsive, quickly detects the temperature and humidity of objects, and does not easily disturb the data read.
2.6. Battery
A solar battery is a device designed to store the electrical energy produced by photovoltaic solar panels. The current entering or leaving the battery is necessarily direct current (DC) and not alternating current (AC) as in the domestic electricity network.
2.6.1. Battery Modelling
Lead-acid batteries are the most widely used storage element in photovoltaic systems. The main function of lead-acid batteries is to store and supply energy in a PV system. The stored chemical energy can be converted into electrical energy and vice versa. Electrochemical reactions are described by the following reactions [19].
(1)
The expression that describes the behavior of battery voltage is:
[19] (2)
where, Voc is the open circuit voltage, I is the battery current and R is the internal resistance of the battery.
The charge/discharge models of Lead-Acid battery are given by Equation (3) and Equation (4).
[20] (3)
[20] (4)
Where: Vbat is battery voltage (V), V0 is battery constant voltage (V), K is polarisation constant (V/Ah), C = battery capacity (Ah), it is actual battery charge (Ah), A is exponential zone amplitude (V), b is Exponential zone time constant inverse (Ah−1), R is internal resistance (Ω), Rpol1 is polarisation resistance when i > 0, Rpol2 is polarisation resistance when i < 0, i is battery current and i* filtered current. The battery current i and the filtered current i* are equal [20].
The polarisation resistance in discharge mode is given by Equation (5)
[20] (5)
The polarisation resistance in charge mode is given by Equation (6):
[20] (6)
The exponential voltage of the Lead-Acid battery is given by Equation (7):
[20] (7)
where, Exp(t) is the exponential zone voltage (V), is the battery current (A), u(t) is the charge or discharge mode. The exponential voltage depends on the initial value of Exp(t0) a u(t) = 1 in charge mode or u(t) = 0 in discharge mode. When the battery is fully charged, the battery’s real charge is equal to zero (it = 0). In this case, the battery voltage begins to drop. The charge continues to overcharge the battery (it < 0). The decrease in voltage is due to the decrease in polarisation resistance. When it = 0 (battery fully charged), the polarisation resistance is infinite [20].
The discharge voltage equation is given by the following expression:
[19] (8)
The charge voltage equation is given by the following expression:
[19] (9)
The temperature variation is given by:
[19] (10)
We know that the expression that describes the thermal effect on resistance is:
(11)
2.6.2. Battery SOC
The state of charge (SOC) is an indication of a battery’s charge level, expressed in percentage. Several techniques are used to estimate the state of charge of the battery (SOC). The techniques are [14] [21]:
Coulomb counting
Voltage recovery
Impedance
Various mathematical methods of estimation are classified according to methodology in the various literature:
Direct measurement: this method uses physical battery properties, such as the voltage and impedance of the battery.
Book-keeping estimation method: this method uses discharging current as the input and SOC.
Adaptive systems method: the adaptive systems method is self-designing and can automatically adjust the SOC for different discharging cases.
Hybrid methods: hybrid models benefit from the advantages of each SOC estimation method and allow a globally optimal estimation performance.
In this project, using the Coulomb-counting method, the state of charge is given by Equation (7) [9]:
(12)
i > 0 in charge, i < 0 in discharge
where,
is the previous state of charge and i is the battery current.
2.6.3. Voltage Divider Bridge
Figure 4. Voltage divider bridge.
The voltage applicable to the microcontroller is approximately 5 V. In this case, a voltage rectifier bridge must be added to adapt the voltage of the battery bank to the input of the Arduino microcontroller. Figure 4 illustrates the voltage divider bridge.
We apply the voltage divider law, and the expression is:
(13)
In our case, VBAT = 14 V, R1 = 33 KΩ and R2 = 57 KΩ.
(14)
When the battery is discharged to a SOC of 80% of its rated capacity, we have VMIN = 11.2 V. Converting VMIN into binary corresponds to 818.4.
2.6.4. The Ageing of Batteries
The aging of a battery is directly linked to the conditions in which it is used. It depends essentially on the number of charge-discharge cycles. To achieve a service life of 10 to 15 years, the battery must be kept in a state of charge of more than 50%. In this research, the algorithm developed maintains the state of charge of the battery at a SOC of 80% to reduce the aging of the battery. The aging of lead-acid batteries is determined by the following three factors [22]:
The first factor is cyclic life and resistance to high temperatures, which are present in all battery applications.
The second factor is the effects of sulphation and under-charging, which are only specific to PV applications.
The third factor is catastrophic factors, such as manufacturing defects, undersizing, misuse, deep freezing, etc., which can often be avoided.
High overloads cause corrosion, deformation, erosion of the plates, and overheating, and they can lead to the coalescence of the Pb particles with a consequent loss of porosity.
2.7. Centrally Managed Multi-Inverters
This type of architecture will allow great flexibility in the maintenance and management of the installation’s uptime by using only the number of inverters required. This management also ensures that the inverters are used at their optimum power depending on the amount of sunlight. Figure 5 illustrates the architecture of centrally managed multi-inverters.
Figure 5. Multi-inverter architecture with centralised management.
2.8. Model Assumptions
Internal resistance is assumed to be constant during charge and discharge cycles and does not vary with current amplitude.
The model parameters are derived from the discharge characteristics and are assumed to be the same as those in the model.
Battery capacity does not change with the current amplitude (no Peukert effect).
3. Results and Discussions
3.1. Simulation Results
In this section, we describe the design of the system studied and the results obtained by simulation using MATLAB software, Arduino IDE software and Proteus. Based on Equations (3)-(8), the block diagram for modelling the lead acid battery using MATLAB software is shown in Figure 6. The SOC is calculated using the Coulomb counting method.
Figure 6. block diagram for modelling the lead acid battery using MATLAB.
Figure 7. Battery discharge.
For K = 0.0058935; A = 1.0154; V0 = 12; V = 2.0354; C = 30; R = 0.073 and SOC0 = 100. Simulation results in discharge mode are shown in Figure 7.
From the SOC and Vbat variation curves, we can see that the battery is discharged to a SOC of 90.32%, corresponding to a battery discharge voltage of 12.65 V. The discharge current is also negative, which shows that the battery is in discharge mode (ut = 0). For K = 0.0058935; A = 1.0154; V0 = 12; V = 2.0354; C = 30; R = 0.073 and SOC0 = 90.32. Simulation results in charge mode are shown in Figure 8.
Figure 8. Battery fully charged.
Figure 9. Influence of the thermal effect on resistance.
The simulation results show that the battery is in charge mode (ut = 1). We can see that the battery is fully charged (VAB = 14 V) with a state of charge of 100% and that it = 0. The polarisation resistance is infinite, as the theory states. Figure 9 illustrates the Effect of temperature on resistance.
From the variation curve, we can see that when the temperature increases, internal resistance also increases. We also know that heating metal increases its electrical resistance. Figure 10 illustrates the Effect of temperature on battery voltage.
Figure 10. Effect of temperature on battery voltage.
We found that the voltage decreased when the temperature fell below 25˚C. At temperatures above 25˚C, the voltage increases. So, if the voltage drops, this also affects the battery’s SOC. Figure 11 shows the influence of temperature on the battery’s capacity.
Figure 11. Influence of temperature on the battery capacity.
We note an increase in discharge capacity as the SOC decreases. If the discharge capacity increases, this indicates that the battery capacity is decreasing. When the battery is at a temperature below 0˚C, the resistance of the sulphuric acid solution will continue to increase, the polarization effect, reducing the capacity of the battery. Consequently, when the state of charge decreases, the depth of the battery increases, causing the battery to age. For K = 0.00004308; A = 1.889; V0 = 12.16; B = 0.3053; C = 30; R = 0.0006, Figure 12 illustrates the influence of battery discharge current on the battery voltage.
Figure 12. Influence of battery discharge current on the battery voltage.
Simulation results show that the voltage decreases rapidly as the current increases.
Figure 13 illustrates the design of the battery charging and discharging system algorithm with temperature control using MATLAB software.
Figure 13. Design diagram of the battery charging and discharging system algorithm with temperature control in MATLAB software.
We began to design the algorithm developed using MATLAB Simulink for a State of Charge (SOC) of 80% corresponding to a minimum voltage of discharge of 11.2 V. Figure 14 shows the simulation results of the algorithm developed using MATLAB software.
In the range [0, 3], SOC_BAT1 = SOC_BAT2 = 70%, Battery 1 is prioritized at the HIGH level indicating charging mode and Battery 2 at LOW level, indicating the discharging mode. Interval [3, 6] SOC_BAT1 = 100% and SOC_BAT2 = 70%, battery 1 is at LOW level indicating discharge mode and battery 2 is at HIGH level indicating charge mode. From interval [6, 8.5], SOC_BAT1 = SOC_BAT2 = 100%, batteries 1 and 2 are at the LOW level for discharging and the DC loads are at the HIGH level for charging mode. At the interval [8.5, 10], SOCBAT1 decreases below 80%, and SOC_BAT2 = 100%, so battery 1 is activated for charging mode. On the temperature control side, in interval [3, 6], the temperature is above 25˚C, a HIGH level is detected indicating a high temperature while for the interval [6, 10] the temperature is below 20˚C, and a low frequency is detected. Figure 15 illustrates the designed and simulated algorithm of the battery charging and discharging system with temperature control using Arduino IDE software and Proteus software. We have fitted LEDs to indicate the operating status of the battery charge or discharge system for each switch.
![]()
Figure 14. Variation curves for the state of charge and discharge of batteries with temperature control.
(a)
(b)
Figure 15. Designed and simulated diagram of the battery charge and discharge management system with temperature control: (a) Battery 1 in charge, Battery 2 full charge. (b) Battery 1 full charge, Battery 2 full charge, DC LOAD in charging and FAN_CONTROL1 activated for temperatures above 40˚C.
The simulation results show that if battery 2 is fully charged, the Arduino microcontroller receives an analogue signal at the voltage divider bridge from the first grouping of batteries. This analogue signal is converted into a digital signal by the Arduino microcontroller, which sends a command to switch relay 1 across pin 8 to charge the first battery (Figure 15(a)). Once the first group of batteries has been charged, the microcontroller opens the contact of relay 2 and sends a command to close relay 2 via pin 10 to charge the second group of batteries. Once all the batteries are charged and the sun is still shining, the Arduino microcontroller sends a command via pin 12 to close relay 3 to charge other DC electrical loads (Figure 15(b)). Also, if the local temperature exceeds the battery’s operating range, the microcontroller sends a signal to close relay 4 or relay 5 for air conditioning. We can see that the simulation results obtained using Proteus and MATLAB Simulink software match.
3.2. Experimental Results
This part is devoted to the practical implementation of the battery charge/discharge management system combined with a temperature control system for the algorithm developed. We used an experimental set-up consisting of two batteries (6FM-7AH (12V7AH/20HR)), Rechargeable Sealed Lead-acid battery, Cycle; use: 14.5 - 14.9 V (25˚C); Initial current: less than 2.1 A; Standby use: 13.6 - 13.8 V (25˚C), an Arduino board, two potentiometers, four resistors, two voltage divider bridges, connection cables, four relays, four LEDs, a DHT11 temperature sensor and a test plate. In this study, the LEDs will be powered if the relay is activated for each test of the algorithm developed. Figure 16 and Figure 17 show the assembly of the developed algorithm using arduino IDE software.
Figure 16. Battery 1 charging indicator.
Figure 17. Battery 2 charging indicator.
From the experimental results, we can see that for a discharge of 80% of the rated capacity, relay 1 is activated to charge battery 1 (VBAT1) first. If the first group of batteries is charged, relay 2 is activated by the Arduino UNO microcontroller to charge battery 2. In addition, if all the batteries are 100% charged, relay 3 is activated by the Arduino UNO microcontroller to charge other DC electrical loads. For temperature control, if the temperature exceeds 25˚C, relay 4 is activated for fan conditioning.
Figure 18 shows the display of the experimental results of the algorithm studied using the serial monitor.
We transferred the experimental results to Excel using the Plx_DAQ application. Figure 19 shows the variation in temperature and humidity as a result of temperature and humidity saved in Excel.
Figure 18. Displaying results using the serial monitor.
Figure 19. Temperature and humidity variation curves obtained by Plx_DAQ on date 7/11/2024.
From the temperature and humidity variation curve, we can see that if the temperature increases, the humidity decreases and vice versa. The measured values of temperature using DHT11 are between 23˚C to 27˚C. Based on the measured values on 7/11/2024, we can see that the temperature was high. According to the operating range of the lead-acid battery, we note that the battery requires air conditioning, because we see that the minimum temperature obtained by experimentation is over 25˚C.
4. Discussions
[3] [5] [6] [11] and [12] have developed algorithms for managing the charge and discharge of a single battery, showing the importance of each method used and its performance. Our novelty focuses on the development of an algorithm for managing the charging and discharging of batteries in a solar system in order to optimize the energy produced, using an Arduino microcontroller. The algorithm developed also performs well on the state of charge and discharge of the battery and contributes to good optimal management of the solar energy produced using the algorithm developed compared to the existing solar installation kit. The algorithm developed enables the life of a battery to be maximized by managing the state of charge at a minimum value of 80%, corresponding to a battery depth of discharge of 20%. The algorithm developed also manages temperature, which has a negative effect on battery capacity and internal resistors. At high temperatures, increasing the service current accelerates the build-up of overcharge; at the same time, it also accelerates the rate of corrosion of the grid and the generation and precipitation of gases, thus shortening the aging of the battery. [15] reveals that a battery depth of discharge of 20% corresponds to a maximum number of battery cycles of 8500. This author indicates that as the depth of discharge increases, the number of battery cycles decreases, which has an impact on reducing the life of a battery. [14] describes how impedance measurements combined with fuzzy logic data analysis have been used to estimate the state-of-health (SOH) of lead-acid batteries.
The algorithm of the mechanism developed disconnects the battery from the load when the voltage exceeds the minimum value. With the algorithm we have developed, it is possible to recover the energy lost as a result of the problem of charging and discharging the batteries that are lacking in the various solar fields in Burundi. We designed and simulated the algorithm we developed using MATLAB software and then the Arduino IDE and Proteus software for comparative study. We found that the simulation results obtained with Proteus and MATLAB Simulink were the same. The battery charge and discharge management system algorithm that was developed can be used to manage the charge and discharge of a single battery bank with a direct power supply to the other DC loads. In this case, the DC loads will have to be connected directly to the space to charge the second battery bank. We note that the simulation results using Proteus and MATLAB Simulink software and the experimental results are matched, which shows the effectiveness of the algorithm developed.
5. Conclusion
The exploitation of renewable energies as part of sustainable development began with research into fossil and nuclear energies. Batteries (accumulators) have now become a solution for storing energy, which can be recovered in the form of energy produced by discharging or by regeneration through a charging phase. In this project, we showed the different research works on the management of charge and discharge of batteries studied by different authors with different methods. It was noted that it is important to know the state of charge and discharge of a battery in different applications. We have shown the different cases that cause energy losses from batteries in a photovoltaic system. We have modelled and simulated the lead acid battery. We have shown the simulation results for the charging and discharging of the battery. We found that if the voltage decreases, the battery’s state of charge also decreases. Based on the simulation results, we showed the effect of temperature on the voltage and internal resistance of the battery, as well as its effect on the aging of the lead acid battery when the DoD Exceeds 20%. We presented the factors that influence the lifetime of a lead-acid battery in a solar system.
We have developed an algorithm based on a mechanism for managing the charge and discharge of two groups of batteries for optimum management of the solar energy produced using an Arduino UNO microcontroller. We designed and simulated the algorithm developed using MATLAB2020a software, then Proteus software and the Arduino IDE software. We ended with an experimental study using a prototype. We note that the battery requires air conditioning, because we see that the minimum temperature obtained by experimentation is over 25˚C. The simulation results using Proteus, Arduino IDE, MATLAB Simulink and the experimental results are matched, demonstrating the validity and effectiveness of the algorithm developed.
In relation to novelty, this project contributes to the implementation of an automatic mechanism for optimally managing the solar energy produced, based on a system for managing the charging and discharging of batteries using an Arduino microcontroller.
Given that the current solar kit is not equipped with this mechanism, the importance of the system studied is that it allows the recovery of lost energy and the optimal management of the solar energy produced with the Internet of Things (IOT). The system developed is applicable to other applications requiring energy storage in batteries for optimum management of electrical energy.
The results of this project will be a good reference for the study of the gain of the solar tracker compared to the fixed solar panel for the future project of integration of solar tracker with battery management in Burundi supported by an Erasmus+ grant and the doctoral school of Burundi.
Acknowledgements
Erasmus+ and Doctoral School of Burundi supported this project.
Authors’ Contributions
Bukuru Denis: Conceptualization, Methodology, Supervision, Project administration, Validation, Writing—review and editing;
Pritpal (“Pali”) Singh: Conceptualization, Methodology, Supervision, Project administration, Validation, Writing—review and editing;
Niyonzima Jean Bosco: Supervision, Project administration, Writing—review and editing, Validation;
Ntawuhorakomeye Noel: Supervision, Project administration, Writing—review and editing, Validation.