1 Introduction

The global energy landscape is undergoing a paradigm shift, marked by a heightened focus on sustainability and a transition towards renewable energy sources [1]. Micro-grid systems, characterized by their localized generation and distribution capabilities, have gained prominence as a means to enhance energy resilience and efficiency [2]. Hybrid micro-grid systems combine multiple sources of energy, often integrating conventional and renewable sources, to create a robust and adaptive energy infrastructure. This integration necessitates sophisticated energy management strategies to harness the full potential of diverse energy resources and ensure a reliable power supply. While the integration of renewable energy into micro-grid systems offers many benefits, it introduces challenges that must be addressed for effective implementation. The intermittent nature of renewable sources, variability in energy production, and the mismatch between energy supply and demand pose significant hurdles [3].

Additionally, the integration of diverse energy storage technologies and the seamless coordination of multiple energy sources require advanced control strategies. Addressing these challenges is essential for realizing the full economic and environmental potential of hybrid micro-grid systems [4]. A thorough examination of the existing literature reveals a growing body of research dedicated to the optimization of hybrid micro-grid systems. Studies have explored various aspects, including energy management algorithms, control strategies, and the integration of different renewable energy sources [5]. Different contributions have been made in the areas of predictive modeling, real-time monitoring, and economic dispatch strategies. However, there remains a need for more comprehensive approaches that address the unique challenges of hybrid micro-grid systems, considering both technical and economic factors [6, 7].

This research aimed to contribute to the existing body of knowledge by developing an advanced energy management strategy for hybrid micro-grid systems using renewable energy sources. The study explored the integration of solar, wind, and diesel generator, coupled with a battery energy storage, to create a resilient and efficient energy network. The focus was on addressing challenges related to intermittency, optimizing energy dispatch, and ensuring grid stability. The motivation behind this research lied in the imperative to accelerate the adoption of sustainable energy solutions. By developing a robust energy management strategy for hybrid micro-grid systems, this study provides practical insights for engineers, policymakers, and stakeholders involved in the planning and implementation of renewable energy projects. The potential impact extends beyond theoretical advancements, offering tangible contributions to the transition towards a cleaner and more sustainable energy future.

The primary contribution of this study included an advanced energy management algorithm. Developing an algorithm to optimize the coordination of renewable energy sources and battery energy storage within a hybrid micro-grid. Moreover, the research had the objective to provide practical guidelines for the design and operation of hybrid micro-grid systems, fostering a more widespread adoption of sustainable energy practices. The developed hybrid renewable micro-grid model and energy management system algorithm were performed using the Stateflow logical language in the MATLAB/Simulink environment. This paper is organized as follows. Section 2 presents the concept of hybrid micro-grid. In Sect. 3, the energy management strategy is presented. Section 4 presents and evaluates the simulation results of the developed algorithm and finally, Sect. 5 gives the conclusion of the paper.

1.1 Critic on literature

Hybrid micro-grid systems are becoming more prevalent and are finding more interesting applications in different fields. A hybrid micro-grid system is composed of different generation resources including fossil fuel-based (e.g., diesel) and renewable energy-based resources such as solar PV, micro-hydro, wind and biomass. The role of a hybrid micro-grid system is of paramount importance in the current complex energy transition. Hybrid micro-grids are increasingly being adopted worldwide. They can operate in grid connected and island mode. Except for the distributed generation units, a hybrid micro-grid is composed of controllable load and energy storage systems. An energy management system is important to optimize its performance. The energy management system of a micro-grid includes both generation and demand side management by providing satisfaction of the system constraints, to realize an economical, sustainable, and reliable operation of the micro-grid. An energy management system offers many benefits from production dispatch to energy savings, reactive power support to the regulation of frequency, reliability to loss cost-reduction, energy balance to mitigate greenhouse gas emissions, and customer participation to customer privacy. As the level of the renewable energy sources penetration raises, the requirement of a real-time and robust energy management strategy becomes necessary to connect the distribution generation resources as well as the energy storage systems.

1.2 Existing works related to energy management system of hybrid micro-grid system

A brief overview on the energy management system of hybrid micro-grid system using renewable energy sources is outlined below:

  1. 1.

    Himabindu et al. have developed an optimal energy management strategy. The main objective of the research was to satisfy the power demand by the load and to maintain the state of the charge of the energy storage systems, which included the battery and the hydrogen in a certain range. The results have shown that the method was able to optimize the utilization costs and the lifespan of the energy storage systems. The authors suggested the utilization of other methods to check the performance of the proposed energy management system and also include the grid-connected mode [8].

  2. 2.

    Kang et al. [9] have proposed a small-scale hybrid AC/DC microgrid energy management technique based on Artificial Neural Network control. An EMS operation mode was chosen, an operation profile was chosen in each operation mode, and then ANN training was implemented in each operation mode in order to develop the proposed EMS.

  3. 3.

    Elkazaz et al. [10] have implemented a new energy management system (EMS) that can minimize the micro-grid daily operating cost and maximize the renewable energy source self-consumption by determining the optimal configuration for a central battery energy storage system (BESS) based on a defined cost function was proposed. This EMS had a two-layer structure. Firstly, the upper layer. In this structure a Convex Optimization Technique was used to solve the optimization issue and to determine the reference values for the power that should be drawn by the micro-grid from the main grid utilizing a 15 min sample time. The reference values were then fed to a lower control layer, which uses a 1 min sample time, to determine the settings for the BESS which then ensured that the micro-grid accurately follows these references.

  4. 4.

    Bilbao et al. [11] focused on the optimal operation of hybrid microgrids, based generally on the mathematical modelling. To implement the management of this type of networks requires several challenges and various options. The main contribution of the research was the mathematical modelling of many hybrid microgrid components. This modelling can be utilized in various control and management methods of the network, and its feasibility has been shown in three methods, which include one based on the Decision Tree method, which belongs to the Machine Learning family. The results on a test system of 69 buses showed that it is possible to implement its management.

  5. 5.

    A new hybrid battery and PV-wind turbine power system was proposed by Reddy et al. [12] using Fuzzy Logic control. The dynamic behaviour of the recommended model was examined under various operating conditions. The developed system and its control strategy displayed exceptional performance. The proposed model offers a useful tool for enhancing the efficiency of the smart grid.

However, the study done by Lanre Olatomiwa et al. [13] provided a review on energy management system in hybrid renewable energy systems. In this research, particular consideration was focused on smart grids energy management systems. The methods using fuzzy logic techniques are also presented to develop the energy management systems. The study pointed out that the requirement for a real-time and effective energy management strategies has become very vital to connect the hybrid renewable resources associated with the energy storage systems. This complete review revealed that most of studies on the energy management for a hybrid renewable energy systems have been done in islanded mode, and only a few cases are focused on grid connected. Thus, it is important to develop new strategies and techniques to control and to manage the power flow in a hybrid renewable micro-grid system operating in grid connected mode.

2 Concept of hybrid micro-grid

A typical hybrid micro-grid system refers to a group of distributed generation (DG) systems based on renewable and/or non-renewable resources, including an energy storage system (ESS) as well as local controllable loads, usually connected to the distribution system [14]. It can either operate in grid connected mode or island mode according to the load condition. Hybrid micro-grid systems can be classified in different categories based on the location, size, application, and connectivity [15]. Three types of hybrid micro-grid configurations exist in general, which are remote, grid-connected and networked. Hybrid micro-grid systems can be principally classified into three categories according to the system architecture and voltage characteristics, AC micro-grid, DC micro-grid, and Hybrid AC/DC micro-grid [16].

A hybrid micro-grid is composed of different distributed generation sources; the power from these DGs is collected, converted and distributed based on the load demands. To assure an effective operation of the system, a control strategy is required and it is important when power electronics interface with the system to constitute a single unit. The control system is very important because it also enables to conserve the specific energy supply and the power quality [17]. Figure 1 gives a typical representation of a hybrid micro-grid system, where it can be seen that a micro-grid could also be interconnected with the main grid and includes a diversity of assets and power sources, which provide different services to a range of facilities.

Fig. 1
figure 1

Hybrid micro-grid concept [17]

According to the environmental concerns (like atmospheric, ground and water pollution, climate change), the use of fossil fuels, the finite and limited quantities of conventional fuels, the increase in the cost of electrical energy, the need of energy security and the independence of certain nations, increase the necessity to embrace and develop renewable energy resources [18]. The decentralization of electricity supply brings production closer to the point of consumption, increasing system reliability, because when a fault occurs somewhere and as a part of the network is insulated, this will not affect the other branches. Additionally, it increases the efficiency of the entire system because the transmission losses are reduced [19].

Hybrid micro-grid systems are getting more attentions due to the increase in energy needs around the world, with a variable rate between nations and continents. For practical and scientific advantages, important incentives are established to promote the integration of hybrid micro-grid projects for electrification in remote areas and developing nations [20]. To improve the power generating system overall, the hybrid micro-grid depends on the interconnect converter. It also enhances the quality of the power and facilitates the AC or DC power supply between each micro-grid [21].

2.1 Architecture of a hybrid micro-grid system

In the pursuit of a resilient, sustainable, and decentralized energy system, hybrid micro-grid architectures have emerged as a cutting-edge solution that integrates the benefits of diverse distributed energy resources, storage technologies, and intelligent control systems. Figure 2 shows the structure of a hybrid micro-grid. The basic architecture includes a variety of renewable energy sources, a conventional generator and different types of loads as well as energy storage devices, which interface with the power electronic systems [22]. For a proper system harmonization and control, the Point of Common Coupling (PCC) defines the operating mode, which can be either grid connected mode or islanded mode. It also allows to connect the micro-grid with the main grid. The PCC has as role to connect or disconnect the hybrid micro-grid system from, or to the main grid. To ensure overall system stability, different levels of control, utilizing micro-sources and central controllers support and coordinate the micro-grid [23].

Fig. 2
figure 2

Micro-grid architecture [24]

A hybrid micro-grid architecture represents an innovative approach to energy distribution and management that harmonizes renewable and conventional energy sources, storage technologies, and advanced control systems [25]. Hybrid micro-grids are at the forefront of the global movement to change the energy landscape because they promote the local energy production, improve grid resilience, and contribute to environmental sustainability [26]. Hybrid micro-grids have a compelling potential to shape a more efficient and sustainable energy future as technology advances and the understanding of energy dynamics expands [27]. An energy management system (EMS), which is software-based, manages and controls the flow of energy in a hybrid micro-grid system. It collects real-time data from multiple sensors, such as solar panels, wind turbines, and energy storage devices, and evaluates it to determine the best way to operate the system.

2.2 Energy management controls for hybrid micro-grid

For reliable, sustainable, and efficient energy systems, hybrid micro-grids have emerged as a transformative solution that uses the cooperation of diverse energy sources and storage technologies [28]. For a successful operation of hybrid micro-grids, it is important to implement sophisticated energy management controls [29]. These controls serve as the brains behind the system, coordinating the complex interaction of renewable and conventional energy resources, storage systems, and load demands to optimize the performance, resilience, and environmental impact [30].

Energy management controls for hybrid micro-grids are dynamic, adaptive systems that include a range of hardware and software components designed to monitor, analyze, and direct the flow of energy within the micro-grid. At their core, these controls aim to achieve several key objectives. Different control strategies of the energy management are presented below.

2.2.1 Optimal resource allocation

Hybrid micro-grids often consist of diverse energy sources, including solar PV, wind turbines, fossil fuel generators, and energy storage. The energy management controls determine the most efficient combination of these resources to meet the current energy demand while considering factors such as availability, cost, and environmental impact [31].

2.2.2 Load balancing

The controls actively balance the energy supply and demand by adjusting the distribution of power from different sources. This ensures that the micro-grid operates smoothly, avoiding overloading or underutilization of any particular component [32].

2.2.3 Islanding and grid connection

One of the unique features of hybrid micro-grids is their ability to switch between grid-connected and islanded modes. The energy management controls monitor grid conditions and initiate a seamless transition between these modes as needed, ensuring continuity of power supply and maintaining stability [33].

2.2.4 Storage management

Energy storage systems, such as batteries, play a pivotal role in hybrid micro-grids by storing excess energy and releasing it when demand exceeds supply. The controls determine the optimal times for charging and discharging these storage systems to maximize their lifespan and efficiency [34].

2.2.5 Predictive analytics

Advanced energy management controls use predictive algorithms that anticipate the energy generation, consumption patterns, and storage needs based on historical data, weather predictions, and load profiles [35]. This enables proactive decision-making and enhances the ability of micro-grid to adapt to changing conditions [36].

2.2.6 Demand response

The controls can also facilitate demand response strategies by intelligently adjusting energy consumption in response to grid conditions or pricing signals [37]. This not only benefits the micro-grid but also contributes to overall grid stability during peak demand periods [38].

2.2.7 Environmental considerations

Energy management controls can factor in environmental considerations, such as reducing carbon emissions, when making operational decisions. This ensures that the operation of micro-grid aligns with sustainability goals [39].

The complexity of hybrid micro-grid systems demands a multidisciplinary approach to energy management controls [40]. This involves a fusion of control theory, power electronics, data analytics, communication protocols, and real-time monitoring. As technology continues to advance, artificial intelligence and machine learning techniques are increasingly being integrated into energy management systems to enhance their adaptability and decision-making capabilities [41].

2.3 Description of the developed hybrid microgrid system

The developed hybrid micro-grid architecture was applied to supply a variable AC load. The power generation capacity of each distributed generation source was 500 kWp for solar, 500 kW for wind energy, 900 kWh for the battery and 1.5 MW for the diesel generator. The power generated from the PV and battery are DC, but for wind is AC, therefore, the power generated from the DC sources were converted in AC by using an inverter. The line to line voltage from PCC was 10 kV and a transformer was used to set the AC bus voltage for the system to 380 Vac. The battery was utilized to assure power supply to the variable load without any interruption. It supplied power when the available power from the distributed generation was not sufficient to satisfy the load.

2.3.1 Load profile

The developed hybrid micro-grid supplied the load directly by 380Vac through a transformer. The power system grid included generation, transmission, and distribution. According to the generation system, the total generated power, such as PV and Wind, were connected in parallel. The battery was used as a back-up system during peak demand and fluctuations in the power generated from renewable energy sources. Figure 3 illustrates the block diagram of the developed system and Table 1 presents the summary of all the variables for the developed hybrid micro-grid.

Fig. 3
figure 3

Block diagram of the developed system

Table 1 Required values for the developed system

3 Energy management strategy for the developed hybrid micro-grid

The system consisted of two renewable energy sources (wind and PV power plants), an energy storage system, and a generator that supplied electricity to the load demand when the utility grid was unavailable. The following formula in Eq. (1) was used to determine the net power generation:

$${{\text{P}}}_{{\text{G}}}= {{\text{P}}}_{{\text{pv}}}+{{\text{P}}}_{{\text{wind}}}+{{\text{P}}}_{{\text{batt}}}$$
(1)

where, \({{\text{P}}}_{{\text{G}}}\) the power generation; \({{\text{P}}}_{{\text{pv}}}\) the power produced from PV; \({{\text{P}}}_{{\text{wind}}}\) the power produced from Wind; \({P}_{batt}\) the power produced from Battery.

When there was an excess of power generation, the battery was charged; when there was not enough power generation to meet the load demand, the battery was discharged. According to the developed energy management system (EMS), the power generation was supplied the load demand through four scenarios and with the help of the battery, a diesel generator, and the utility grid. Figure 4. shows the architecture of the energy management algorithm flow chart. First, the power generated by various sources and the load demand was measured using the scenarios listed below.

Fig. 4
figure 4

Flowchart of the energy management strategy for the hybrid microgrid

Case 1: When the load demand is met by the power generated.

$${{\text{P}}}_{{\text{L}}}= {{\text{P}}}_{{\text{pv}}}+{{\text{P}}}_{{\text{wind}}}$$
(2)

According to this scenario, the load was continuously supplied by the power generated from wind power plant and PV power plant sources as illustrated in Eq. (2).

Case 2: When the power generation was greater than the load demand.

$${{\text{P}}}_{{\text{pv}}}+{{\text{P}}}_{{\text{wind}}} >{\mathrm{ P}}_{{\text{G}}}$$
(3)

In this case, the power generation exceeded the load demand as presented in Eq. (3); as a result, the load demand was satisfied by the power generation, and the surplus was used to charge the battery. The SOC of the battery was firstly measured and see if it fell below the maximum value, which was 100%. When the condition was satisfied, the load was supplied and the battery was also connected to be charged until its SOC reached the maximum value. When the battery was fully charged, it was disconnected and waited the discharge phase as presented in Eqs. (4), (5), which show the charging condition. The excess of production was supplied to the utility grid. The conditions were formulated as below:

$${{\text{SOC}}}_{{\text{min}}}<{{\text{SOC}}}_{{\text{batt}}}<{{\text{SOC}}}_{{\text{max}}}= 20\mathrm{\%}<{{\text{SOC}}}_{{\text{batt}}}<100\mathrm{\%}$$
(4)
$${{\text{P}}}_{{\text{G}}}> {{\text{P}}}_{{\text{L}}}={\text{Charging}}$$
(5)

Case 3: when the power generation is not enough to meet load demand as presented in Eq. (6).

$${{\text{P}}}_{{\text{pv}}}+{{\text{P}}}_{{\text{wind}}} < {{\text{P}}}_{{\text{G}}}$$
(6)

The battery was used to supply the load, in this case because the power generation was less than what was required to meet the load demand as shown in Eqs. (6), (7) give the condition of discharge. The energy management system (EMS) calculated and checked the difference between the available power generation from the renewable energy sources and load. It also measured the SOC of the battery at the same time. When the power from the battery was sufficient to meet the demand of the load, when the condition was satisfied, then the battery was discharged until its SOC reached the minimum point. In Eq. (8), the supply power formula is given where the battery is used to support the load. Equations (9), (10) and (11) presents the operating modes of the battery.

$${{\text{P}}}_{{\text{G}}}<{{\text{P}}}_{{\text{L}}}=\mathrm{Battery \,Discharging}$$
(7)
$${{\text{P}}}_{{\text{L}}}= {{\text{P}}}_{{\text{PV}}}+{{\text{P}}}_{{\text{wind}}}+{{\text{P}}}_{{\text{batt}}}$$
(8)
$${{\text{SOC}}}_{{\text{batt}}}=20\mathrm{\%}=\mathrm{Battery \,Disconnected}$$
(9)
$$SOC\le 20\%=Charge \,battery$$
(10)
$$SOC>20\%=Discharge \,battery$$
(11)

Case 4: When the battery reached its minimum value and the generated power was less than the load demand.

$${{\text{P}}}_{{\text{PV}}}+{{\text{P}}}_{{\text{wind}}}+{{\text{P}}}_{{\text{batt}}}<{{\text{P}}}_{{\text{L}}}$$
(12)

In this case, the SOC of the battery reached its minimum value, which was 20% thus, the battery was disconnected and Eq. (12) presents the formula of the power supplied with the support of the battery when this total amount becomes less than the demand of the load. At this stage, the load demand was provided by the help of the generator or the utility grid based on the availability of the utility grid. When the utility grid was available, then the utility grid supplied the load and when the utility grid was not available, then the diesel generator was switched on to supply the load. The EMS checked the availability of the generated power from the renewable energy sources to see if it was \(\ge\) 20% of the total power produces from the renewable energy sources. When the condition was approved, then the battery was connected to be charged by the available power generation. In contrary, when the condition was not satisfied, then the available generated power from the renewable energy sources was added to the utility grid or generator to supply the load. For this study, it was specified that the battery could be charged when the available power was \(\ge\) 20% of the total production, when it reached its minimum value. Charging a battery with a greater power input, compared to a smaller one, offers several advantages in terms of efficiency, charging time, and overall battery performance. The flow chart architecture of the EMS is presented in the Fig. 4 below.

4 Simulation results

The developed energy management system algorithm was designed and built on MATLAB/SIMULINK environment by physical modelling. The Stateflow logical programming environment was used to design the energy management system algorithm. All the components of the model were represented by their respective model blocks available in Stateflow logical programming environment. This section is focused on the different simulation results of the developed energy management system algorithm and considers various scenarios. Adopting scenarios allows to position with a neutral and objective point of view while also better understanding the real environment. Scenarios are essential for providing a clear technique and strategy. As a result, considering the scenarios in chronological order offers a very helpful direction. The Stateflow logical programming environment is used in the implementation of the developed energy management system algorithm. The operational mode of Stateflow environment refers to a logical system that can be either 0 or 1. When the output of the flow chart reads 1, it signifies the system is operational (ON), and when it reads 0, it means the system is OFF. The test parameters for each component used in the simulation are presented in the Table 2.

Table 2 Test parameters used for the MATLAB simulation

Scenario 1: In this first case, the power production from the renewable energy sources was equal to the total load power demand. As shown in Table 1, the load power was fixed at 800 kW. Thus, the total power generated from the renewable energy sources was supplied to the load without any interruption and in this stage, the battery, utility grid and diesel generator were disconnected from the system. Figure 5 below illustrates the power generation from the renewable sources, which are PV and wind.

Fig. 5
figure 5

Power generated by renewable energy sources

As it can be seen in Fig. 5, the power generated is equal to the load demand power. Figure 6 presents the chart of the output results for this first scenario, in which all the results are displayed graphically. It is shown that only the load is supplied and other outputs, which include the battery, utility and diesel generator are not operational.

Fig. 6
figure 6

Stateflow output results chart

Scenario 2 In this second case, the total power generation from the renewable energy sources became higher than the load demand power. As shown in Fig. 7, the power produced from the renewable energy sources is more than the expected load demand power. Thus, the battery is charging according to the charge / discharge condition and when the maximum value was reached then it was automatically disconnected from the system and the excess of production was directed to the utility grid.

Fig. 7
figure 7

Power generated by renewable energy sources

Figure 8 presents the graphical output results from the block diagram, showing the operating mode of the system. The result shown that the battery is charging and at the same time the load is being supplied.

Fig. 8
figure 8

Stateflow output results chart

In Fig. 9 below, the battery is fully charged. Therefore, it was disconnected and the surplus of production was directed to the utility grid. In this case, the load demand and utility grid were completely supplied until the production condition change.

Fig. 9
figure 9

Battery fully charged

Figure 10 also shows the output results from the Stateflow chart in which all the outputs (variable AC load, battery, utility grid and diesel generator) are presented. It is shown that the two outputs are operational, the load demand and the utility grid. This shows that the battery is fully charged and waiting for the discharging phase.

Fig. 10
figure 10

Stateflow output results chart

Scenario 3 In this third case, the power generated from the renewable energy sources became less than the load demand power as illustrated in Fig. 11, thus, the load demand was met by the assistance of the battery energy storage.

Fig. 11
figure 11

Power generated by renewable energy sources

In Fig. 12, it is shown that the battery was at its maximum value (100%) and it is discharging according to the stated condition. In this case, the battery was discharged until it reached its minimum value (20%) or the condition changed.

Fig. 12
figure 12

Battery discharging

Figure 13 shows the stateflow chart, where the output results are displayed. The first and second graphs show that the load and the battery are in operating mode and the two other outputs, which are the utility grid and diesel generator are disconnected. In Fig. 14, the state of charge of the battery is presented. It shows that the battery has reached its minimum value (20%) and was automatically disconnected from the system. In this stage, according to the developed energy management system, the load demand was met by the help of the utility grid or diesel generator based on the utility grid availability.

Fig. 13
figure 13

Stateflow output results chart

Fig. 14
figure 14

Battery discharged and disconnected from the system

When the battery reached its minimum value, the condition was that, if the utility grid was available, then the load was supplied by the utility grid and if not, the diesel generator was switched on to supply the load. Additionally, the developed energy management strategy stated that the battery could only be charged if the power generated from the renewable energy sources was more or equal to 20% of the total produced power from these sources. The total power produced from the renewable energy sources was 1 MW and 20% of this production was 200 kW, thus, the battery could only be charged when the power generation was \(\ge\) 200 kW. This condition of charging a battery with a higher power input, compared to a smaller one, offers several advantages in terms of efficiency, charging time, and overall battery performance.

The Stateflow chart is shown in Fig. 15, where the output results are displayed. The load was supplied by the assistance of the utility grid and the available power supplied from the renewable sources. The battery was charging through the power generated from the renewable energy sources because the power generated from the renewable energy source exceeded 20% of the total power produced in this case. When the power generated from the renewable energy sources dropped below 20% of the total power generated, which means below 200 kW as illustrated in Fig. 16, the battery was assumed to be automatically disconnected from the system as defined from the algorithm and it is shown in Fig. 17.

Fig. 15
figure 15

Stateflow output results chart

Fig. 16
figure 16

Power generation by renewable energy sources

Fig. 17
figure 17

Output results from the developed energy management system chart

Figure 17 shows the Stateflow chart, where the output results of this case are presented. It is seen that the system is operating on grid connected mode and the battery is disconnected from the system.

When the utility grid became unavailable, the diesel generator was switched on to supply the load as shown in Fig. 18. The load was supplied through the diesel generator and the available power produced from the renewable energy sources. The battery was charging at the same time because the generated power from the renewable energy sources was more or equal to 20% of the total power generated (\(\ge\) 200 kW).

Fig. 18
figure 18

Stateflow output results chart

The output results from the Stateflow chart is presented in the Fig. 18 above. The results show that the load, battery and diesel generator graphs are in operating mode (1) and the utility grid graph is (0), which shows that the utility grid is unavailable. As discussed for the utility grid availability case, when the power generated from the renewable energy sources became less than 20% of the total power generated, which means below 200 kW as illustrated in Fig. 19, then the battery was automatically disconnected from the system and only the load demand was supplied from the available power produced and diesel generator.

Fig. 19
figure 19

Power generation by renewable energy sources

Figure 20 shows the Stateflow chart, where the output results of the presented case are shown. It is seen that the load is supplied through the diesel generator and the battery is disconnected from the system because the power generated is less than 20% of the total power produced from the renewable energy sources.

Fig. 20
figure 20

Stateflow output results chart

The demand was supplied via the diesel generator, and the developed energy management strategy was continuously checking the power produced from the renewable energy sources and the utility grid availability. Once the power generated was enough to provide power to the load demand or the utility grid became available, then the diesel generator was switched off. This developed algorithm enabled to provide the variable AC load with uninterrupted power and to keep the SOC of the battery in the admissible limits by charging the battery at higher power. In this application, because of the intermittent nature of the renewable resources, a higher charging power is required to fully recharge the battery in a shorter amount of time than usual. The results have shown that it is possible to maximize the charging time by using a greater power. Moreover, a higher power charging of a battery has presented a better energy density utilization. By utilizing the developed control rules for the hybrid renewable microgrid, the system achieved power balance and the battery SOC maintained the required value for extending the battery life.

5 Conclusion

This paper presented an energy management strategy for hybrid microgrid system using renewable energy. Different scenarios were used during the simulation to show the robustness and the effectiveness of the developed energy management system control to handle the load in both islanded mode and grid connected mode and ensure the proper operation of the battery energy storage system in hybrid microgrid system. The variable AC load for the developed hybrid microgrid system was fixed to 800 kW and the total generation power from the renewable energy sources was 1 MW. To achieve the aim and objectives of the research, a hybrid microgrid model was implemented and developed using MATLAB/Simulink software software and an energy management system algorithm was developed using Stateflow logical programming environment in MATLAB/Simulink software. The energy management strategy dictated that the battery can only charge if the generated power from renewable sources is equal to or greater than 20% of the total production. The overall power supply from renewable sources is 1 MW, and 20% of this amount is 200 kW. Hence, the battery can only charge when the power production is ≥ 200 kW. This condition of charging the battery with a higher power input, offers various advantages in terms of efficiency, charging time, and overall battery performance compared to a scenario with a smaller input. The results show that this developed algorithm was able to control the energy flow between the hybrid micro-grid system and the variable AC load directly connected as well as connected to the utility grid and also to ensure a proper relation between the charging/discharging rate of the battery energy storage system based on their operating conditions and finally, it allowed to keep the SOC of battery in the admissible limits. To improve the overall reliability of the system, more research in this area is necessary. In this study, excess energy was stored in the battery and then sent to the utility grid because renewable sources sometimes produce more energy than the load demands. Developing an energy management plan that maximizes the use of this extra energy is advised. Examples of such loads include water pumping, ambient heating or air conditioning, and water heating with storage tanks.