1 Introduction

Energy is the development of any country engine. It generally comes from fossil sources that are endangered and renewable (clean) whose use is becoming more and more numerous. Among the clean energy, photovoltaic (PV) technology is the most used. Today’s power plants are either stand alone or be connected to the Electrical Distribution Network (EDN). The electrical characteristics (current-voltage) of GPV are sensitive to changes in atmospheric conditions. The use of the storage system (eg battery) is often essential. The battery is facing phenomena overload and underload [1]. The transfer of energy for supplying a variable load and injection to the network in case of surplus production is a problem. This is why we consider it necessary to use a battery protection system and a monitoring strategy for energy management. But in the literature, there is work to solve its problems. For example for batteries, in [2], the optimal feedback control technique for the state of charge (SOC) of the storage batteries energy (BSE) is used. The results is acceptable and method is effective. A smart charge controller is designed in [3] in order to extend the life of the battery. It has benefit functions for monitoring and control than the logic controller and conventional relays. A control strategy taking into account the load and the depth of discharge is used in [4] to avoid overload and under load batteries. The result is acceptable. The roulette redistribution mechanism is proposed in [5] with the power distribution algorithm based on the PSO (Particle Swarm Optimization). The proposed method improves the efficiency of 0.82% to 1.76% of system. The technique discussed in the monitoring system proposed in [6] uses an Arduino microcontroller. This approach clearly detect the location of the error according to information acquired and collected. To manage energy production of a multi-source system, Multi-Agent System (MAS) is proposed in [7] which are a connection of several fields such as artificial intelligence, distributed computer systems and engineering. The results showed that the SMA is very flexible due to their distributed structure and can also adapt to changes in energy systems to renewable sources. In [8], a centralized power supervisor is established to determine the reference power levels depending on the conditions of supply and demand. The simulation results obtained in Matlab / Simulink environment show the effectiveness of the proposed control scheme. The DSP microcontroller TMS320F2812 is used in [9] to construct the controller circuit for the power management system composed of photovoltaic generator and battery. The simulation and experimental results show a better performance of the proposed controller.

So with all these examples, we see that there is firstly more supervision strategies photovoltaic systems and other intelligent approaches to control charging and discharging. But we offer as part of this work simply smart approach monitoring of PV systems with BS connected to the RBT based on Arduino. The latter is a common material printed circuit on which is a microcontroller which can be programmed. The advantages of this card is that it is inexpensive, it facilitates electrical installations, it has a clear and simple programming environment and can perform a variety of tasks such as home automation (control of domestic appliances - lighting, heating ...). We call it ”magic card”. The Arduino system gives us the opportunity to combine the performance of programming to those of electronics. The Arduino board is programmable in a language similar to C that many researchers do not mastered. And in this paper we have proposed a novelty that is to use matlab language to drive the Arduino card (AC). And the latter is used for optimal power management and both ensure proper regulation of BS. And in this paper we have proposed a novelty that is to use matlab language to drive the Arduino card (AC). And the latter is used for optimal power management and both ensure proper regulation of BS. And in this paper we have proposed a novelty that is to use matlab language to drive the Arduino card (AC). And the latter is used for optimal power management and both ensure proper regulation of BS. This article will consist of three sections: Sect. 1 modelling, Sect. 2 supervisory strategy of the proposed system and Sect. 3 results and discussion.

2 Modeling of the proposed system

A model is a simplified representation of a system or a physical phenomenon to reproduce its functioning, analyze, explain and predict some aspects.

2.1 Modeling of GPV

The IV characteristic of a PV cell is not linear and depends on multiple parameters [10]. Figure 1 shows the photovoltaic model where \(I_{ph}\) represents the generated current for a given radiation, \(I_{out}\) the current produced by the cell to the external circuit, \(V_{out}\) is the voltage at the output terminals, a diode parallel with a current source, \(R_{s}\) series resistance and \(R_{p}\) shunt resistance of the cell. \(R_{s}\) and \(R_{p}\) are considered for precise and accurate results.

Fig. 1
figure 1

Schematic diagram of the electrical photopile

This model (see Fig. 1) is used by the authors for a good understanding of the operation of a solar cell. It establishes a relationship between the charging current (\(I_{out}\)) and load voltage (\(V_{out}\)). Equation 1 shows this relationship:

$$\begin{aligned} I_{out}(1+\frac{R_{s}}{R_{sh}})=I_{ph}-\frac{V_{out}}{R_{sh}}-I_{dark} \end{aligned}$$
(1)

When neglecting the effects of the parallel resistor and the series resistance, we find Equation 2:

$$\begin{aligned} I_{out}= & {} I_{ph}-I_{dark} \end{aligned}$$
(2)
$$\begin{aligned} With~~ I_{dark}= & {} I_{0}\left[ expo\left( q\frac{V_{out}+R_{s }.I_{out}}{K.T.\alpha }\right) -1\right] \end{aligned}$$
(3)

A GPV consists of (\(N_{s}\)) cells in series and (\(N_{p}\)) in parallel cells. It is modelled by Equation 4:

$$\begin{aligned} I_{out}=N_{p}.I_{ph}-I_{0}\left[ expo\left( q\frac{V_{out}+R_{s }.\frac{N_{s}}{N_{p}}.I_{out}}{N_{p}.K.T.\alpha }\right) -1\right] \end{aligned}$$
(4)

where:  \(I_{0}\) is the reverse saturation current, q the electron charge, \(\alpha \) the ideality factor of the junction, T the environment temperature et k the Boltzmann constant.

2.2 Modeling the boost converter

The c-dc converters are used either to step up/down the PV voltage. They can also be used to extract maximum power through MPPT (maximum power point tracking). Figure 2 shows the circuit diagram of a dc–dc boost converter. It is connected to 30 panels of PV that provides a larger output voltage than that of the panel. It is used here for less than PV panels.

Fig. 2
figure 2

Diagram of the boost converter

Two sequences are considered conduction according to the state of the transistor (T). This converter is modeled by the equations 56 et 7:

$$\begin{aligned} C_{1}\frac{dv_{pv}}{dt}= & {} \frac{V_{pv}}{r_{pv}}-i_{L} \end{aligned}$$
(5)
$$\begin{aligned} C_{2}\frac{dV_{dc}}{dt}= & {} d.i_{L}-\frac{V_{dc}}{R}\end{aligned}$$
(6)
$$\begin{aligned} L\frac{di_{L}}{dt}= & {} v_{pv}-d.V_{dc} \end{aligned}$$
(7)

The inductance and capacity (\(L_{s}\), \(C_{1}\), \(C_{2}\)) are storage elements. If they are carefully calculated, they could filter the current and minimize the ripple factor of both the input and output voltages (\(V_{pv}\) and \(V_{dc}\)) of the converters [9]. The storage elements (\(L_{s}\), \(C_{1}\) and \(C_{2}\)) are respectively dimensioned by the equations 89 et 10:

$$\begin{aligned} L_{s}= & {} \frac{V_{dc}}{4f.\varDelta I_{L}} \end{aligned}$$
(8)
$$\begin{aligned} C_{1}= & {} \frac{I_{L}}{4f\varDelta V_{pv}} \end{aligned}$$
(9)
$$\begin{aligned} C_{2}= & {} \frac{I_{p}}{4f.\varDelta V_{dc}} \end{aligned}$$
(10)

2.3 Modeling battery

Figure 3 is a simple circuit diagram of a battery where R is the internal resistance, it is variable and depends on the temperature, capacity and current charge and discharge of the battery, \(V_{bat}\) is battery voltage, \(E_{ba}\) represents the emf of the battery which depends on the charge state and \(I_{bat}\) is the battery current; it is positive during charging and negative during discharge. So the current sign of the battery depends on the operating modes. There are three main states of a battery storage system, which are discharging, standby and charging states [11].

Fig. 3
figure 3

Simple electrical model of a battery

Applying the mesh law and taking into account the two operational modes (charging and discharging), we have the equation 11:

$$\begin{aligned} V_{bat}=E_{b} \pm R.I_{bat} \end{aligned}$$
(11)

A battery is characterized by a few parameters such as its capacity (\(C_{bat}\)), its state of charge (SOC) and the charging voltage and the discharge voltage.

$$\begin{aligned} C_{bat}= & {} C_{10}\frac{1,76(1+0,005\times \varDelta T)}{1+0,67(\frac{I_{bat}}{I_{10}})}R.I_{bat} \end{aligned}$$
(12)
$$\begin{aligned} SOC(\%)= & {} 100\left( 1-\frac{Q}{C_{bat}}\right) \end{aligned}$$
(13)

Where:

$$\begin{aligned} Q=I_{bat}.t \end{aligned}$$

The Battery Model used in this paper is a Lead-Acid Battery with a nominal voltage of 12 V. It is connected to the dc bus through a bidirectional buck-boost converter for charging or discharging, as shown in Fig. 4. According to the model developed by CIEMAT, the battery voltage varies during charge and discharge. It is modeled by:

  • Charging voltage:

    $$\begin{aligned} V_{ch}=[2-0,16SOC]-A.(1-0,025\times \varDelta T) \end{aligned}$$
    (14)

    Where \(A=\frac{I_{bat}}{C_{10}}.\left( \frac{6}{1+I_{bat}^{0,86}}+\frac{0,48}{(1-SOC)^{1,2}}+0,036\right) \)

  • Voltage discharge:

    $$\begin{aligned} V_{dch}=[2,085-0,12(1-SOC)]-B.(1-0,007\times \varDelta T) \end{aligned}$$
    (15)

    Where \(B=\frac{I_{bat}}{C_{10}}.\left( \frac{4}{1+I_{bat}^{1,3}}+\frac{0,27}{SOC^{1,5}}+0,02\right) \)

With \(C_{10}\) is the battery capacity in Ah constant current discharge rate for 10 heures. \(\varDelta T=T-25\) degre Celsus : It is difference between the battery temperature and 25 degre Celsus. Subsequent paragraphs, however, are indented.

2.4 Modeling the buck-boost converter

Using this DC/DC converter (see Fig. 4) is explained by the fact that the voltage at the DC bus is greater than that of the battery but also it must ensure the buck function in one direction and lift in the opposite direction.

Fig. 4
figure 4

Model of the electric buck-boost converter

The diagram of Fig. 4 shows the electrical model of the bidirectional converter used. When charging the battery, it will operate in buck mode. In this case, control switch S2. When discharging switch S1 is controlled. It becomes lift.

So for these two modes of operation, the buck-boost chopper can be modelled by the equations 16 and 17 where u is the control signal:

$$\begin{aligned} \frac{di_{L}}{dt}= & {} \frac{V_{bat}}{L_{ds}}-(1-u)\frac{V_{dc}}{L_{ds}} \end{aligned}$$
(16)
$$\begin{aligned} \frac{dV_{dc}}{dt}= & {} (1-u)\frac{i_{L}}{C}-\frac{V_{dc}}{R.C} \end{aligned}$$
(17)

2.5 Modeling and dimensioning UPS

In this paper, the single-phase inverter (Fig. 5) is connected a left by a dc bus witch is connected a dc/dc boost converter (Fig. 2) and right by a grid (electric network). Figure 5 represents the single phase inverter. It is a dc/ac and the main power converter of the system. The inverter block provides Equation 18:

$$\begin{aligned} v_{ab}=v_{a}-v_{b} \end{aligned}$$
(18)

Where:

$$\begin{aligned} v_{a}= & {} h_{a}V_{dc} \\ v_{b}= & {} h_{b}V_{dc} \end{aligned}$$

Hence the equation 18 becomes:

$$\begin{aligned} v_{ab}=(h_{a}-h_{b})V_{dc}=h_{ab}.V_{dc} \end{aligned}$$
(19)

Applying the mesh law (Fig. 5), we find the equation 20:

$$\begin{aligned} v_{ab}-L_{on}.\frac{di_{L}}{dt}-V_{gr}=0 \end{aligned}$$
(20)

So the equation 20 becomes:

$$\begin{aligned} L_{on}.\frac{di_{L}}{dt}=h_{ab}.V_{dc}-V_{gr} \end{aligned}$$
(21)

Where \(V_{gr}\) represents the grid voltage, inductance \(L_{on}\) is used to filter the inverter output current and \(h_{a}\) and \(h_{b}\) are control signals.

Fig. 5
figure 5

Ideal Model of the single-phase inverter connected to the electric network

The Table 1 shows the parameters of the photovoltaic panels, the battery, the dc/dc converters, the dc/ac inverter and the grid.

Table 1 Parameters of components of the proposed system

3 Supervision Strategy card arduino

3.1 Operation mode PV-battery system connected to RED

The objective of the PV + Battery installation is to produce, consume and inject the surplus into the BT network. The diagram of Fig. 6 is a simplified electrical representation of the study system. It is composed of a photovoltaic generator, a boost converter, a battery bank, a buck-boost converter and a single-phase inverter. The S1, S2, S3, S4 and S5 are the commands relays for energy distribution.

Fig. 6
figure 6

Configuring the system circuit

NB: The relay S2 and S3 cannot be on at the same as it is impossible to load and unload both a battery. As S4 and S5 cannot be closed because they both serve respectively injection and consumption via the network. We chose safety switches to isolate the component failure. The control relays are each coupled through a diode to impose a direction of travels aware.

To make it easier supervision system, two algorithms are developed: one plays the role of battery protection and one can manage the transfer of energy between the PV, batteries and electrical distribution network the supply to the load.

3.2 Proposal for a power management strategy

In this system, the panels are considered as the main source. If the deficits battery bank will come second. Otherwise the network will supply the load. The minimum discharge the battery voltage is 11 V and the maximum charging voltage to 13 V. Figure 7 shows how the system works.

Fig. 7
figure 7

System management algorithm

The operation of the system is described in six modes:

  • -Mode 1 The power produced by the panels is greater than the power needed to charge and the battery voltage is greater than 12 V. In this case, the firm control system closes only S1 and S4 relay and opens S2, S3 and S5. This means the load is powered by the panels and there’s injection system.

  • -Mode 2 The power produced by the panels is greater than the power needed to charge but the battery voltage is below 12 V. In this case, the firm control system closes the relays S1 and S2 and opens S3, S4 and S5. This means the load is powered by the panels. The batteries are charging. There will be no injection of energy to the network.

  • -Mode 3 The power produced by the panels is less than the power needed to charge but not zero and the battery voltage is greater than 12 V. In this case, the firm control system closes S1 and S3 relay and opens S2, S4 and S5. This means that the batteries are landfilled and the load is supplied by the panels and batteries. He will not have energy injection to the network.

  • -Mode 4 The power produced by the panels is less than the power needed to charge but not zero and the battery voltage is below 12 V. In this case, the firm control system closes S2 and S5 relay and opens S1, S3 and S4. This means that the batteries are charging and the load is supplied by the network. He will not have energy injection to the network because S4 is open.

  • -Mode 5 The power generated by the panels is zero and the battery voltage is greater than 12 V. In this case, the control system closes S3 relay and opens S1, S2, S4 and S5. This means that the battery is discharging and the load is powered by the batteries. He will not have energy injection to the network.

  • -Mode 6 The power generated by the panels is zero and the battery voltage is less than 12 V. In this case, the control system closes S5 relay and the remaining relays are low. This means that the load is supplied by the network. The batteries and panels are disconnected.

Among these modes, we see that the battery works is in charge mode or discharge mode. Or its voltage varies depending on its operating modes. This variation can result in overload or underload battery hence the need for protection system.

3.3 Operation of the battery protection strategy

Figure 8 shows the algorithm to protect the battery against overload and underload. This shows that the protection system can be described with six (6) modes of operation:

  • - Mode 1 The battery voltage is increased, that is to say, the battery is charging, and it is between \(11.5 V<V_{bat}<13.5 V\).In this case, we will continue to charge the batteries.

  • - Mode 2 battery is being charged, it is not between \(11.5 V<V_{bat}<13.5 V\) but higher than 13.5 V. In this case, the protection system will disconnect the battery by opening S2 and S3 relay.

  • - Mode 3 The battery is being charged, it is not between\(11.5 V<V_{bat}<13.5 V\) but less than 13.5 V. In this case, they are allowed to charge battery mode.

  • - Mode 4 The battery voltage is decreasing, that is to say during use, and it is less than 11.5 V. In this case, the protection system opens the relay S2 and S3.

  • - Mode 5 The battery is discharging but the voltage is not less than 11.5 V. In this case, continue to use the battery.

  • - Mode 6The battery is either charge mode or discharge mode. She is resting.

Fig. 8
figure 8

Battery backup strategy

To overcome the data acquisition, a monitoring system has been built. And in order to follow in real time the system, the algorithm show in Figs. 7, 8 were implementated by using an Arduino board. This electronic card is the interface between our design system and a PC (see Fig. 9). It is an easy to use yet powerful single board computer that has gained considerable traction in the hobby as well as professional market [12].To realize the supervision of the system, we still need the following materials:

  • Four (4) Breakers 32A;

  • Five (5) Control Relay;

  • Four (4) Diodes check;

  • resistors to achieve sensors (voltage, current) and a level detector.

These materials are a set of interface between the Arduino board and different components system (see Fig. 9). They allow Arduino ensure the transfer of energy and deprotect the batteries.

Fig. 9
figure 9

Structure of control and supervision by Arduino-PC

In the absence of the real system, we made simulations with LED lamps in series with 220 resistors. We randomly selected a company. The owner of this last wishes to operate its expenses via a PV-battery system connected to BT network. Some loads operate 24/24 at constant power and other depend on the time working staff. Workers start coming at 8am and down to 19h. The GPV operates from the same time interval. The battery voltage does not depend on time. We traced the power profiles produced, load and battery between 8h and 19h (Fig. 10).

Fig. 10
figure 10

Profile of tension and those powers GPV and load

This Fig. 10 shows that:

  • between 8 am and 11 am the request (red curve) is greater than the power produced (blue curve) and the battery is in discharge,

  • between 11 am and 4 h 30 pm, the battery is disconnected and the energy produced by the PVG is higher than that required this can be explained by the fact that some devices are at rest and the solar irradiation is important,

  • from 4 pm 30 until 8 am the energy requirement remains over production and the battery is charging between 4 pm and 6 pm.

The Arduino board has its own software under which we can write purely Arduino program. But in this work in a spirit of curiosity and the fact that many researchers use matlab for simulations, we implemented the strategy in matlab algorithm. Arduino is always the control board and becomes an outer periphery of matlab. For that to happen, we first connected the card to the PC via a cable and then wrote \(''\hbox {a} = \hbox {Arduino;}''\) on the command window matlab. They also allow you to quickly know the features of the card.

4 Results and discussions

As we know Arduino card is a programmable microcontroller card capable of performing a variety of tasks such as control of home appliances—lighting, heating and store the results and also to communicate with the outside world .This means creating a program for controlling appliances based on the received data. For that several programming languages are used, such as Python, Java, C++, etc. In this project we used the Matlab development environment installed in a computer. The latter sends an instruction to the microcontroller which acts on the electric device by sending a signal PWM (a digital signal) which, at a given frequency, a duty ratio which varies with the given time ”orders it receives”.

Fig. 11
figure 11

Matlab software with the algorithm supervision coding

Fig. 12
figure 12

LED Lighting by Arduino from matlab

Fig. 13
figure 13

Simulation results of profiles depending on the measured time

Figure 11 below shows the GUI of the Matlab software that contains all the instructions of our program.

Figure 12 shows that the lighting of LED by the Arduino board from matlab. Arduino turn on and off the relay by time intervals as described below:

  • from 8 h to 10 h 59 min: S1 and S3 turned on and S2, S4 and S5 extinguished;

  • from 11 h to 16 h 29 mn: S1 and S4 on and S2, S3 and S5 extinguished;

  • from 16 h 30 min to 18 h 29 mn: S1 and S2 turned on and S3, S4 and S5 extinguished;

  • 18 h 30 to 7 h 59 min: single S5 is turned on.

It is found that all LEDs work normally.

The Fig. 13 shows the results of operation of system with the supervision system. This fig is described as follows:

  • from 8 to 10 am 59 mn: Food of the charge by the GPV and batteries;

  • from 11 h to 16 h 29 mn: Power supply of the load by the GPV and energy injection into network;

  • from 16 h 30 mn 18 h 29 mn: Food of the charge by the GPV system and charge the batteries;

  • from 30 to 18 h 7 h 59 min: Food of the load over the network.

These results show that the Arduino board manages power between GPV, BS and RED and controls the charge and discharge of the battery. So we can conclude that this Arduino control board works well with Matlab.

4.1 Conclusion

This study involved a PV+battery connected to the BT network. The monitoring algorithm we implemented on the Arduino card properly responds to different modes of operation. This is what has allowed the card to ensure both energy management. This work is a great contribution GPV control and supervision by an Arduino board with Matlab. In the immediate perspective, we expect to achieve the effective supervision of this type of system proposed.