# Design and Embedded Implementation of a Power Management Controller for Wind-PV-Diesel Microgrid System

Authors: M. Boussetta; S. Motahhir; R. El Bachtiri; A. Allouhi; M. Khanfara; Y. Chaibi
Journal: International Journal of Photoenergy
 (2019)

---

## Abstract

This paper presents an implementation of real-time energy management systems (EMS) to maximize the efficiency of the electricity distribution in an isolated hybrid microgrid system (HMGS) containing photovoltaic modules, wind turbine, battery energy storage system, and diesel generator (DG) which is used as a backup source. These systems are making progress worldwide thanks to their respect for the environment. However, hybridization of several sources requires power flow control (PFC). For this reason, in this work, a proper energy management system is developed using LabVIEW software and embedded in a suitable platform for the real-time management of the hybrid energy system. The developed EMS is tested and validated through a small-scale application which accurately represents the case study of an isolated mosque located in a remote area of Morocco. The aim of this paper is to (i) propose a novel modelling method and real-time monitoring interface under the LabVIEW software based on the real data obtained by an optimal sizing previously made using Homer-pro software and (ii) implement the power control system on a low-consumption embedded platform that is the Raspberry-pi3.


---

## Body

## 1. Introduction

Access to energy is now considered as a central issue in the fight against poverty and economic development. The proportion of the world’s population with access to electricity has gradually increased in recent years. However, despite these improvements, 1.1 billion people are still deprived of this essential service, with the majority of these people located in Africa. Among those who have gained access to electricity in the world since 2010, only 20% live in rural areas [1]. In Morocco, almost 1.3 million rural people are deprived of electricity; i.e., 88902 households do not have access to electricity [2]. Most of these rural homes are located in isolated or hard-to-access locations and do not allow connection to an electrical grid since the investment cost is very large and online losses become significant. It is then necessary to be able to install the infrastructures for electrification in sparsely populated areas and away from the main grid.In recent years, rural electrification has been achieved with DG or with stand-alone renewable energy sources, including photovoltaics and wind power, which have been considered promising to meet the growing demand for energy and play a very important role in the clean energy production. However, renewable energy depends to a large extent on wind speed or solar radiation. In order to provide a continuous supply by taking advantage of the complementary nature of the two sources of energy, one solution is to hybridize the types of sources in the form of the microgrid.HMS were considered attractive and preferred alternatives; indeed, the development of microgrid in rural areas makes it possible to electrify villages located far from the distribution grid with renewable energy sources (RES) in a more sustainable way. Another major factor in the development of microgrid systems is the sharp drop in the cost of renewable energies, which makes these energies competitive with traditional fossil fuels. Similarly, energy storage solutions are currently undergoing significant development due to the improvement of different technologies and lower production costs. In addition to renewable energy sources, a HMGS may also incorporate an AC distribution system, a DC system, a storage system, power converters, loads, a ballast load, and an EMS or a supervisory system. In most cases, HMGS contain two buses: a DC bus for sources, DC loads, and batteries and an AC bus for AC generators and the distribution system.The technoeconomic analysis of any hybrid renewable energy system (HRES) is highly essential to know its efficiency and economic viability, so several methods for optimal sizing have been proposed in the literature [3–11]. These works across the world have shown that a HRES is more economical than stand-alone energy systems. However, the intermittent nature of renewable energy sources requires proper power management in order to improve overall performance and increase the lifespan of the microgrid components. Therefore, adequate management of the energy flow through the HRES and the establishment of a supervisory system are essential.Various control strategies and topologies for an autonomous hybrid system have been reported in the literature [12–17]. Mengi and Altas have proposed a new energy management technique for PV/wind/grid renewable energy system in [18]; likewise, an evaluation of three EMSs was carried out by [19] to identify the most effective one. In addition, [20] proposed four optimization techniques for resolving an economic dispatch problem; the application is made on the system connected and not connected to the grid. [21] seeks to develop a dynamic energy management model for microgrid-enabled production systems. [22, 23] proposed management architectures multiagent based with both centralized and decentralized energy. [24] developed a coordinated control strategy for a stand-alone hybrid system with the aim of maintaining the battery state between 70% and 80% and maintaining the DG power above 40% of its nominal value. Likewise, a fuzzy logic technique is used to formulate a rebel control system for a HMGS [25–27]. Other researchers create new management strategies to minimize the total and operating cost of stand-alone hybrid energy systems [28, 29]. A control strategy consisting of the high-pass filter-based droop controller is realized by [30]. [31] came up with a mathematical formulation of the energy management problem and its implementation in a centralized EMS for isolated microgrid. For the grid connected microgrid systems, the energy management aims at reducing the dependence on the main distribution grid in the microgrid [32–35].On the other hand, researchers proposed a microgrid power management system (PMS) in real time [36–38]. An advanced real-time EMS for a microgrid is developed to maximize the power of the available RES while minimizing the energy cost and carbon dioxide emissions [39]; also, a multiobjective power management procedure for microgrid is carried out by [36]. [40] developed a technical and economic analysis of home EMS incorporating a small-scale wind turbine and battery energy storage system; the EMS is expressed as a mixed integer nonlinear programming (MINLP) and solved by the cultural algorithm as an effective metaheuristic optimization algorithm.A new field of research has appeared in recent years that has focused on the management of domestic energy [41, 42]. Novel home EMS using wireless communication technologies for carbon emission reduction within a smart-grid smooth power peak demand and diminish CO2 emissions is carried out by [43]. In the same way, three approaches are suggested for the rolling optimization by the home EMS, namely, mixed integer linear programming, continuous relaxation, and fuzzy logic controller [44]. ZigBee-based energy measurement modules are used to monitor the energy consumption of home appliances and lights [45]. Likewise, [46] developed a distributed multicontrol-center dynamic power flow algorithm based on an asynchronous iteration scheme.Most of the articles cited above regarding power management are simulation work and theoretical formulation; few articles present a practical implementation. Experimental evaluation of a PMS for a HRES with hydrogen production presents a PMS based on a fuzzy control system takes into account the uncertainties of the load demand and the power production from renewable energy sources for a HRES [47]. In an EMS implementation in Serbian manufacturing, the Plan-Do-Check-Act cycle approach with the aim to cut energy consumption and CO2 emissions is proposed by [48]. [49] present the energy box concept in the context of the V2G (vehicle-to-grid) technology to address the energy management needs of a modern residence, considering that the available infrastructure includes microrenewable energy sources in the form of solar and wind power. A real-time load management is developed to control unpredictable residential loads [50]; the developed control is implemented on an ARM Cortex-A9 processor of the ZYNQ device. Likewise, a supervisory PMS for a hybrid microgrid with HESS is presented by [51].In this article, we consider the case study of a mosque located in a mountain area of Morocco. First, we perform an optimal sizing to identify the best combination of energy sources. Then, we perform a design and modelling using the LabVIEW software. Finally, we carry out an experimental evaluation of the PMS on a real-time platform that is the Raspberry-pi 3 equipped with a microprocessor ARMv8, 1.2 GHz 64-bit quad-core.The aim of this work is to realize an optimal configuration of a hybrid PV-wind-diesel; a supervision system with the function of ensuring a secure, reliable, and efficient operation of the microgrid; and the implementation of a real-time PMS to verify the effect of the RES variation on the evolution of the system.The contributions of this article are(i)
feasibility study of a HMGS based on PV, wind turbine, and diesel generator using the actual solar radiation and the wind speed data to power a mosque located on an isolated site in Morocco
(ii)
modeling of the microgrid and the creation of a supervision dashboard to monitor the evolution of the system under the LabVIEW software
(iii)
implementation of the PMS on an embedded RPI3 platform


## 2. Studied System

The energy system studied in this paper is a stand-alone hybrid system that contains RES (PV panels and a wind turbine) associated with a standby diesel generator and storage battery. The structure of this AC/DC microgrid is shown in Figure1. The PV and the battery are connected to the DC bus and the wind turbine; the GD and the loads are connected to the AC bus on the other side.Figure 1
Studied hybrid PV-wind-diesel system.


## 3. Sizing of the HMGS

In this study, we chose an isolated load under real operating conditions. It is a mosque located in the center of Morocco (33°45′11″N latitude; 04°30′57″W longitude), with a daily load of 77 kWh/day; the detail of the consumption and the description of the major economic input data used in the model to define the optimal size of the different component of the hybrid energy system are given in Table 1 and Table 2, respectively.Table 1
Infrastructure load analysis.
Load description
Quantity
Power (watt)
On-time (hr/day)
Watt-hr/day
Outside lighting
2
125
11
2750
Garden lighting
3
80
11
2640
Inside lighting
40
100
6–8
24000–32000
Air conditioner
4
1200
6–8
28800–38400
Imam house
—
—
—
3276–5868
Total
73268–81650Table 2
Infrastructure load analysis.
Equipment
Life time (year)
Capital
Replacement
O&M (€/yr)
Generic flat plat PV
30
€1700/kW
€1500/kW
28
Wind turbine
25
€10,000
€10,000
180
Converter (5 kW)
10
€700
€600
50
Generic kWh Li-ion
10
€200
€200
10
Diesel generator
15,000 hours
€500/kW
€500/kW
€0.030/hrThe daily profile of the load is shown in Figure2. In this work, the load is modelled by its demand per power hour.Figure 2
Profile load.In order to supply this load, it is necessary to identify the optimum system between the various possible combinations (diesel only, PV-diesel, wind-diesel, and PV-wind-diesel). For this reason, a sizing of the hybrid system was carried out with HOMER-Pro software, for a 25-year project lifetime, using actual solar radiation data, wind speed, and economic data of the various components.


## 4. Modelling of the Proposed System

### 4.1. Photovoltaic Module

The photovoltaic output power depends on the incident solar radiation, and the hourly output power of the PV panel at any timet is calculated using the following equation:
(1)PPV=PPV,STCDf,PVRiRi,STC,where PPV,STCis the power provided by the PV array under standard test conditions (STC) (kW), Df,PV is the number of the derating factor (%), Ri is the solar radiation incident on the PV array in the current time step (kW/m2), and Ri,STC is the incident radiation at STC (1 kW/m2).Figure3 shows the output power profile by the set of photovoltaic panels sized in this study:Figure 3
PV panel output power.


### 4.2. Wind Turbine Modelling

At a specific site, the output power provided by the wind turbine depends on the wind turbine’s power curve (WTPC) and wind speed at the hub heightWh. The power curve of the wind turbine used in this work is shown in Figure 4, and the wind speed at the hub height Wh is calculated using the following equation:
(2)Wh=Wa.lnHh/slnAh/s,where Wa is the wind speed at anemometer height (m/s) derived from the wind speed data (Figure 5), Hh=30m is the hub height of the wind turbine (m), Ah=20mis the anemometer height (m), and s is the surface roughness length (m).Figure 4
Wind turbine’s power curve.Figure 5
Wind speed and wind power output.Figure5 shows the wind speed profile and the power supplied by the wind turbine for a typical day.


### 4.3. Battery Modeling

The optimum system found when dimensioning contains a storage battery to provide the necessary power when the RESs are insufficient to meet the load needs, if, of course, the amount of battery charge is sufficient. It is calculated by the following equation:(3)Pat=Pat−1+PSt−1+Ptt−1⋅Cbat⋅Cinv,where Pat is the battery charge at time t, Pat−1 is the battery charge at time t−1, PSt−1 is the charge quantity to be stored at time t−1, Ptt−1 is the total energy to be provided by the battery at time t, Cbat is the battery charge efficiency, and Cinv is the inverter charge efficiency.State of charge (SOC) of the battery depends on the load requirement and the power provided by the RES, and it is calculated using the following equations:(i)
For the charging mode,
(4)SOCt=SOCt−1+PbattCcharPN⋅1
(ii)
For the discharging mode,
(5)SOCt=SOCt−1+PbattCdisPN⋅100,where SOCtis the state of charge of the battery at time t, Pbattis power exchange during the time step Δt, Cchar is the battery charge efficiency, Cdis is the battery discharge efficiency, and PN is the battery nominal capacity.


### 4.4. Diesel Generator Modeling

The diesel generator used in this study is of the genset type with a maximum power of 10 kW; its function is to deliver the power difference between the power generated by the RES and the load profile when the battery is discharged; it always works near its rated power, to increase its lifetime and to minimize emissions and consumption. This consumption is given by the following equation:(6)Fct=α×Pnom+β×Pout,where α and β are the coefficients of the straight line presented in Figure 6. Pout and Pnom are the output power and the nominal power of the DG, respectively.Figure 6
Power curve of DG.


## 4.1. Photovoltaic Module

The photovoltaic output power depends on the incident solar radiation, and the hourly output power of the PV panel at any timet is calculated using the following equation:
(1)PPV=PPV,STCDf,PVRiRi,STC,where PPV,STCis the power provided by the PV array under standard test conditions (STC) (kW), Df,PV is the number of the derating factor (%), Ri is the solar radiation incident on the PV array in the current time step (kW/m2), and Ri,STC is the incident radiation at STC (1 kW/m2).Figure3 shows the output power profile by the set of photovoltaic panels sized in this study:Figure 3
PV panel output power.


## 4.2. Wind Turbine Modelling

At a specific site, the output power provided by the wind turbine depends on the wind turbine’s power curve (WTPC) and wind speed at the hub heightWh. The power curve of the wind turbine used in this work is shown in Figure 4, and the wind speed at the hub height Wh is calculated using the following equation:
(2)Wh=Wa.lnHh/slnAh/s,where Wa is the wind speed at anemometer height (m/s) derived from the wind speed data (Figure 5), Hh=30m is the hub height of the wind turbine (m), Ah=20mis the anemometer height (m), and s is the surface roughness length (m).Figure 4
Wind turbine’s power curve.Figure 5
Wind speed and wind power output.Figure5 shows the wind speed profile and the power supplied by the wind turbine for a typical day.


## 4.3. Battery Modeling

The optimum system found when dimensioning contains a storage battery to provide the necessary power when the RESs are insufficient to meet the load needs, if, of course, the amount of battery charge is sufficient. It is calculated by the following equation:(3)Pat=Pat−1+PSt−1+Ptt−1⋅Cbat⋅Cinv,where Pat is the battery charge at time t, Pat−1 is the battery charge at time t−1, PSt−1 is the charge quantity to be stored at time t−1, Ptt−1 is the total energy to be provided by the battery at time t, Cbat is the battery charge efficiency, and Cinv is the inverter charge efficiency.State of charge (SOC) of the battery depends on the load requirement and the power provided by the RES, and it is calculated using the following equations:(i)
For the charging mode,
(4)SOCt=SOCt−1+PbattCcharPN⋅1
(ii)
For the discharging mode,
(5)SOCt=SOCt−1+PbattCdisPN⋅100,where SOCtis the state of charge of the battery at time t, Pbattis power exchange during the time step Δt, Cchar is the battery charge efficiency, Cdis is the battery discharge efficiency, and PN is the battery nominal capacity.


## 4.4. Diesel Generator Modeling

The diesel generator used in this study is of the genset type with a maximum power of 10 kW; its function is to deliver the power difference between the power generated by the RES and the load profile when the battery is discharged; it always works near its rated power, to increase its lifetime and to minimize emissions and consumption. This consumption is given by the following equation:(6)Fct=α×Pnom+β×Pout,where α and β are the coefficients of the straight line presented in Figure 6. Pout and Pnom are the output power and the nominal power of the DG, respectively.Figure 6
Power curve of DG.


## 5. Energy Management System

### 5.1. Proposed Energy Management Scheme Based on Power Flow Control

Energy management in a microgrid is the way to distribute energy between different components and to meet the load requirement in all climatic conditions. In this paper, the microgrid is insulated and consists of several power sources; the control system must ensure the maximum supply of the load by the RES (wind turbine, PV).The diagram of the EMS proposed in this article is shown in Figure7. It allows to control the energy flow between the different components and to display the indicators for the user. The main tasks of the control system can be summarized as follows:
(i)
Energy flow control(a)
Meet the load requirement
(b)
Avoid interruptions of electrical power supply
(c)
Protect batteries from deep discharge and overload
(d)
Automatic start and stop of the diesel generator
(e)
Connect and disconnect the ballast load automatically in the event of excess energy generated by the RES
(ii)
Supervision(a)
Inform the user if the power generated by the PV and the wind turbine is sufficient or not
(b)
Inform the user if power is supplied to the load and by which energy system
(c)
Indicate whether the DG is running or stopped
(d)
Display the SOC of the battery and indicate whether it is plugged in or not
(e)
Indicate if ballast load is connected or notFigure 7
General structure of the proposed system.


### 5.2. Power Management Algorithm

The purpose of PMS is to ensure the supply of the load. To meet the specifications defined in the previous section the proposed algorithm is shown in Figure8. It is based on 5 modes:
(i)
PV mode (PL<PPV): the power supplied by the PVs is sufficient to supply the load. This mode is the highest priority in our case, if it is activated, the power produced by the PV panels is greater than the requested power by the load; in this case, the load is powered by the PVs and the wind turbine is disconnected if the battery is charged (SOC; SOCmax) or charging the battery if SOC<SOCmax
(ii)
Wind mode (PPV<PL and PL<PW): the power provided by the wind turbine is sufficient for the power supply. This mode is activated if the power provided by the PVs is not sufficient. The load is fed by the wind turbine. The PVs load the battery if SOC<SOCmax and they are disconnected otherwise
(iii)
PV/wind hybrid mode (PPV<PL and PL<PW and PPV+PW>PL): the load is fed by the two RESs (wind and PV). This mode is on if the first two modes are not activated. In this case, the battery is charged by the remaining power if SOC<SOCmax. Otherwise, the rest of power feeds a ballast load
(iv)
PV/wind/battery hybrid mode (PPV<PL and PL<PW and PPV+PW<PL and SOCmin<SOC≤SOCmax): in this case, the RESs are not able to ensure the requirement of the load; the battery ensures the lack of power
(v)
PV/wind/diesel hybrid mode (PPV<PL and PL<PW and PPV+PW<PL and SOC≤SOCmin): the load cannot be fed by the two RESs (wind and PV) and the battery is discharged. This mode is activated if the preceding modes are not activated; in this mode, the DG is started to complete the lack of energyFigure 8
Proposed power management algorithm.


### 5.3. LabVIEW Code for Controlling the Power Flow of the Microgrid

Simulation step must be performed prior to implementation. In this study, the operation of the HMGS is tested using the LabVIEW software, for a typical day. Figure9 shows the power management program, consisting of 3 parts:
(i)
System inputs: the load profile (Figure 2), the power generated by the PVs (Figure 3), the power supplied by the wind turbine (Figure 5), and the SOC of the battery for each one-minute time space
(ii)
Controller: corresponds to the operation defined by the algorithm shown in Figure 8
(iii)
System outputs: corresponds to the actuators and to displays that indicate the status of each source and load (dashboard).Figure 9
LabVIEW code for controlling the power flow of the microgrid.


## 5.1. Proposed Energy Management Scheme Based on Power Flow Control

Energy management in a microgrid is the way to distribute energy between different components and to meet the load requirement in all climatic conditions. In this paper, the microgrid is insulated and consists of several power sources; the control system must ensure the maximum supply of the load by the RES (wind turbine, PV).The diagram of the EMS proposed in this article is shown in Figure7. It allows to control the energy flow between the different components and to display the indicators for the user. The main tasks of the control system can be summarized as follows:
(i)
Energy flow control(a)
Meet the load requirement
(b)
Avoid interruptions of electrical power supply
(c)
Protect batteries from deep discharge and overload
(d)
Automatic start and stop of the diesel generator
(e)
Connect and disconnect the ballast load automatically in the event of excess energy generated by the RES
(ii)
Supervision(a)
Inform the user if the power generated by the PV and the wind turbine is sufficient or not
(b)
Inform the user if power is supplied to the load and by which energy system
(c)
Indicate whether the DG is running or stopped
(d)
Display the SOC of the battery and indicate whether it is plugged in or not
(e)
Indicate if ballast load is connected or notFigure 7
General structure of the proposed system.


## 5.2. Power Management Algorithm

The purpose of PMS is to ensure the supply of the load. To meet the specifications defined in the previous section the proposed algorithm is shown in Figure8. It is based on 5 modes:
(i)
PV mode (PL<PPV): the power supplied by the PVs is sufficient to supply the load. This mode is the highest priority in our case, if it is activated, the power produced by the PV panels is greater than the requested power by the load; in this case, the load is powered by the PVs and the wind turbine is disconnected if the battery is charged (SOC; SOCmax) or charging the battery if SOC<SOCmax
(ii)
Wind mode (PPV<PL and PL<PW): the power provided by the wind turbine is sufficient for the power supply. This mode is activated if the power provided by the PVs is not sufficient. The load is fed by the wind turbine. The PVs load the battery if SOC<SOCmax and they are disconnected otherwise
(iii)
PV/wind hybrid mode (PPV<PL and PL<PW and PPV+PW>PL): the load is fed by the two RESs (wind and PV). This mode is on if the first two modes are not activated. In this case, the battery is charged by the remaining power if SOC<SOCmax. Otherwise, the rest of power feeds a ballast load
(iv)
PV/wind/battery hybrid mode (PPV<PL and PL<PW and PPV+PW<PL and SOCmin<SOC≤SOCmax): in this case, the RESs are not able to ensure the requirement of the load; the battery ensures the lack of power
(v)
PV/wind/diesel hybrid mode (PPV<PL and PL<PW and PPV+PW<PL and SOC≤SOCmin): the load cannot be fed by the two RESs (wind and PV) and the battery is discharged. This mode is activated if the preceding modes are not activated; in this mode, the DG is started to complete the lack of energyFigure 8
Proposed power management algorithm.


## 5.3. LabVIEW Code for Controlling the Power Flow of the Microgrid

Simulation step must be performed prior to implementation. In this study, the operation of the HMGS is tested using the LabVIEW software, for a typical day. Figure9 shows the power management program, consisting of 3 parts:
(i)
System inputs: the load profile (Figure 2), the power generated by the PVs (Figure 3), the power supplied by the wind turbine (Figure 5), and the SOC of the battery for each one-minute time space
(ii)
Controller: corresponds to the operation defined by the algorithm shown in Figure 8
(iii)
System outputs: corresponds to the actuators and to displays that indicate the status of each source and load (dashboard).Figure 9
LabVIEW code for controlling the power flow of the microgrid.


## 6. Hardware Implementation

After sizing a HRES to justify the choice of the PV-wind-diesel system, we developed a management algorithm and we carried out a successful simulation on LabVIEW, using real radiation and wind speed data. The simulations show the feasibility of such a system.In this section, we implement the energy control system on an embedded platform such as the Raspberry-pi 3. Figure10 shows the overall electrical scheme. Power sources and load are connected to the Raspberry-pi through an Arduino. Part of the Raspberry pins will control the relays, which are wired directly to the sources, and other pins will control the different loads.Figure 10
General scheme of the hardware implementation.


### 6.1. Raspberry-Pi

Raspberry-pi 3 (RPI3) is an open hardware platform and is a low-cost ARM-based palm-size computer, featuring a quad-core 1.2 GHz processor, 1 GB of RAM memory, 4 USB, 10/100 Ethernet, GPIO, HDMI and composite video outputs, and SD card slot. RPI is small in size and it consumes 5 V electricity at 1 A current due to which power consumption of the Raspberry-pi is less.It allows the execution of several variants of the free GNU/Linux operating system and compatible software. We chose the Raspbian distribution Linux embedded operating system. The programming is done using the Python language wish is a structured and object-oriented programming language. It features dynamic typing, automatic memory management, and an exception management system.


### 6.2. Relays

The relay circuit was designed to be able to switch the different sources, according to the program executed by the Raspberry, which translates the proposed algorithm. For the realization of this one, we used ISIS software as shown in Figure11.Figure 11
ISIS diagram of the relay circuit.Four coils of the relay are powered by 5 V pin of the Rpi and the masses are isolated by transistors 2N2222. Each relay corresponds to a power source and the control is sent by the Rpi. A current passes to the base of the transistor, then the coil of the relay is energized; this will make it possible to use the energy of the chosen source.After verifying the operation of the circuit on ISIS, we realized the printed circuit using ARES software. Thus, we have obtained the printed circuit indicated in Figure12.Figure 12
ARES diagram of the relay circuit.


### 6.3. Load Control Circuit

To test the management program practically, we took lamps as the system load and a fan as the ballast load. The control circuit that controls these charges is realized. Figure13 shows its diagram on ISIS and Figure 14 shows its implementation on ARES.Figure 13
ISIS diagram of the load control circuit.Figure 14
ARES diagram of the load control circuit.


### 6.4. Arduino

It is a circuit whose main constitution is a microcontroller that can be programmed to perform very different tasks. Its programming is done using the Arduino integrated development environment, which is a free and cross-platform Java Application, which can be used as a code editor and a compiler, and which can transfer the firmware and the program via the serial link (RS-232, Bluetooth, or USB depending on the module).In our case, the power management program has been implemented on the Raspberry; however, the Rpi does not contain any analog inputs, so we used the Arduino to convert the analog data received from the power sources to digital values. As a result, two programs will be developed, one for the Raspberry (for management) and one for the Arduino to do the data transfer.


## 6.1. Raspberry-Pi

Raspberry-pi 3 (RPI3) is an open hardware platform and is a low-cost ARM-based palm-size computer, featuring a quad-core 1.2 GHz processor, 1 GB of RAM memory, 4 USB, 10/100 Ethernet, GPIO, HDMI and composite video outputs, and SD card slot. RPI is small in size and it consumes 5 V electricity at 1 A current due to which power consumption of the Raspberry-pi is less.It allows the execution of several variants of the free GNU/Linux operating system and compatible software. We chose the Raspbian distribution Linux embedded operating system. The programming is done using the Python language wish is a structured and object-oriented programming language. It features dynamic typing, automatic memory management, and an exception management system.


## 6.2. Relays

The relay circuit was designed to be able to switch the different sources, according to the program executed by the Raspberry, which translates the proposed algorithm. For the realization of this one, we used ISIS software as shown in Figure11.Figure 11
ISIS diagram of the relay circuit.Four coils of the relay are powered by 5 V pin of the Rpi and the masses are isolated by transistors 2N2222. Each relay corresponds to a power source and the control is sent by the Rpi. A current passes to the base of the transistor, then the coil of the relay is energized; this will make it possible to use the energy of the chosen source.After verifying the operation of the circuit on ISIS, we realized the printed circuit using ARES software. Thus, we have obtained the printed circuit indicated in Figure12.Figure 12
ARES diagram of the relay circuit.


## 6.3. Load Control Circuit

To test the management program practically, we took lamps as the system load and a fan as the ballast load. The control circuit that controls these charges is realized. Figure13 shows its diagram on ISIS and Figure 14 shows its implementation on ARES.Figure 13
ISIS diagram of the load control circuit.Figure 14
ARES diagram of the load control circuit.


## 6.4. Arduino

It is a circuit whose main constitution is a microcontroller that can be programmed to perform very different tasks. Its programming is done using the Arduino integrated development environment, which is a free and cross-platform Java Application, which can be used as a code editor and a compiler, and which can transfer the firmware and the program via the serial link (RS-232, Bluetooth, or USB depending on the module).In our case, the power management program has been implemented on the Raspberry; however, the Rpi does not contain any analog inputs, so we used the Arduino to convert the analog data received from the power sources to digital values. As a result, two programs will be developed, one for the Raspberry (for management) and one for the Arduino to do the data transfer.


## 7. Results and Discussion

### 7.1. Sizing Results

Figure15 shows the comparison of all possible combinations from an economic and ecological point of view (net present cost and the amount of greenhouse gas emissions). This figure shows the interest of using HMGS compared to the current situation of the diesel generator. Hybrid PV-wind-diesel system (PWDS) produces better results compared to the PV-diesel system (PDS), wind-diesel system (WDS), and diesel-only system (DS).Figure 15
NPC and amount of emissions of each combination.The sizing result using the Homer-pro software shows that the optimal system is a hybrid system based on 5 kW panels, the wind turbine of 3 kWp, and a genset of 10 kW backup diesel generator, combined with a generic kWh storage battery Li-ion 1 kWh and a Leon s219cph 5 kW 48 Vdc bidirectional converter (BDI 1P).Further information on the system inputs and other results of this dimensioning can be found in [52].


### 7.2. Modelling Results

In order to test and monitor microgrid performance under real conditions, a simulation study is done using LabVIEW software. The simulation results consist mainly of 2 components: the user interface realized in the form of a dashboard that allows the user to see the state of the microgrid every minute. As shown in Figure16, it is composed of
(i)
two tables: Table1 contains the actual values of the load as well as the powers of the renewable energy and Table 2 displays the results of the simulated values and their execution times as well as the date
(ii)
4 LEDs indicate whether the load is powered or not, the battery is connected or not, the DG is on or off, and the ballast load is feed or not
(iii)
the SOC level of the battery
(iv)
5 displays showing the status of each energy source and the need for the load during the execution of the program; the user can see the evolution curves of powers in real time. We used memory oscillators to get the results for 24 hFigure 16
LabVIEW user interface of the microgrid.Figure17 shows the power supplied by the various energy sources. As can be seen, it corresponds to the required load profile. Figures 18 and 19 represent the power evolution provided by the wind turbine and the PV panels, respectively.Figure 17
Load consumption.Figure 18
The power supplied by the wind turbine.Figure 19
PV power production.Figure20 shows the state of the diesel generator; it is started 3 times during the day.Figure 20
DG control.


### 7.3. Experimental Result

Figure21 shows the first setup of our microgrid; it is a model realized with modest personal means. We have used potentiometers to vary the powers provided by energy sources on purpose to visualize the effect of this variation in real time. Similarly, for the load, we took 5 lamps and a fan as the ballast load.Figure 21
Implementation setup.Arduino receives the power values provided by the power sources and the battery (potentiometers); it handles the analogue digital conversion and then transfers them to the RPI3, which executes the power management program, and reacts to the loads according to the flow chart of Figure8.


## 7.1. Sizing Results

Figure15 shows the comparison of all possible combinations from an economic and ecological point of view (net present cost and the amount of greenhouse gas emissions). This figure shows the interest of using HMGS compared to the current situation of the diesel generator. Hybrid PV-wind-diesel system (PWDS) produces better results compared to the PV-diesel system (PDS), wind-diesel system (WDS), and diesel-only system (DS).Figure 15
NPC and amount of emissions of each combination.The sizing result using the Homer-pro software shows that the optimal system is a hybrid system based on 5 kW panels, the wind turbine of 3 kWp, and a genset of 10 kW backup diesel generator, combined with a generic kWh storage battery Li-ion 1 kWh and a Leon s219cph 5 kW 48 Vdc bidirectional converter (BDI 1P).Further information on the system inputs and other results of this dimensioning can be found in [52].


## 7.2. Modelling Results

In order to test and monitor microgrid performance under real conditions, a simulation study is done using LabVIEW software. The simulation results consist mainly of 2 components: the user interface realized in the form of a dashboard that allows the user to see the state of the microgrid every minute. As shown in Figure16, it is composed of
(i)
two tables: Table1 contains the actual values of the load as well as the powers of the renewable energy and Table 2 displays the results of the simulated values and their execution times as well as the date
(ii)
4 LEDs indicate whether the load is powered or not, the battery is connected or not, the DG is on or off, and the ballast load is feed or not
(iii)
the SOC level of the battery
(iv)
5 displays showing the status of each energy source and the need for the load during the execution of the program; the user can see the evolution curves of powers in real time. We used memory oscillators to get the results for 24 hFigure 16
LabVIEW user interface of the microgrid.Figure17 shows the power supplied by the various energy sources. As can be seen, it corresponds to the required load profile. Figures 18 and 19 represent the power evolution provided by the wind turbine and the PV panels, respectively.Figure 17
Load consumption.Figure 18
The power supplied by the wind turbine.Figure 19
PV power production.Figure20 shows the state of the diesel generator; it is started 3 times during the day.Figure 20
DG control.


## 7.3. Experimental Result

Figure21 shows the first setup of our microgrid; it is a model realized with modest personal means. We have used potentiometers to vary the powers provided by energy sources on purpose to visualize the effect of this variation in real time. Similarly, for the load, we took 5 lamps and a fan as the ballast load.Figure 21
Implementation setup.Arduino receives the power values provided by the power sources and the battery (potentiometers); it handles the analogue digital conversion and then transfers them to the RPI3, which executes the power management program, and reacts to the loads according to the flow chart of Figure8.


## 8. Conclusion and Future Work

This paper presents an implementation of real-time energy management systems (EMS) to maximize the efficiency of the electricity distribution in a microgrid. The grid serves a load with an off-grid hybrid renewable energy system made of photovoltaic modules, a battery energy storage system, a diesel generator, and a wind turbine. Furthermore, a proper power flow control is developed using LabVIEW software and embedded in a suitable platform for the real-time management of the hybrid energy system. The developed EMS is tested and validated through a small-scale application which accurately represents the case study of an isolated mosque located in a remote area of Morocco.This system can be introduced into a microgrid to monitor its components. The system is realized and is equipped with a supervision dashboard, allowing the user to monitor the evolution of the hybrid system. In the future, these power systems will be able to take advantage of clean and renewable energy sources.In the hardware implementation, we used the potentiometers to vary the RES powers and the load profile; in the next works, we will replace these potentiometers with current and voltage sensors to use the real panels and the wind turbine. Also, monitoring and control technologies must be developed to reduce energy consumption in renewable energy systems. Currently, we are developing a remote monitoring system and a control interface that allows the user to see the power variations and the state of the battery, thus controlling remote power sources. For this reason, we created a hosting server as well as its configuration; thus, we installed the PHP language and a web server named APACHE in order to communicate with the RPI3 using its IP address and to control it from afar.



---

*Source: 8974370-2019-12-01.xml*