**1. Introduction**

Renewable energy systems, such as solar panels and wind turbines generate power from natural resources that are available intermittently. Since they produce variable power, their effective dissemination can be accelerated by better control and monitoring. Traditionally, data acquisition systems (DAQs), usually centralized, are used for collecting all system data [1]. However, the cost of commercial DAQs is the most significant barrier for greater diffusion. IoT (Internet of things) based smart meters have recently gained substantial popularity for control and measurement data. Indeed, their ability to communicate data over networks offers a wide range of applications. Therefore, IoT devices can potentially be useful for real-time energy management. Accordingly, energy production efficiency and reliability can be significantly improved ([2–4]). This can help reduce dependence on traditional fossil fuel-based energy sources and promote renewable energy.

However, implementing IoT in renewable energy systems faces several challenges due to the variety of protocols and devices available in the market [5]. This can make it difficult to integrate IoT devices while ensuring their compatibility with the existing infrastructure [6].

On the other hand, defined as the combination of the physical system and its digital model, the Digital Twin (DT) paradigm can be used to predict energy production and consumption. It also enables predictive maintenance [7]. Therefore, it is crucial to implement

**Citation:** Chalal, L.; Saadane, A.; Rachid, A. Unified Environment for Real Time Control of Hybrid Energy System Using Digital Twin and IoT Approach. *Sensors* **2023**, *23*, 5646. https://doi.org/10.3390/s23125646

Academic Editors: Antonio Puliafito, Antonio Cano-Ortega and Francisco Sánchez-Sutil

Received: 3 May 2023 Revised: 3 June 2023 Accepted: 12 June 2023 Published: 16 June 2023

**Copyright:** © 2023 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https:// creativecommons.org/licenses/by/ 4.0/).

techniques that provide a wide range of operational data about the actual system [8]. IoT technology can be associated with DT thanks to their ability of actuation and sensing.

In this work, our objective is to build a DT of a standalone PV system to deal with real-time energy management challenges. Figure 1 depicts the diagram of the digital twin as developed in this work:


**Figure 1.** Diagram of the digital twin of the standalone PV system.

To experimentally validate the proposed framework, we have developed a lab demonstrator according to IoT-based architecture for embedded and distributed instrumentation. Furthermore, to cope with the devices' heterogeneity, we use MATLAB Simulink. Indeed, this is a comprehensive software environment that can communicate with sensors and Programmable Logic Controllers through client/server applications.

This document is structured as follows. First, we present a review of the literature related to our work. In the second part, we detail our test bench which constitutes the physical part of the proposed Digital Twin. In the third part, we present an approach based on the Energetic Macroscopic Representation (EMR) formalism as a numerical counterpart of our system. Finally, the experimental validation of the resulting digital twin will be discussed.
