## 4 Case Study
### Control Grid Framework Creation  
After configuring the communications with all the equipment, we have to design an interface that provides the user with the ability to see all the registers in real time and to have the possibility to execute commands on all of them, such as start/stop actions of generation equipment, load/unload of storage systems, etc.  
Figure 7 shows instantaneous values monitored in real-time for the microgrid. As shown, there are 1320 W of photovoltaic generation, 8020 W of wind generation, with a wind speed of 5.1 m/s, compared to a demand of 9880 W. In this case, the batteries are at a standstill as there is no high demand and no surplus energy production to charge them. Otherwise, the storage system is almost fully charged, with a State of Charge (SOC) of 98%.  
The SCADA for the control of the batteries also has to be created, as can be seen in Figure 8. It shows how the batteries are in a charging process. At that moment, the microgrid is injecting 1780 W to the batteries, which have a SOC of 98%, and 266 V.  
Figure 6: Elements of the CEDER’s microgrid. Source: prepared by authors.  
Home Assistant allows visualising in real time the value of the variables collected from each of the elements, as shown in Figure 9.  
The initial situation was that of an electrical grid with two renewable generation sources (wind turbine and photovoltaic panels), a Pb-acid batteries storage system, and loads. All these elements worked independently. After applying the procedure proposed, all the elements are integrated into a single control system, and they can work in a coordinated way, which allows establishing management strategies. For example, we can set a strategy to charge the batteries when there is excess generation (See Figures 10-12).  
Figure 8: CEDER’s microgrid battery SCADA developed in Home Assistant. Source: prepared by authors.  
Figure 7: CEDER’s microgrid control framework developed in Home Assistant. Source: prepared by authors.  
Figure 10: Daily grid generation–consumption graphic (before implementation). Source: prepared by authors based on the results of this study.  
Figure 9: CEDER’s microgrid elements’ instantaneous values graphically represented. Source: prepared by authors.  
Figure 10 shows grid one-day generation and consumption curves before the conversion into a smart microgrid. The yellow area represents the power surplus for that day. As there is no communication between the elements of the grid, batteries cannot see there is a power surplus and they do not do anything.  
Figure 11 shows grid one-day generation and consumption curves (before the conversion into a smart microgrid), including batteries' manual charge when there is a power surplus, that is, an operator sees the power surplus and active batteries charge with a fix power value. The green area represents energy stored in batteries. The yellow area represents the power surplus after the batteries' manual charge.  
Figure 12 shows microgrid one-day generation and consumption curves after the implementation of the proposed procedure to convert the network section into a smart microgrid, including automatic batteries' charges when there is a power surplus. All the elements of the grid are integrated in the same control system developed with Home Assistant; therefore, the control system can detect the power surplus and send to the batteries the best charging instructions at all times. The green area represents energy stored  
Figure 11: Daily grid generation–consumption graphic with batteries in manual mode (before implementation). Source: prepared by authors based on the results of this study.  
Figure 12: Daily microgrid generation–consumption after implementation. Source: prepared by authors based on the results of this study.  
in batteries (optimized). The yellow area represents the power surplus after the batteries' automatic charge.