A Novel Internet of Energy Based Optimal Multi-Agent Control Scheme for Microgrid including Renewable Energy Resources

The increasing integration of Renewable Energy Resources (RERs) in distribution networks forms the Networked Renewable Energy Resources (NRERs). The cooperative Peer-to-Peer (P2P) control architecture is able to fully exploit the resilience and flexibility of NRERs. This study proposes a multi-agent system to achieve P2P control of NRERs based Internet of Things (IoT). The control system is fully distributed and contains two control layers operated in the agent of each RER. For primary control, a droop control is adopted by each RER-agent for localized power sharing. For secondary control, a distributed diffusion algorithm is proposed for arbitrary power sharing among RERs. The proposed levels communication system is implemented to explain the data exchange between the distribution network system and the cloud server. The local communication level utilizes the Internet Protocol (IP)/Transmission Control Protocol (TCP), and Message Queuing Telemetry Transport (MQTT) is used as the protocol for the global communication level. The effectiveness of the proposed system is validated by numerical simulation with the modified IEEE 9 node test feeder. The controller proposed in this paper achieved savings of 20.65% for the system, 25.99% for photovoltaic, 35.52 for diesel generator, 24.59 for batteries, and 52.34% for power loss.


Introduction
Renewable energy is going to be an important source for power generation in the near future because we can use these resources again and again to produce useful energy. The energy resources are normally classified as fossil resources, renewable, and nuclear energy resources. Different renewable energy resources, such as hydropower, wind, solar, biomass, ocean energy, biofuel, geothermal, etc., provide 15-20% of the total world's energy. The world is going to turn into a global village due to more requirement of energy due to fast-growing population, which leads to the use the fossil fuels such as coal, gas, and oil to fulfil the energy requirement, which creates unsustainable situations and many problems such as depletion of fossil fuels, environmental and geographical conflicts, greenhouse effect, global warming, and fluctuation in fuel prices. Due to environment-friendly and less emission of gases from renewable energy, it is considered as sustainable energy; also supported for the society from each dimension: economic, social, and environmental [1]. are dependent on renewable and load forecasting. Regarding the dispatch intervals, both the primary and the secondary controls are operated for sharing the actual power deviation taking place from the dispatch values. A consensus algorithm-based secondary control and the distributed optimisation algorithm-dependent tertiary controls have garnered a lot of research attention owing to their increased flexibility and resilience compared to the centralised control [18,19]. Furthermore, the implementation of a distributed algorithm is dependent on Multi-Agent System (MAS), wherein multiple subsystems/agents interact with one another with the help of sparse communication networks [20].
To the best of the authors' knowledge, achieving reactive power/active power sharing and voltage and frequency regulation, with preserved local information privacy, is still the open question. To this end, this paper presents a distributed consensus-based method to achieve reactive power, active power sharing and voltage and frequency regulation in MG. First, the original control problem is transformed into an equivalent active power reference generation problem, which can be solved by obtaining the global active power utilization level. Further, a distributed diffusion algorithm is proposed to acquire this global variable. In addition, this study objectives to offer potential solutions for following situations: (i) distributed controllers may neither be located at the same location as distributed generations nor have a proprietary communication network. A remote control of microgrids by the Internet, taking communication latency into consideration, is required. (ii) For microgrids governed via multi agent systems, each agent or sub-multi agent systems can be practically owned via different stakeholders who could cooperate or work independently. (iii) With the features in Internet of Things and renewable system, the number of controllable units in microgrid is dramatically increasing. Any distributed control system scalability to withstand increasing numbers of distributed generations is an issue worthy of exploration.

Related Works
Active power-sharing traditionally takes place through primary control. The centralised controller is then used to offset drop control deviations in frequency [21,22]. There is no flexibility in the centralised control structure, and there can be a single failure. The literature therefore reports distributed control algorithms [23]. The information shared by the distributed controllers over a sparse communication network can be used to achieve active power sharing and frequency control [24]. However, the distributed generations are transmitted directly to their neighbours without protection of their privacy or sensitive local data such as power outputs, usage levels, power capacity, etc.
In [25], coordinated controls were proposed, including for different distributed energy storage systems, to equalize charge status. A secure cloud-based multi-agent platform is not, however, investigated. In [26], the Combination of Communication Technology and Hierarchical Control Method proposed a coordinated method for the assessment of the state-of-the-art balance in Alternating Current (AC) MG. However, the proposed control structure will inevitably invalidate intact high level control functions. In [27], the authors proposed an efficient distributed control method for the synchronisation in the Island micro grid of several Renewable Energy Resources (RERs). The secondary control technique is developed to remove deviations in frequency and to ensure a certain time-efficient power sharing. Within a limited time frame, the proposed end time controller allows the unconnected design for the voltage control and an alternate time frame for reactive power sharing. However, the authors do not consider the graph network for data and information transfer between the MG connect agents.
In [28], the authors suggested a distributed iterative learning environment to address Direct Current (DC) microgrid's current/voltage sharing problem. The optimal control method, which is further determined by using the iterative value algorithm, was derived in game theory. An adaptive dynamic programming architecture and algorithm were developed to share current while simultaneously changing the DC bus's voltage to its rated value. However, active and reactive power sharing is not investigated. In [29], an MG isolated composed by parallel connected inverters from multiple voltage sources was analysed by the researchers. The primary control was integrated into every inverter by internal voltage and current systems with PR trimmings, Virtual Impedance, external voltage, and frequency drops controllers. A secondary frequency restoration function has been implemented by the investigators. This contributes to the implementation of the diffusion algorithm including a frequency control and a single communication network delay. However, a secure cloud-based platform for multi-agents is not investigated. In [30], the authors proposed a split multi-agent finite time control approach with a balance of load delay and voltage restoration in the battery's DC MG. Theoretically, for each device, delays can be different and endless. The linearization feedback approach is used with the input time delays in dual integrated and single integration systems in order to transform charging and voltage recovery problem. However, the distributed control for multi agent system governed microgrids in Internet of Energy is not investigated.
In order to meet load demand and protection demand, the authors in [31] created a Hybrid control system, based on a multiagent system event, which utilizes online supplies of renewable energy. However, there is no study of the active and reactive power sharing. In [32], the authors suggested a new control method for voltage/frequency restore approach based on the consensus algorithm and proposed method implemented in island microgrid systems (MGs). However, a secure cloud-based platform for multi-agents is not investigated. The authors proposed a diffused method for coordination control of hybrid microgrids in [33]. The method proposed regulates accurate dc current and reactive power shares between distributed microgrid generators, maintains power-sharing between the two microgrids and restores a DC voltage, and the AC frequency, to their rated values. However, the authors do not consider the graph network for data and information transfer between the MG connect agents. In [34], researchers suggested a collapsing distributed and hierarchical cooperative control method for microgrid cluster, including distributed layer generation, micro grid layer, and cluster layer controls for MG. The distributed generation layer control regulates each distributed unit's current/tension locally. The control of the microgrid layers for each microgrid is performed to positively manage distributed generating units via several small communication networks. The control of the Cluster-Layer co-ordinates micro grids on the basis of a more advanced peer-to-peer communication interface between micro-grid-agents. However, the distributed control for multi agent system governed microgrids in Internet of Energy not investigated. In [35], a new distributed multi-agent framework based on the cloud layer computing architecture is developed for real-time microgrid economic dispatch and monitoring. In [36], the Time of Use (ToU) model is proposed to define the rates for shoulder-peak and on-peak hours. A two-level communication system connects the microgrid system, implemented in MATLAB, to the cloud server. In [37], the researchers proposed a multi-agent and multi-layer architecture for acquiring the P2 P control of the MGs. Here, the control framework was distributed entirely and it contained three control layers that were operated in every MG. For the primary control, the researchers adopted a droop control for every MG-agent to carry out a localized power-sharing. The researchers proposed a distributed diffusion for each secondary control that helped in voltage/frequency restoration and arbitrary power-sharing amongst the microgrid. However, a cloud-based platform for multi-agents is not investigated.
The existing technical studies do not address the following limitations.

•
The critical bus voltage, subject to distributed secondary voltage regulation, must be restored to ensure continuous operation of sensitive loads. Literature [38] provides critical bus voltage restoration, but it doesn't simultaneously maintain accurate reactive-power sharing among units of Renewable Energy Resources (RERs) [39].

•
To the best of our knowledge, a behaviour and analysis of distributed secondary control, when the AC side voltage of a distributed generator unit reaches to its limit, has not been reported. • Literature [40][41][42] assume purely inductive networks for small signal dynamic analyses of the distributed secondary frequency controller [42] and the distributed sec-ondary voltage controller [40,41]. For a practical micro grid system, especially the low voltage (LV) micro grid system • The active power, reactive power-sharing simultaneous regulation are not investigated. Second, the distributed diffusion control method for multi agent governed microgrids in the Internet of Energy has not been studied. This motivates us to provide a novel approach that enables the group play and plug feature, such that microgrids with multiple multi agent, owned by different stakeholders, can be flexibly controlled.

Paper Contribution
The present developments and limitations of the literature have led the researcher to propose a fully distributed diffusion based control system for the achievement of several objectives. The chief contributions of this paper are summarised as: 1.
The peer-to-peer control architecture considering multi-agent and multi-layers interaction is introduced for a distribution networks in the Energy Internet, which has not been reported in the past.

2.
This paper summarises the findings of researchers in distributed control design of RERs devices in microgrid to provide ancillary services, including equal reactive power sharing, equal active power-sharing between RES units, and controlling the load in both islanded mode and grid-connected mode.

3.
An IoT-based communication protocol including specifications such as MQTT is proposed. This improves system flexibility. The proposed system offered analytics and business intelligence (BI), which allowed the researchers to gain insights on data collected by visualizing dashboards and reports. Additionally, the use of large data-based data storage technologies enabled the system's scalability at the national level. This provided energy-efficiency strategies for the home owners and the utility companies.

Proposed System Description
Here, the researchers considered that the RESs consisted of the communication and control agents on the Internet of Energy realm, as described in Figure 1. The physical components of a general microgrid included the inverter-interfaced Renewable Energy Resources [Such as photovoltaic, wind turbine, and energy storage systems], dynamic and static loads, and the diesel generators. It was noted that a framework controlled the RESs in a microgrid, wherein one MAS agent managed every RESs. The MAS agents communicate by Local Area Network (LAN) and can access the Internet for remotely controlling the microgrid via the cloud servers. In the Energy Internet, every distributed generator/microgrid was managed by various stakeholders and their controllers on the MAS/agents differed from MG components. It was expected that number of the distributed generator and MG agents could be changed online. Hence, a remote, flexible, and distributed control and implementation framework were necessary. Figure 1

presents a proposed system.
A smart grid would need an effective measuring and communication system to continuously track the power and cost profile and regularly quantify power losses. There are several stages of data processing.
This work contains measurement units (MU) for every distribution network bus. MU is MATLAB modelling. Power and cost information is sent to the control centre regularly at a fixed time. The control centre is designed as a virtual data management and analysis platform. One approach to communication, relating to the device topology proposed, is considered. The case takes a Cloud approach, which sends its measured data directly to the cloud by any MU connected to the corresponding feeder bus, as illustrated in Figure 1.
The data transfer among the MATLAB software package and the open-source IoT framework ThingSpeak are used to model proposed communication architectures. ThingSpeak was chosen for the simulation of real-time cloud communication due to its following benefits [43]:

1.
ThingSpeak Cloud IoT platform data aggregation, tracking and analysis. In the smart grid model, the power profile is monitored on multiple ThingSpeak channels in real-time and depicted graphically.

2.
Security: The Username and password allow user authentication while each channel is equipped with its ID and accessible (see by other users). There are two keys in each channel for the application programming interface. A randomly generated read key and write key of the API. These keys can save or retrieve information from each channel over the Internet or LAN.

3.
It facilitates the double-way flow of data between the user and virtual device and allows data and remote control to be exchanged in real-time.  A smart grid would need an effective measuring and communication system to continuously track the power and cost profile and regularly quantify power losses. There are several stages of data processing.
This work contains measurement units (MU) for every distribution network bus. MU is MATLAB modelling. Power and cost information is sent to the control centre regularly at a fixed time. The control centre is designed as a virtual data management and analysis platform. One approach to communication, relating to the device topology proposed, is considered. The case takes a Cloud approach, which sends its measured data directly to the cloud by any MU connected to the corresponding feeder bus, as illustrated in Figure 1.
The data transfer among the MATLAB software package and the open-source IoT framework ThingSpeak are used to model proposed communication architectures. Thing-Speak was chosen for the simulation of real-time cloud communication due to its following benefits [43]: 1. ThingSpeak Cloud IoT platform data aggregation, tracking and analysis. In the smart grid model, the power profile is monitored on multiple ThingSpeak channels in realtime and depicted graphically. 2. Security: The Username and password allow user authentication while each channel is equipped with its ID and accessible (see by other users). There are two keys in each channel for the application programming interface. A randomly generated read key  Figure 2 shows a single photovoltaic cell diode system based upon which current source, diode, resistance series, and parallel resistance are represented. In the Figure 3 Illustration, the photovoltaic cell current-voltage characteristics are described in the mathematical equation standard [44]:

Photovoltaic Cell Modeling
where: I ph;cell , is a current (A) of photovoltaic; I 0;cell , is a saturation current of a photovoltaic; T is a temperature of a diode; k is a constant of Boltzmann (1.38 × 10 −23 J/K); R p , is a parallel resistance of PV (Ω); R s , is a series resistance of PV (Ω), V is a thermal voltage.

Photovoltaic Modeling
The photovoltaic module consisting of PV cells joined in a parallel and series shape is mentioned above. Therefore, Equation (1) derives from the mathematical standard and the PV module description of its I-V characteristic [44]: where: Vt is a thermal voltage, I PH is a photocurrent (A), R S is a series resistance, I O i a reverse leakage current, R p is a parallel resistance. The Equation (2) produces voltag and current curve as indicated in Figure 4,

Photovoltaic Modeling
The photovoltaic module consisting of PV cells joined in a parallel and series shapes is mentioned above. Therefore, Equation (1) derives from the mathematical standard and the PV module description of its I-V characteristic [44]: where: Vt is a thermal voltage, I PH is a photocurrent (A), R S is a series resistance, I O is a reverse leakage current, R p is a parallel resistance. The Equation (2) produces voltage and current curve as indicated in Figure 4,

Photovoltaic Modeling
The photovoltaic module consisting of PV cells joined in a parallel and series shapes is mentioned above. Therefore, Equation (1) derives from the mathematical standard and the PV module description of its I-V characteristic [44]: where: Vt is a thermal voltage, I PH is a photocurrent (A), R S is a series resistance, I O is a reverse leakage current, R p is a parallel resistance. The Equation (2) produces voltage and current curve as indicated in Figure 4. The PV module's photocurrent (I PH ) is determined by the amount of solar radiation falling on modulus and photovoltaic cell temperature that fits the equation below [44]: where: I PH.n is a photocurrent; G n is a irradiance where: K v is a temperature coefficient, V oc;n is open circuit voltage.
where I sc;n is a short-circuit current.  The PV module's photocurrent (I PH ) is determined by the amount of solar radiation falling on modulus and photovoltaic cell temperature that fits the equation below [44]: where: I PH.n is a photocurrent; G n is a irradiance where: K v is a temperature coefficient, V oc;n is open circuit voltage.
where I sc;n is a short-circuit current.

System of Energy Storage
The system of battery storage stores excess energy generated by generation of renewables. In the event of energy shortages from the renewable energy systems batteries will be discharged so as to meet demand for load. Simple dynamics of batteries are modelled, such as [44,45]: where bat is a maximum batteries capacity (A h), bat is a batteries state of charge (%), is a battery ampere-hour and bat is the battery current.

Diesel Generator of Disterbuted Network
In the micro grid, this diesel generator balances power and charge. A diesel engine, a control system, an exciting system, and a simulated machine are included in the models. Diesel engine and the model system governor are combined with speed inputs into one

System of Energy Storage
The system of battery storage stores excess energy generated by generation of renewables. In the event of energy shortages from the renewable energy systems batteries will be discharged so as to meet demand for load. Simple dynamics of batteries are modelled, such as [44,45]: where Q bat is a maximum batteries capacity (A h), SOC bat is a batteries state of charge (%), B AH is a battery ampere-hour and i bat is the battery current.

Diesel Generator of Disterbuted Network
In the micro grid, this diesel generator balances power and charge. A diesel engine, a control system, an exciting system, and a simulated machine are included in the models. Diesel engine and the model system governor are combined with speed inputs into one unit (in p.u.). The mechanical capacity of the diesel motor is the block output. The control function is modelled as follows [46]: where T 1 , T 2 and T 3 are regulator time constants, k is a proportional gain and. The actuator transfer function is as: where T 4 , T 5 and T 6 are actuator time constants. An excitement system is represented by the following transfer function for the synchronous machine.
where V ro is a regulator's output, V f d is a exciter voltage, T e is time constant (seconds), K s is the gain.

Problem Formulation
This paper considered an MG with N controllable distributed generator (indexed as I = 1, 2, . . . , N.). The MGs electrical network is presented using an elaborate weighted graph, [47].

Primary Control of Inverter
The basic graph for Renewable Energy Resources (RERs) connected via AC/DC converters and LCL filters is shown in Figure 5. The proposed primary control is shown in Figure 5 [48].
where ω ni and V ni are the nominal set points for frequency and voltage, ω i and V oi are the frequency and voltage of DG i, m Pi and m Qi are the frequency and voltage magnitude droop coefficients of DG i, respectively.
where 1 , 2 and 3 are regulator time constants, k is a proportional gain and. The actuator transfer function is as: where 4 , 5 and 6 are actuator time constants. An excitement system is represented by the following transfer function for the synchronous machine.
where is a regulator's output, is a exciter voltage, is time constant (seconds), K s is the gain.

Primary Control of Inverter
The basic graph for Renewable Energy Resources (RERs) connected via AC/DC converters and LCL filters is shown in Figure 5. The proposed primary control is shown in Figure 5 [48].

MASs Communication
The communication networks of microgrid having N agents was represented using a graph: G = (V G , E G ) having a defined set of nodes V G = {v 1 , v 2 , . . . , v N } and edges E G ⊆ V G × V G . All nodes presented in the graph G(agents) showed a one-to-one correspondence to the units in the graph T (renewable energy resources). Furthermore, edges in G, which represented the communication links for the data exchange, differed from electrical connection seen in T . In addition, set of neighbors described in the ith node of G was represented by N i = v j ∈ V G : v i , v j ∈ E G . The researchers represented the adjacency matrix as a ij ⊆ R n×n [11]. Here, the term a ij represented the information that was exchanged between the units i and j, wherein a ij = 1 when units i and j were connected with the edge (v i , v j ) ∈ E G , else a ij = 0. The researchers represented the Laplacian matrix as L = l ij ⊆ R n×n where each element l ij = ∑ n i=1 a ij − a ji . They described the pinning matrix as G = diag[g i ] ⊆ R n×n and g i = 1 when the RER/agent could access the references ω re f and V re f , else g i = 0. Figure 6 presents the data exchange between the controllers. resented by = { ∈ : ( , ) ∈ ℰ }. The researchers represented the adjacency matrix as [ ] ⊆ × [11]. Here, the term represented the information that was exchanged between the units and , wherein = 1 when units and were connected with the edge ( , ) ∈ ℰ , else = 0. The researchers represented the Laplacian matrix as = [ ] ⊆ × where each element = ∑ − =1 . They described the pinning matrix as = [ ] ⊆ × and = 1 when the RER/agent could access the references and , else = 0. Figure 6 presents the data exchange between the controllers.

Proposed Secondary Distributed Controller
The chief objective of this section is to add to droop controller of renewable energy resources a secondary controller. In order to control the frequency and voltage of the system in a common connecting point, the controller receives information from neighbouring RES and sharing power between appliances. Moreover, a virtual leader can be assigned to one RES or a couple of storage devices on the system. The leader has the tension and frequency setpoints of the system and shares the information with his neighbouring storage units. The RES model needs to be developed in order to develop such a control design. A simplified RES model has been developed in our recent work. The model reflects the dynamics of the DC and the RES active power. The RES dynamics of devices in smart grids can be precisely incorporated into this model. The RER device dynamics can be displayed [49]:

Proposed Secondary Distributed Controller
The chief objective of this section is to add to droop controller of renewable energy resources a secondary controller. In order to control the frequency and voltage of the system in a common connecting point, the controller receives information from neighbouring RES and sharing power between appliances. Moreover, a virtual leader can be assigned to one RES or a couple of storage devices on the system. The leader has the tension and frequency setpoints of the system and shares the information with his neighbouring storage units. The RES model needs to be developed in order to develop such a control design. A simplified RES model has been developed in our recent work. The model reflects the dynamics of the DC and the RES active power. The RES dynamics of devices in smart grids can be precisely incorporated into this model. The RER device dynamics can be displayed [49]: . .
For the development of such a simplified model, voltage controller and current controller dynamics are supposed to be much faster than a droop controller, so its dynamics may be ignored. u P i for distributed active power-sharing is input in the above-mentioned model, and D P i reflects RESs heterogeneity. To ensure the equality of power sharing, D P i P i should be controlled by batteries in order to increase power sharing in a RES with higher capacity (lower drop-in gain, D P i ). This study regulates nominal voltage and the frequency of adjacent RES units in order to minimize communications between RERs. The control design will require only nominal frequencies ω nom i and the nominal tension |V nom i | of its adjacent devices, and thus, only the frequency and voltage signals from neighbouring RESs.
These inputs include The overall dynamics of the ith is formulated as [49]:  (20) .
Let ω re f and V re f be a reference voltage and frequency of RES. These references are used as external commands, which force RES to precisely converge voltage and frequency to their desired values. The respect, design of diffusion is proposed as: Let . P i D P i P i and . Q i D Q i Q i , then a closed-loop model of renewable energy resources with a diffusion design Equations (22)-(25) are [49]: . . .
where L is symmetric matrix, P(0) is vector of initial proportional active power. e −C 2 Lt is a symmetric matrix.
.ω i Denote D 0 diag {a 0i } i=1,...,N . Consequently, we obtain from (35) that If at least one of the folder is connected with a leader, e.g., D 0 is not a zero matrix, the communications graph G between the followers was shown in [49] that all the values on C 2 L + C ω 0 D 0 of the matrix were positive in real parts for all C 2 > 0 and C ω 0 > 0. lim t→∞ω (t) = 0. This corresponds to the battery frequency diffusion of the reference frequency ω re f . Figure 7 shows the proposed method flowchart.

Proposed Internet of Energy Communication Platform
The decentralised controller of a smart MG helps in managing the system operating conditions if there is some disturbance. Furthermore, the IoT technology can be used for communicating between the appliances present in smart homes, central controller, or power management centres. The researchers proposed the IoT platform for collecting the data, monitoring, managing, and controlling a smart microgrid. All appliances and energy resources were integrated and connected in this platform. The major IoT platform layers

Proposed Internet of Energy Communication Platform
The decentralised controller of a smart MG helps in managing the system operating conditions if there is some disturbance. Furthermore, the IoT technology can be used for communicating between the appliances present in smart homes, central controller, or power management centres. The researchers proposed the IoT platform for collecting the data, monitoring, managing, and controlling a smart microgrid. All appliances and energy resources were integrated and connected in this platform. The major IoT platform layers included energy supply layer, network layer, energy management layer, energy appliance layer, control system layer, and the Internet of Things service layer, as presented in Figure 8. (a) Agent Layer The device or perception layer was referred to as the layer of different component [50]. Various IoT users are included in the device layer, which comprises of smart electri vehicles, smart homes, and transportation systems, along with RERs such as FCs, MTs and the WTs. Additionally, this layer supported different kinds of sensors for measurin the real-time environmental and physical state of the components and the actuator needed for adjusting them. Hence, WSNs and WSANs were seen to be an inseparabl component of this layer.

(b) IoT platform layer
The IoT platform layer is the sensors layer. Moreover, this layer supports differen types of sensors to monitor the environmental or physical condition of connected agent and to adjust them in real-time. Wireless sensor and actor network (WSANs) and wireles sensor network (WSNs) are the two pieces of the sheet that are inseparable. WSNs can b described as a number of sensors that are used to sense the environmental conditions and transmit them through a wireless network to other devices or upper layers.  It is a demanding job to develop an energy management distributed Energy Internet (IoE) base. The role of the platform is to (1) incorporate the micro-grid tools into the communications system and (2) link to the IoE cloud in order to track and manage the devices. The IoE communications network proposed is composed of four different layers, as defined in Figure 8. Following is a summary of each layer.

(a) Agent Layer
The device or perception layer was referred to as the layer of different components [50]. Various IoT users are included in the device layer, which comprises of smart electric vehicles, smart homes, and transportation systems, along with RERs such as FCs, MTs, and the WTs. Additionally, this layer supported different kinds of sensors for measuring the real-time environmental and physical state of the components and the actuators needed for adjusting them. Hence, WSNs and WSANs were seen to be an inseparable component of this layer.

(b) IoT platform layer
The IoT platform layer is the sensors layer. Moreover, this layer supports different types of sensors to monitor the environmental or physical condition of connected agents and to adjust them in real-time. Wireless sensor and actor network (WSANs) and wireless sensor network (WSNs) are the two pieces of the sheet that are inseparable. WSNs can be described as a number of sensors that are used to sense the environmental conditions and transmit them through a wireless network to other devices or upper layers. Layer of data processing is defined as the layer which allows processing and storing a huge volume of data, which was assembled from lower layers with the help of powerful processors [50].
(e) Layer of cloud The cloud layer stores a historical data from distributed energy resources (DERs) for the purpose of global tracking. One of the features required for IoT applications and services is to store historical data [51]. The IoE cloud layer includes virtualized servers. In addition, an application interface has been introduced with preserved historical data for each DER. A vast volume of data can be saved and maintained in the historical archive, which is supported by the application interface to the cloud infrastructure [52].

MQTT Knowledge
Message Queuing Telemetry Transport (MQTT) is a lightweight protocol that makes effective use of the network bandwidth with a fixed header of two bytes. The MQTT is operational on TCP and ensures that all messages are sent from agent to server.
Three main players, MQTT broker, MQTT publisher, and a MQTT subscriber, are included in a protocol [53]. The MQTT subscriber and publisher are indirectly linked and do not use one IP address simultaneously. MQTT Broker refers to the network gate way that filters, obtains, and distributes the publishers' messages to the thousands of simultaneouslyconnected MQTT subscribers. An MQTT broker takes care of the customer authorization and initialization process necessary for communication. To publish the information, the MQTT publishers utilize custom themes for catering to their clients. The MQTT protocol did not use Metadata marking. After that, the MQTT topic management presents the metadata for a message load, which is considerable, and it can attach meaningful attributes to topic. MQTT is seen to be a string having a multi-attribute and multi-level layer. All subjects could be updated for deriving the routing data. Figure 9a presents the connection's initialization after exchanging the control packets between the clients and brokers. It was noted that the check packets for the CONNAC, Link, PUBACK, PUBLISH, SUBSCRIBE, SUBACK, etc., comprise specific instructions regarding the theme, transmission, and the payload Quality of Service (QoS). Figure 9b presents all components of the MQTT contact. Figure 10 presents an overview of smart homes' hierarchical platform with a cyber layer, physical layer, and control layer. Two communication layers were included in the hybrid platform. It was seen that in Layer one (local layer), the appliances in the smart building transmitted the MQTT messages to a Building MQTT Client (BMC), reported the events/measurement, and subscribed to the MQTT messages that BMC published for protection/control purpose. Layer two (global layer) represented the interaction between the cloud and BMC with the HTTP GET/POST requests' help. In this architecture, every appliance was equipped with a Wi-Fi module connected to the local gate way. Thus, it could periodically publish the values of a dedicated and pre-defined topic. After that, BMC subscribes to different issues and posts received values to the cloud channel. Cloud data can be accessed by the cloud MATLAB interface, which implements the designed appliance resource allocation algorithm. The researchers found that if communication failure occurs in any layer, the architecture proposed is resilient (either local or global).

Architecture of Proposed System
BMC was therefore developed to operate as a local controller for all devices in the building during any communication link failure or high network latency noted. The results section highlighted this function of the BMC [11].
MQTT protocol did not use Metadata marking. After that, the MQTT topic managemen presents the metadata for a message load, which is considerable, and it can attach mean ingful attributes to topic. MQTT is seen to be a string having a multi-attribute and multi level layer. All subjects could be updated for deriving the routing data. Figure 9a presents the connection's initialization after exchanging the control packets between the clients and brokers. It was noted that the check packets for the CONNAC, Link, PUBACK, PUBLISH SUBSCRIBE, SUBACK, etc., comprise specific instructions regarding the theme, transmis sion, and the payload Quality of Service (QoS). Figure 9b presents all components of the MQTT contact.

MQTT Broker
Topic: Data1 Topic: Data n scribes to different issues and posts received values to the cloud channel. Cloud data can be accessed by the cloud MATLAB interface, which implements the designed appliance resource allocation algorithm. The researchers found that if communication failure occurs in any layer, the architecture proposed is resilient (either local or global). BMC was therefore developed to operate as a local controller for all devices in the building during any communication link failure or high network latency noted. The results section highlighted this function of the BMC [11].

Result Analysis and Discussion Proposed Method
The proposed controller is tested with the micro grid, as shown in Figure 1. Here, researchers have described the simulated implementation of the distributed secondary controller, on a multi-agent system platform, in addition to their correlation with the cloud server and LAN. The multi-agent system was implemented in the MATLAB cluster connected to LAN via the network switch and connected to the cloud server via the Internet. Local communication was carried out by the TCP/IP protocol, whereas the TCP protocol conducted the communication between the cloud server and MAS. Communication between the agents was in the form of a client/server format with the help of ThingSpeak and could be configured for any network topology. In the ThingSpeak-based communication system, every agent acted as the server, which waits for the incoming messages. It can dispatch the messages to a corresponding technique since it was the neighbouring server's client.

Access to Internet Web Page
In this study, the researchers carried out a simulation test, where they described and discussed the results of a decentralised power-management and control approach for micro grid in Energy Internet paradigm, which was implemented using the proposed algorithm over the cloud platform for regulating the appliances in a smart home. As noted in software communication and architecture interface, a MATLAB program was present for the Main Command and Control Unit (MCCU), which helped organize all ThingSpeak platforms. The MQTT (Mosquitto) functions as a broker and bridges the home appliance subscription and MCCU publishers' gap. For regulating the home appliances through the MQTT gateway, the researchers used a custom code derived from the proposed MATLAB-based algorithm for its deployment. Here, the researchers designed a ThingSpeak dashboard interface, using a simple and effective user interface (UI), which allowed the homeowners to access and interact with the home energy management service over the cloud system. Figure 11 presents an internet web page that can be accessed in any internet browser after entering and providing their username and password. and could be configured for any network topology. In the ThingSpeak-based communication system, every agent acted as the server, which waits for the incoming messages. It can dispatch the messages to a corresponding technique since it was the neighbouring server's client.

Access to Internet Web Page
In this study, the researchers carried out a simulation test, where they described and discussed the results of a decentralised power-management and control approach for micro grid in Energy Internet paradigm, which was implemented using the proposed algorithm over the cloud platform for regulating the appliances in a smart home. As noted in software communication and architecture interface, a MATLAB program was present for the Main Command and Control Unit (MCCU), which helped organize all ThingSpeak platforms. The MQTT (Mosquitto) functions as a broker and bridges the home appliance subscription and MCCU publishers' gap. For regulating the home appliances through the MQTT gateway, the researchers used a custom code derived from the proposed MATLAB-based algorithm for its deployment. Here, the researchers designed a Thing-Speak dashboard interface, using a simple and effective user interface (UI), which allowed the homeowners to access and interact with the home energy management service over the cloud system. Figure 11 presents an internet web page that can be accessed in any internet browser after entering and providing their username and password.  This section discusses the effect of the microgrid communication system. The microgrid will exchange information in the presence of the communications device, such as load consumption and power generation. To ensure power-sharing of microgrid operating costs, the microgrid gets required power from a neighbouring microgrid. That means a communication system provides the data needed to transfer power between the microgrids, utilizing the IEEE 9 bus system in reference [54].
The experimental results noted in MATLAB for the power, voltage, and actual power of every RERs have been presented in Figures 12 and 13. All renewable energy sources in the microgrid autonomously alters their power output for fulfilling load demands. Results for Scenarios indicated that a cloud server's distributed MAS control for the remote microgrid was an effective technique. This study extracts and simulates SPR-305E-WHT-D solar. Table 1 lists these factors. Table 2. BUS generation and load parameters of IEEE 9 test system [55]. P R i and D R i are the nominal active power generation and the reciprocal of frequency droop gain of the inverter-based generator at bus i, respectively. P L i and D L i are the nominal load and the frequency coefficient of the load at bus I, respectively. P R i = 0 and D R i = 0 (P L i = 0 and D L i = 0) if no inverter-based generator (load) is connected to bus i.  P R i and D R i are the nominal active power generation and the reciprocal of frequency droop gain of the inverter-based generator at bus i, respectively. P L i and D L i are the nominal load and the frequency coefficient of the load at bus I, respectively. P R i = 0 and D R i = 0 (P L i = 0 and D L i = 0) if no inverter-based generator (load) is connected to bus i. Figure 12 illustrates the graphical user interface of power profile at demand scenario. Figure 13 illustrates the graphical user interface of reactive power profile at demand scenario. The proposed system's effectiveness of proposed scheme for remote microgrid via cloud server is validated.

Results Discussion
The results are illustrated in Figures 12 and 13 Measurement of power sharing for all renewable energy resources. It is noted from the results that: 1. In both scenarios, as Figure 12 illustrates, the aims of active power sharing can be accurately achieved. 2. From Figure 13, the suggested system can realise accurate sharing of reactive power.
As the control objective of power sharing is to make sure both reactive and active power sharing among generators follows renewable energy resources,  P R i and D R i are the nominal active power generation and the reciprocal of frequency droop gain of the inverter-based generator at bus i, respectively. P L i and D L i are the nominal load and the frequency coefficient of the load at bus I, respectively. P R i = 0 and D R i = 0 (P L i = 0 and D L i = 0) if no inverter-based generator (load) is connected to bus i. Figure 12 illustrates the graphical user interface of power profile at demand scenario. Figure 13 illustrates the graphical user interface of reactive power profile at demand scenario. The proposed system's effectiveness of proposed scheme for remote microgrid via cloud server is validated.

Results Discussion
The results are illustrated in Figures 12 and 13 Measurement of power sharing for all renewable energy resources. It is noted from the results that: 1. In both scenarios, as Figure 12 illustrates, the aims of active power sharing can be accurately achieved. 2. From Figure 13, the suggested system can realise accurate sharing of reactive power.
As the control objective of power sharing is to make sure both reactive and active power sharing among generators follows renewable energy resources, Figure 13. The graphical user interface of the reactive-power profile.    Figure 12 illustrates the graphical user interface of power profile at demand scenario. Figure 13 illustrates the graphical user interface of reactive power profile at demand scenario. The proposed system's effectiveness of proposed scheme for remote microgrid via cloud server is validated.

Results Discussion
The results are illustrated in Figures 12 and 13 Measurement of power sharing for all renewable energy resources. It is noted from the results that: 1.
In both scenarios, as Figure 12 illustrates, the aims of active power sharing can be accurately achieved.

2.
From Figure 13, the suggested system can realise accurate sharing of reactive power. As the control objective of power sharing is to make sure both reactive and active power sharing among generators follows renewable energy resources, In the system's case, the efficiency and effectiveness before applying the proposed algorithm is 0.639. After implementing the suggested MAS method, efficiency of the system is found to be 0.771. By comparing proposed algorithms with traditional method, the proposed algorithm in our work saved 20.65%.
In the photovoltaic case, the efficiency and effectiveness before applying the proposed algorithm is 0.677. Whereas after implementing the suggested MAS method, efficiency of system is found to be 0.853. By comparing proposed algorithms with traditional methods, the proposed algorithm in our work saved 25.99%.
In the diesel generator case, the efficiency and effectiveness before applying the proposed algorithm is 0.653. Whereas after implementing the suggested MAS method, efficiency of the system is found to be 0.883. By comparing proposed algorithms with traditional methods, the proposed algorithm in our work saved 35.52%.
In the battery case, the efficiency and effectiveness before applying the proposed algorithm is 0.687. Whereas after implementing the suggested MAS method, efficiency of system is found to be 0.856. By comparing proposed algorithms with traditional methods, the proposed algorithm in our work saved 24.59%.
In the power loss case, the efficiency and effectiveness before applying the proposed algorithm is 2.541. Whereas after implementing the suggested MAS method, efficiency of system is found to be 1.211. By comparing proposed algorithms with traditional methods, the proposed algorithm in our work saved 52.34%.
The comparison between with and without corrective method is illustrated in Table 2. Figure 14 shows the efficiency and effectiveness without the proposed MAS. Figure 15 shows the efficiency and effectiveness by using the proposed method. Figure 16 shows the comparison between power loss without the proposed method and with the proposed method. Figure 17 shows the improvement (%) by using the proposed method. Table 3 shows the difference between with and without the corrective method.         . Improvement (%) by using proposed method. Figure 17. Improvement (%) by using proposed method.

Conclusions
This paper is intended to serve as a preliminary basis for quantifying the environmental and social benefits resulting from microgrid implementation. This paper presents a new cooperative controller for coordinating the multi renewable energy resources operation using the IEEE 9 test feeder as the basis and with major modifications. The suggested control scheme defines the data exchange within, and among, a multi agent system to enable MG's flexible control in Internet of Energy. The proposed control objectives are achieved with the evaluation of the stability considering network latency. The proposed controller depends on the information transferring between the connected agents in the MG system. In addition, the reactive/active power is optimally shared among the RERs. The proposed controller improves the performance of the primary droop control method that can't adjust the MG-VF to their nominal values, and also, it does not enhance the power-sharing among the RERs in MG. A hypothetical multi-agent MG system is designed to prove the proposed controller's effectiveness using the MATLAB/Simulink environment in the presence of the different scenarios in MG. In addition, this study presents a hierarchical communication platform with a two-level structure, which is suitable for the microgrid management system. The proposed platform uses TCP/IP for local microgrid data exchange and as a backup communication method among microgrids in case of a failure in the cloud level communication. Finally, for accessing the data related to the power consumption of the individual loads, the researchers developed a reliable web portal associated with the IoT environment. The authors also provided a GUI after plotting a graph of power consumption for determining the power usage of every appliance. The results presented the effectiveness of proposed methods in equally sharing the active/reactive power of loads, during constant power load, and load change events. The controller proposed in this paper achieved savings of 20.65% for the system, 25.99% for photovoltaic, 35.52 for diesel generator, 24.59 for batteries, and 52.34% for power loss.
Future extension of this work may include the integration of the LoRaWAN network, with the proposed IoT architecture, because the use of the LoRaWAN technology could lead to a very promising solution, due to its good coverage capabilities (both in outdoor and in hybrid environments), whereas its most critical aspect is represented by the relatively low data throughput and duty cycle limitation.

Conflicts of Interest:
The authors declare no conflict of interest.