Design, Deployment and Performance Evaluation of an IoT Based Smart Energy Management System for Demand Side Management in Smart Grid

The Smart Grid (SG) is the technological development that incorporates digital technologies and advanced communication methods to determine and respond to variations in electricity consumption in order to revolutionize power distribution, transmission, and generation. In the conventional electrical grid, customers remain unaware to their energy usage patterns that not only results in energy loss but also money. The consumers’ usage and consumption standards need to be regulated in order to improve energy efficiency (EE). SG utilizes demand side management (DSM) for energy savings by use of various approaches like financial incentives, subsidized tariffs, and awareness to alter consumers’ energy demand. In smart environments (SE), Internet-of-Things (IoT) is evolving as a significant partner for resource and energy management. DSM in SG must take advantage of smart energy management system (SEMS) developed on smart meters (SMs) and modern technologies like IoT. Using SMs with IoT based technologies makes SEMS more effective in the SG. This paper offers design, deployment, implementation, and performance evaluation of an IoT based SEMS, including SMs as well as IoT middleware module and its related benefits. The proposed SEMS operates online and offers real-time (RT) load profiles (LPs) to customers and suppliers remotely. The customers’ LPs allow suppliers to disseminate and regulate their incentives as well as incite the customers to alter their energy consumption. Furthermore, these LPs serves as an input for developing numerous DSM approaches. The proposed solution is installed and evaluated at 4 different locations of Stylo Pvt. Ltd. Pakistan, which can communicate commands and observe the efficiency of electricity supplied by the utility. Moreover, the RT impact of using separate SM for automated control of heating, ventilation and air conditioning (HVAC) system is shown in terms of power consumption. The RT case study presents the efficacy of the proposed IoT-based-SEMS.


I. INTRODUCTION
A power grid or an electric grid (EG) is an interconnected infrastructure that supplies electricity to consumers from producers. The traditional electric grid (TEG) was established over 100 years with no significant improvements in its fundamental infrastructure, despite the fact that electricity usage and its need has increased substantially since last few decades that necessitates effective management and control of electricity consumption as well as production on the larger scale [1]. In 2021, worldwide energy demand increased by 4.6% as compared to last year, i.e., 2020 [2]. With the increase in electricity demand the associated challenges in the EG, such as load-shedding, frequent power outages and environment vulnerabilities, have also multiplied. These issues are exacerbated especially in the developing countries, where there is a significant imbalance between energy demand and generation, as well as a rise in energy loss because of mismanagement, e.g., energy demand of Pakistan has increased significantly over the last few years and continues to rise. By 2030, the overall electricity demand is estimated to be 115,000MW, whereas, the generation capacity has not kept pace with growing demand in recent years, leading to severe energy deficits [3]. The average electricity short fall in Pakistan is around 6500MW [4] and is expected to worsen in the upcoming years. Moreover, there are significant operational inefficiencies within the system; electricity theft is common in most regions of the electrical distribution network, and average line losses account for 18.7% of the total generation in the country [5].
As a remedy to the aforementioned challenges, substantial transformation in TEG is required. Smart grid (SG) is a technological development of a TEG in terms of addressing the future energy demands [1], [6]. The SG facilitates realtime (RT) surveillance of the EG by using digital technologies, advanced two-way communication to determine and respond to variations in electricity consumption in order to revolutionize the power distribution, transmission and generation components of a TEG [7]. The basic architecture of SG along with its functionalities are presented in figure 1 whereas figure 2 differentiates TEG from SG in terms their various domains. The primary concept of SG initiated from the objective of advanced metering infrastructure (AMI) that includes demand side management (DSM) as a significant contributor to enhance the Energy Efficiency (EE) [8].
The DSM is a set of techniques used to enhance and regulate the energy system through RT command and control at the consumer level [9]. The DSM techniques are shown in figure  3. The effective and successful deployment of DSM schemes alters the energy consumption patterns, which further impacts the overall load of the power supply company. Effective DSM strategy causes desirable changes in the consumer's load profiles (LPs) and alters the maximum demand (MD) of the electricity distribution network by regulating the consumer's energy usage patterns that further leads to lower electricity prices [10]. DSM is a cheaper way to provide EE, especially for developing countries where a complete infrastructure shift from TEG to SG is not a viable solution due to the massive cost. According to a report of Pakistan's center for peace development and reforms (CPDR), DSM can conserve 17 % of overall energy in Pakistan [11].
With the technological advancements, automated smart monitoring and control strategies are becoming part of DSM, giving birth to the smart energy management system (SEMS). SEMS refers to a set of computer-assisted tools used by the suppliers in order to track, regulate and improve the functioning of distribution, transmission and generation systems. It is the technological platform installed at the customer's end that enables suppliers and customers to monitor electricity usage and to manually adjust or automate energy usage inside homes, industries, buildings, or any other facility. As a result, the efficacy of DSM relies on effective Energy Management System (EMS) that produce customers' LPs and reacts to energy-saving directives and algorithms [12]. It is essential to deploy smart meters (SMs) in this regard, as they are one of the key components for converting EMS to SEMS. SMs are the integral part of communication platform in the SG. It transfers all electrical parameters to the data center regularly for the aim of tracking, control and data analysis which further plays a key role in DSM, load profiling and fault analysis [13]. Using SMs with the Internet of things (IoT) based technologies makes SEMS more effective in the SG [14].
In smart environments (SE), IoT is becoming a salient partner for resource and power management. It facilitates integration and management of equipment through linking, tracking, and reacting to numerous applications [15]. Furthermore, it allows bidirectional-communication between equipment, sensors and networks with or without human interventions, which is critical for SE infrastructure to efficiently utilizes resources and handle the related challenges  [16]. IoT empowers internal devices to interact with SE and also enables customers and suppliers to control the power utilization in any desired manner by gathering and analysis of data of all active devices of SG that further improves its productivity [17], [18]. Efficient, automated, cost-effective, RT and reliable EMS is vital to the success of DSM in SG. As buildings and homes contribute a considerable segment in the electrical grid, regulating their consumption of energy can potentially result in better efficacy, sustainability, and reliability of the system. This work emphasizes on the RT monitoring and control in the DSM segment of SG, considering RT implementation of an IoT based SEMS in the buildings of a private industry in Pakistan. It provides design, deployment, implementation, and performance evaluation of an IoT based SEMS as well as their related benefits. The work inculcates IoT middleware module and SMs for management and effective data analysis. The proposed solution is installed and evaluated at 4 different places at the user end, which can communicate commands and also observe the efficiency of electricity supplied by the utility.
The major contributions of this research are summarized as follows: • Provides the overview of TEG and SG.
• Addresses the problem of insufficient knowledge of consumers regarding electricity usage. • Provides a layered system architecture framework design that integrates IoT middleware module and SMs for management and effective data analysis. • The design, deployment, and RT performance evaluation of the proposed solution with impact of using separate SM for automated control of heating, ventilation and air conditioning (HVAC) system are also presented. • The work acts as an example for providing the necessity/overview of load monitoring and control for residential/industrial customers of Pakistan, providing efficient energy utilization. The rest of this paper is structured as follows. The literature review is provided in section 2. The proposed system architecture is described in section 3. Section 4 covers demonstration, deployment, and performance evaluation based on RT data. Section 5 outlines the potential benefits of the proposed system. Section 6 discusses the significance of SEMS from Pakistan's perspective. Section 7 concludes with a summary of the findings and recommendations for future research.

II. LITERATURE REVIEW
First, we examine the work on importance of DSM in SG, numerous categorizations of DSM, and its main components, such as SEMS. Then, we analyze some of the significant contributions on SEMS design and implementation.
Energy consumption in SE, is monitored and measured by different appliances that communicate with the datacenter to collect and provide information access to both suppliers and consumers. This allows the users to monitor their electricity consumption and also enables automation of numerous appliances in order to maintain their electricity usage amenable. Electricity suppliers, on the other hand, can control the EG's MD by diverting electricity to the locations/facilities where needed, especially when Distributed Energy Resources (DERs) are available [19], [20]. SEMS was established as a result of such smart systems. Unlike traditional DSM systems, the DSM for the future SG must be entirely automated and build on reliable and secure modern communication technologies [8]. A completely automated DSM not only helps suppliers in reducing energy wastage and theft but also assists consumers in minimizing their energy usage and bills [21].
The authors in [9] examine effective DSM approaches for energy management to reduce the peak-to-average-ratio (PAR) of electricity utilization form the EG. Their approach is based on game theory and genetic algorithm. They investigate weather conditions, electricity price, energy usage patterns of consumers, and various factors to determine an appropriate load control strategy to meet the MD of the EG. In [22] author investigated DSM in the SG using a system model that included three parties: consumers, suppliers and a datacenter. They proposed a set of DSM approaches, particularly smart pricing strategies. Authors Palensky and Dietrich provide a review of DSM, covering demand response (DR), time of use (ToU), spinning reserve (SR) and EE and as well as a classification and analysis of DSM [23]. They come to the conclusion that as a result of SGs, Super Grids and Micro Grids, DSM is transitioning from obsolete modes to the smart and intelligent-based new emerging technologies.
The evolution of home-based SEMS and their significance in the success of DSM schemes in SG is examined in [24]. They demonstrate that their proposed system can contribute in improving the voltage profiles and energy losses in the SG. The authors in [25] provide a comprehensive examination of an innovative building energy management system (BEMS) that can help in the deployment of residential DR programs. The authors implement a proof of concept/prototype of the proposed system in the system on chip (SOC) and evaluate it via experiments. Authors in [26]- [28] claim that cloud computing based SEMS solutions can contribute in load balancing, local resource pooling, delay reduction, cache data management and local data processing. Another significant work [30] provides a system based on cloud servers and fog nodes. They constructed their solution on an IoT panel using Wifi communication based on constrained application protocol (CoAP) and utilized ThingSpeak as a cloud server. Author in [29] improved their work and utilized a lightweight IoT protocol i.e. message queuing telemetry transport (MQTT) protocol in their proposal.
Recently, certain hybrid intelligent RES-based EMSs with bi-directional communication, big data analytics and artificial intelligence (AI) strategies for minimizing consumer bills have been proposed [30]- [33]. Lin demonstrated an IoTfocused SEMS for identifying electrical equipment with identical electrical characteristics based on neuro-fuzzy segmentations [34]. For residential DR, Lin and Tsai suggested innovative EMS for the management of demandside load by meta-heuristically and autonomously scheduling domestic devices without user interference [35].
Authors in [36] created an intelligent current and voltage monitoring framework constructed on the Arduino that communicates data through Bluetooth to a smartphone. They recommended to update Bluetooth communication network with the IoT technique for future researchers. Authors in [37] highlight that DSM approaches must be introduced in underdeveloped nations soon. They presented an intelligent scheduler based on particle swarm optimization (PSO) that includes RT pricing and ToU approaches. In [38] authors presented an energy forecast strategy for DR/DSM in SEMS that efficiently minimizes energy cost. They proposed a generic architect that collects DR feedback and utilizes an effective scheduling strategy by incorporating an energy management controller (EMC). In another work [39], the authors proposed the architecture framework for BEMS based on IoT approach. They highlight that EE of various facilities, including buildings, is vital for the sustainability and the environment. They gathered long-term energy consumption data of facilities and examined it to prove that these were not eco-friendly and energy efficient. They further developed a prototype by using location awareness infrastructure based on the global positioning system (GPS) to proactively regulate electrical appliances in various facilities to enhance EE by reducing energy misuse.
Authors in [40] used an Application-Programming-Interface (API) and DFRduino to construct a RT electricity monitoring system that collected data on a smartphone. Residential electricity consumption accounts for a substantial amount of a country's total energy expenditure; thus, efforts to reduce residential (buildings, homes, etc.) energy wastage will have a greater influence on overall energy savings. AR Al Ali declares that HVAC systems contribute to 60% of energy consumption in Arab gulf countries [30], while in Pakistan it accounts for 44% [41] . Residential buildings contribute more than 40% of the demand on EG in developing nations, according to Rashid and Sahir, and residential loads are generally comprised of shift-able loads that can help in MD shifting and energy management [42]. They developed an integrated system framework to analyze MD in the residential sector (RS) of Pakistan. Their work revealed that the energy expenditure of the RS would surge by 600%, necessitating the development of efficient policies and methods to meet future MDs. According to a study published in 2008, buildings account for roughly 71 % of overall electrical energy usage in the United States [43]. They tracked and evaluated building energy consumption statistics over a year. Their findings suggest that the real operation of green buildings might not be eco-friendly and energy-efficient due to the rigid and decentralized control, necessitating the development of strategies to implement EE and conservation. Table I provides the comparison of various IoT-based-EMS with our proposed work.
The following is a summary of the research gaps: a) A generic framework is required to construct IoT based SEMS at all levels, including the homes, buildings, any other facilities, and so on. b) the infrastructure must support cloud implementations such as middleware module for efficient data management. c) Simple, cost-effective, and practical development of the SEMS framework is required, employing state-of-the-art technologies like cloud based IoT platforms with automated control algorithms.

III. THE PROPOSED SYSTEM DESIGN
All the aforesaid capabilities are integrated into a sole solution that is easy to build and scalable to deploy. We integrate the most promising solution's contribution, as described in [14].

A) PROJECT AND LAYERED ARCHITECTURE OVERVIEW
This solution offers a RT monitoring approach of electrical and aggregated equipment along with a wide-range load control strategy, combined with an equipment that is capable of evaluating and monitoring of grid parameters (GPs) such as current, voltage, active, reactive and apparent power, frequency and power factor (PF). Load control of external appliances (like lighting and air conditioning) is also possible as well as integration of various software platforms enables the evaluation of GPs of users' facilities by providing numerous management summaries and reports. The equipment used to accomplish this concept is the construction of SM to meet the technological requirements. It is a low-cost three-phase energy monitoring platform that is compatible with a variety of open protocols and management platforms, including bidirectional wireless communication systems.
We first discuss the generic architecture of proposed system based on SMs and IoT-MiddleWare module whereas the design of SM along with workflow of proposed SEMS will be provided in next subsection. Figure 4 depicts the layered architecture. The layers are described below. The topmost layer is the application (AP) layer. It interacts with the cloud server and allows consumers in order to view valuable statistics and data of appliances and power consumption. It is implemented remotely by utilizing IP/TCP network model. It could be a cloud service's web portal or a smartphone application. Cloud analytics (CA) refers to the use of cloud services that provides data analytics, prolong data storage, and the execution of DR algorithms and EC directives. The communication (COM) layer is applied in a dispersed approach between the cloud and consumers' end. It utilizes IoT protocol for two-way command/data transfer between SEMS and the cloud (which is a middleware module). Energy control (ECON) layer and energy monitoring (EM) layers are applied at the consumers' facilities. ECON layer is made up of a centralized control element that collects load voltage and current data and further communicates to actuators in order to regulate the devices/equipment's on the basis of received signals. The functionality of ECON is accomplished using a Microcontroller-Unit (MCU) that is configured to do specified tasks. The ECON layer implements the DR strategies that are determined at CA layer based on prolonged data like price incentives, energy consumption trends, and scheduling algorithms, using commands received from the cloud. The EM layer is the bottom layer, which deals with EM through various sensors and actuators. The proposed SM architecture is explained in the next subsection.

B) DESIGN OF NEW SMART METER
Three SOC -MCUs, web application and cloud-based IoT middleware module are part of the proposed SM architecture. Their specifics are listed below.
The MSP430F67641 MCU of Texas Instruments is an intelligent SOC utilized for computing of GPs [44]. Input circuits designed for current computation with Current Transformers (CTs) withstand inner currents up-to 50 mA and calculate reference voltage across a resistor burden of 12. The mathematical formulation for the computing of GPs is described follows [45].
RMS values of current and voltage are calculated by Equation (1) and Equation (2) respectively where, consumption. It could be a cloud service's web portal or a smartphone application Cloud analytics (CA) refers to the use of cloud services that provides data analytics, prolong data storage, and the execution of DR algorithms and EC directives.
The communication (COM) layer is applied in a dispersed approach between the cloud and consumers end. It utilizes IoT protocol for two-way command/data transfer between SEMS and the cloud (which is a middleware module).
Energy control (ECON) layer is made up of a centralized control element that collects load voltage and current data and further communicates to actuators in order to regulate the devices/equipment s on the basis of received signals.
The energy monitoring (EM) layer is the bottom layer, which deals with EM through various sensors and actuators.  (3) and (4).
where, • ℎ = SF for active power • ℎ = SF for reactive power • 90 ( ) = Voltage sample at a sample instant n shifted by 90 degrees Each phase apparent power is computed by Equation (5).
After computing per phase active power, reactive power and apparent power, the cumulative sum of these parameters is determined by the following equations. In addition, after computing active and apparent power, the PF is calculated using the equation below.

= (9)
TIVA C Family Texas Instrument's TM4C129x is the second MCU [46]. It comes with ARM Cortex-M4F based architecture, which was utilized to enable storage of data in its remnant memory. It could also operate various loads remotely (like On/Off lighting and cooling circuits) as well as RT monitoring of important control parameters like temperature and humidity sensors (not included in our scope of work). Furthermore, it is connected using Universal Asynchronous Receiver/Transmitter (UART) with 3rd SoC, nodeMCU [47]. Specifics of nodeMCU are provided in table III. Block Diagram of TM4C129x is provided in figure 6.
Data collection is achieved by creating a UART link inbetween the preferred radio and SM. For this research, we have chosen a wireless radio nodeMCU used for the development of IoT applications and further appropriate for various standards like Bluetooth, ZigBee and IEEE 802.15.4. NodeMCU also supports MQTT protocol and further connects with IoT middleware module wirelessly. Figure 7 shows the block diagram of the proposed SEMS.  The functioning of SEMS employing the SMs is explained below.
• MSP430 analyzes GPs, collects data like voltage and current and transfers it through UART to another MCU i.e., TM4C129 • The TM4C129x receives and saves the data with an interrupt in its EEPROM approximately once in each 30 seconds. • Meanwhile, a function in TM4C129x establishes a link with each obtained GP provided by MSP430F67641 to a JavaScript Object Notation (JSON) format. This allows the transfers of the data to nodeMCU through UART that further enable to initiate a useable MQTT protocol publication for an IoT middleware module. Also, this is roughly carried out in every 30 seconds. • The data attained from the preceding step is transferred to the IoT middleware module [48] which integrates numerous IoT devices to mediated applications. • It serves as a translation layer that permits data storage for particular queries, data availability to consumers on a continual basis and the RT processing. • An API [49] is utilized to link the IoT middleware to the end-users for remote and RT accessibility of all the data via nodeMCU. • Furthermore, the analytical engine server tool generates a number of reports that allow SEMS to examine the quality of the electricity supplied to the facilities, and also provide usage statistics and analysis in different times i.e. instantaneous, daily, etc.
Operation flowchart of SEMS is shown in figure 8.

IV. DEMONSTRATION, PERFORMANCE EVALUATION AND CASE STUDY
This section provides the demonstration, validation, and the evaluation of the proposed solution based on RT implementation results; especially the impact of using separate SM for automated control of HVAC system is also provided.
To analyze the performance and for proposed solution validation, SMs along with 100A CTs were deployed at the main distribution boards (DB) of four different locations of a well-known private company i.e., Stylo Pvt Ltd, which is located in Lahore, Pakistan. Each SM measures the GP of its particular facility and further communicates it to the central IoT middleware module for additional analysis. Figure 9 shows the deployed SM and the CTs. Moreover, RT monitoring, data collection, and numerous reports from the central cloud server are achieved by using the SM consumer application, as displayed in figure 10.
In order to simulate an energy evaluation of all facilities data was gathered from SMs using an API via web middleware module. Then, the collected data were analyzed using different techniques. Figure 11(a) reveals and distinguishes the gross energy usage of all facilities/locations from 01-03-2021 to 17-04-2021. It may be noticed that the average gross usage of energy is almost constant from week 10 to week 12 i.e., around 1250 kWh per day, but a surge of daily gross energy consumption is observed on 24-03-2021 due to the turning on of the HVAC units whereas the gross energy consumption of Stylo factory is almost the same due to installation of less numbers of air conditioning units. Figure 11(b) reveals and distinguishes the reactive power of all facilities which also  figure 11(c), a surge of 104kW can be noted on 24-03-2021 due to switch on of HVAC units. PF monitoring is very critical because low PF indicates inefficient use of electricity and leads to the penalties [50], [51], whereas high PF can improve voltage, maximize current-carrying-capacity in existing circuits, reduce power losses and lower the electricity bills. Figure 11 (d) displays the daily average PF of all facilities from 01-03-2021 to 17-04-2021. It may be noted that average PF of Stylo factory is least due to the inductive load.
The analysis of net energy usage on the basis of weekdays is given in figure 12. It can be noticed that energy usage proportion is nearly identical for Stylo shop because it keeps open seven days a week without observing any off days while energy usage percentage is approximately similar for Stylo warehouse and Stylo factory in working days whereas it falls to 5 % on off days i.e., Sundays The energy usage percentage of Stylo Head Office falls by 26 % on Saturdays due to the shutdown of HVAC units since its corporate office observes holidays and production facility works on Saturdays. It can be noticed that energy usage is least on Sundays. Such investigations are extremely useful in determining when and where the majority of energy is being utilized. This kind of data also provides useful insights on the behavior of people working in the facilities.
The instantaneous energy demand is also extremely significant because it may help in power consumption optimization and in identifying the potential power consumption vulnerabilities inside a device, process, or overall facility. Such instantaneous power demands can be efficiently derived through LPs provided by SMs. This technique would not only enhance efficacy of the system but also drastically reduces the operational and maintenance cost as it provides valuable information like Peak Load and Base load of the respective facilities. Figure 13 shows the hourly Immediate/Instantaneous MD on 12-04-2021. It can be seen that Immediate/Instantaneous MD of Stylo HQ, Stylo factory and Stylo warehouse is least in the break hours i.e., at 2pm, which is due to the shutdown of numerous loads, particularly air conditioning units.

FIGURE 8. Operational flowchart of Smart Energy Management System
Detail of the facilities where SMs are deployed, are provided in table IV.
As aforementioned in the literature review section that HVAC systems contribute a lot in terms of power consumption, similar case was observed for HVAC consumption of Stylo HQ. So, to enhance the efficacy in terms of power saving, a test case was developed, i.e., separate SM was installed to monitor, control, and regulate the HVAC power consumption in the week 18.
For this, nodeMCU is connected with a single channel relay module, which is further linked with a timer relay. Timer relay is used as a time delay function. It gets input signal from the normally open (NO) contact of relay module whereas the magnetic contactor's coil is energized by the signal from NO contact of timer relay.
Block diagram of the connection of SM with magnetic contactor and experimental setup to monitor and control the HVAC's load are shown in figure 14 and 15 respectively (as we have modified the live DB so, please mind the messy wiring). Furthermore, on the basis of operations dynamics of the corporate office, we devised a test algorithm to automate the operation of HVAC system, as shown in figure 16.    Moreover, the provided algorithm is processed at CA layer and executed at the ECON layer in week 19. Figure 17 shows average power saving and energy consumption of HVAC units of Stylo HQ for week 18 and week 19 of 2021, showing the significance of using separate SM with automated control for such heavy loads. It is worth mentioning that the algorithm in figure 16 only controls on/off state of the HVAC system's breaker, while in our future work an intelligent system is being designed for efficient control of the HVAC units independently; incorporating indoor/outdoor room temperature, humidity, and human occupancy etc.    From the results of figure 17, it can be observed that hourly energy consumption is zero at 8:00 AM, 02:00 PM and 07:00 PM due to the execution of the automation algorithm that resulted in the automated on/off control of HVAC units in week 19, which were operating manually in week 18. It also resulted in saving of 17, 20 and 14 kWh units at 01:00 PM, 15:00 PM and 18:00 PM respectively in week 19.

V. BENEFITS OF THE PROPOSED SYSTEM
This research presents significant lessons which can enable future developers and researchers to establish or upgrade SEMS developed on IoT approaches.
The challenge of unintentionally misusing such energy sources is not remediated by a SEMS platform alone, but customers must have to be wise and also mindful about both the environment as well as sustainability in order to deter exploitation of the power resources. The key benefit is that a client/consumer may also obtain a solution by which statistics of energy usage can be retrieved on RT basis and can also interact with the various installed loads (such as lighting and HVAC). Moreover, the proposed solution can be consolidated into existing or newly built systems without having a need of a copyrighted solution given by any company.
Consequently, these kinds of solutions are deployable in a wide range of scenarios in which energy utilization and quality assurance are desired. Numerous applications can also be integrated into the presented solution such as RT power quality monitoring, energy utilization and control of heavy loads like HVAC systems with the help of a middleware module. This would avoid the deterioration of available energy resources.
The provided solution in this work can be utilized in different facilities to detect energy-intensive processes and equipment and the data provided by these kinds of solutions can be compared with facilities' benchmarks to develop numerous techniques for EC, especially by devising separate automated control for the heavy loads like HVAC systems.
Furthermore, current and voltage fluctuations commonly cause considerable damages to facilities' equipment that are usually very expensive. The deployment of proposed SMs on transmission lines within the facility enables quality monitoring of the electricity provided by the suppliers. This data can be further utilized to create intelligent decisionmaking system, which may assist in safeguard of multiple equipment installed in various facilities. Such systems operate by providing early diagnosis of power quality faults by quality monitoring of the supplied power deviations and failures. Another major benefit is energy auditing which is a technique to evaluate EE of system and identifying opportunities to improve it. Energy audit plays a vital role in achieving MD reduction, peak load clipping and operational efficiency objectives of industry or any other facility. Such audits can be even more useful, when comprehensive usage breakdowns, daily/hourly LPs and consumers' behavior insights are known. The proposed system facilitates an effective and easy way of conducting these energy audits.
A change in a customer's energy usage pattern for some incentive and price signal from the suppliers is known as DR.
The significance of SMs in any DR event is elucidated in the following three steps: (a) Overload; a system's MD exceeds a predetermined limit (b) Notification; SM triggers overload notification to the server, (c) Client Response; Server can turn off non-critical loads. The SM analytics play a significant role in the design of DR program systems; furthermore, SM can function as a medium for the implementation of these DR programs. The benefits of the provided smart metering solutions are summarized in figure 18. Moreover, the SEMS provides numerous advantages to the utilities, facilities, and its residents. It can improve operations and processes' performance, lower operational expenditures, offer quick access in remote controlling of various equipment and manage various appliances, boost employee performance, and safeguard facilities and equipment.
The SEMS can help you save money by lowering your facility's energy consumption and operating costs. Facility managers can have a RT understanding of the facility's GPs such as current, voltage, PF, etc. as well as operational parameters, like operation status and electricity consumption. This is made possible with the inclusion of various sensors and monitoring devices in SEMS. This also allows for the detection of previously undiscovered issues (e.g., irregular power consumption of a machine or device such as HVAC unit that is left running) as well as the analysis of energy usage trends in different times. SEMS may drastically cut energy expenditures through energy management, like switching on/off HVAC and/or lighting circuits when not required, which eventually improves the overall performance of the system. According to Pei Huang [52], implementing SEMS can conserve 10 to 20 % of energy compared to traditional systems. For every 50,000 square feet of an average office space, lowering energy usage by 30% equates to conserving of $25,000 annually in operational costs [53].
Other potential economic benefits of deploying SEMS include: (a) because the SEMS gathers entire data from various facilities and displays the data on the datacenter that is a central location, thus, the need for the workforce in equipment monitoring and control can be drastically minimized, (b) SEMS can indirectly help in pro-active maintenance and can aid extend the equipment's life, and (c) EC can also help in increasing the profit, e.g., 30% reduction in electricity consumption equates to a 3% rise in rental income or a 5% rise in building asset value and net operating income [54].
As per the environmental protection agency (EPA) of USA, people spend roughly 90% of their time living indoors [55]. Managing an optimal thermal comfort level and decent indoor quality of air is critical because that affects how people/occupants feel, as well as how healthy and productive they can be. Nevertheless, in several buildings, the appropriate level of indoor air quality and thermal comfort cannot be attained, and indoor pollution concentrations can sometimes be ten times greater than outdoor pollution concentrations. The SEMS' comprehensive monitoring and controlling capabilities, such as adjusting automatically indoor air temperature, ventilation rate, and illumination intensity, can assist to enhance indoor thermal comfort (automated HVAC control using advanced sensors and algorithms (part of our future work)).
The ecological/environmental benefits are derived indirectly from the energy savings achieved through the use of SEMS. Buildings/facilities consume over 40% of primary energy and 72 % of electricity in the USA according to the US Energy Information Agency (EIA) [2]. Buildings, on the other hand, account for 38% of all GHG emissions. As a result, installing the SEMS has a high possibility of conserving intermittent fossil fuels (coal, natural gas, thermal etc.) and lowering GHG emissions.

VI. PAKISTAN'S PERSPECTIVE
This section provides the overview and necessity of load monitoring for residential and industrial customers of Pakistan.
According to the report published by National Electric Power Regulatory Authority (NEPRA) in 2020, the residential consumers utilize almost half of the country's total electricity generation whereas industrial customers use 26% [5]. This shows that efforts to reduce residential (buildings, homes, etc.) and industrial energy wastage will have a greater influence on overall energy savings. Figure 19 shows the electricity generation/consumption of various sources/sectors of Pakistan [5]. Energy efficiency is the cheapest way to meet the growing energy demands as well as it is among one of the core elements of sustainable development, as per the agenda of United Nations Sustainable Development Goals [56], [57]. DSM helps in achieving this goal by providing load monitoring and control for better EE. Furthermore, EE presents long-term economic advantages through lowering the cost of energy supply/imports and its generation as well as lowering energy-related pollutants [56].
Another point is that, ToU and peak hour load tariffs were not implemented to the residential customers in Pakistan until May 2019, when K-Electric (a prominent utility company in Pakistan) declared that peak hour tariffs would be implemented for domestic consumers across Pakistan [58]. Pakistan's growing population, diverse climatic conditions, human growth, and economic development necessitate sustainable and energy efficient buildings and homes in order to achieve a balance between country's present as well as future power demands. The implemented solution acts as an example of RT monitoring and control for all energy consumer sectors in Pakistan and shows the significance of using IoT based SEMS for efficient energy utilization. There is limited load monitoring in the country's present residential, commercial, and industrial distribution system. At this time effective load monitoring or SEMS is needed with more efficient DSM than ever before. Benefits of SEMS in terms of consumer, utility and environment are summarized in figure 20.

VII. Conclusion
DSM is evolving as a key component of the SG. It indicates the various approaches and algorithms to alter customers' energy demand so that energy loss can be reduced. A vital component of DSM is simple, reliable, and effective SEMS that monitors customers' electrical demand data and offers LPs to users and suppliers. The suppliers can use this data to design efficient DR approaches and control power generation efficiently, whereas the customers can alter their energy consumption behaviors to reduce energy wastage. SMs are integral components of EMS and the communication platform in the SG.
The paper focuses on the design, deployment, implementation, and RT performance evaluation of a IoT based SEMS. The work inculcates IoT middleware module and SMs for management and effective data analysis. It accumulates and communicates the data to CA layer that offers consumers with their daily/hourly energy consumption statistics through an API by using IoT communication protocols. The proposed SEMS operates online and also offers RT-LPs to customers and suppliers remotely. The proposed solution is installed and evaluated at 4 different places at the user end, which can communicate commands and also observe the efficiency of electricity supplied by the utility. The proposed solution framework can be employed in any facility where RT energy consumption is needed.
Normally, customers manually check their electricity usage and rely on inefficient measurements performed by utility's staff. The precise quantity of power consumption as well as the customer awareness of power usage are becoming important emerging challenges. This work provides knowledge and significance of using SMs to the users that they can monitor and conserve power utilization, and with valid data on usage of energy, they will eventually be able to reduce their energy consumption, thus, saving both money and energy.
The IoT is an indispensable tool that offers an intelligent and low-cost solution for RT electricity consumption. Based on the provided case study-based analysis, it is concluded that the proposed SEMS assists consumers to effectively, accurately, easily, and reliably monitor their energy utilization hence satisfying their information requirements. Furthermore, from commercial and industrial perspective, based on RT experimentation, it is further concluded that significant energy can be saved using an isolated and proper automated control of heavy loads like HVACs. This research aids in a particular way to derive an efficient RT management and configuration of the future SGs.
We aim to devise and test numerous DR/DSM schemes in the future. For this, an Arduino-based intelligent system is being designed for efficient controlling of HVAC units Thermal, 62% Hydroelectric, 26% Nuclear, 8% Renewable, 4%

Electricty Consumption
independently. Furthermore, it will also incorporate indoor/outdoor room temperature, humidity, and human occupancy etc. The DR/DSM approaches would be executed in the ECON layer and processed at CA layer.