Applsci 08 01320 v2

Download as pdf or txt
Download as pdf or txt
You are on page 1of 23

applied

sciences
Article
Novel Internet of Things Platform for In-Building
Power Quality Submetering
Manuel Alonso-Rosa, Aurora Gil-de-Castro * ID , Ricardo Medina-Gracia ID
,
Antonio Moreno-Munoz ID and Eduardo Cañete-Carmona
Departamento de Ingeniería Electrónica y Computadores, Universidad de Córdoba, Campus de Rabanales,
Edificio Leonardo Da Vinci, E-14071 Córdoba, Spain; manuel.alonso@ieslafuensanta.es (M.A.-R.);
p32megrr@uco.es (R.M.-G.); amoreno@uco.es (A.M.-M.); ecanete@uco.es (E.C.-C.)
* Correspondence: agil@uco.es; Tel.: +34-957-212533

Received: 21 June 2018; Accepted: 27 July 2018; Published: 7 August 2018 

Abstract: As the number of facilities adopting a Building Management System under the Industry 4.0
paradigm increases, it is critical to ensure the good health of their operations. Business continuity and
uninterrupted operations are key requirements for any building, for which Power Quality and Supply
Reliability sophisticated monitoring can play an extremely important role. Submetering, as opposed
to bulk-metering, implies measuring power consumption for individual units or appliances in a
building complex. An Internet of Things mesh network, which brings ubiquitous power quality
submetering inside the entire facility, would be extremely beneficial for the management of the
building thus ensuring seamless business operations. This work describes a novel low-cost Internet of
Things sensor for measuring and analyzing power quality at the input of any individual Alternating
Current (AC) appliance, providing an early detection and analysis system which controls those critical
variables inside the facility and leads to anticipate faults with early-stage alerts based on on-time data
streams treatment. Moreover, the recorded power quality parameters that are processed in the Cloud
system can help to reduce energy consumption, as power quality disturbances can be automatically
analyzed and even compared to standard values. The proposed Internet of Things sensor will help
users to detect most power quality steady-state and events disturbances, while monitoring the energy
consumption. This Internet of Things Power Quality sensor is built around a flexible microcontroller,
which manages an energy metering Integrated Circuit (IC) through Serial Peripheral Interface (SPI),
increasing its original capabilities by including new sophisticated software functionality. Additionally,
it wirelessly communicates with a cloud-based Internet of Things Platform to allow the storage and
supervision of the different power quality events for the entire facility. An example of the access to
the data is also included.

Keywords: advanced metering infrastructure; building energy management system; internet of


things; power quality; smart grid

1. Introduction
Worldwide energy demand is constantly increasing. It is expected that global energy consumption
will increase by more than a third in the period to 2035. Among all the energy demand, the building
sector represents an average 20–40% of worldwide energy use [1]. This may become even more
important as electricity demand is expected to rise in buildings, primarily due to electric heat pumps,
and secondly due to the impact of electric vehicles charging facilities. Consequently, spreading the
demand more evenly in time and better coordination with electricity availability could partially avoid
the need for new infrastructure.

Appl. Sci. 2018, 8, 1320; doi:10.3390/app8081320 www.mdpi.com/journal/applsci


Appl. Sci. 2018, 8, 1320 2 of 23

Within the framework of Smart Electric Grid, substantial energy savings could be achieved
by means of a Building Energy Management System (BEMS). Thus, the combination of direct load
control (DLC) algorithms, during a Demand Response (DR) event, with detailed measurements and,
furthermore, with the contextual energy reporting and analytics would drive to significant impact on
reducing energy costs. However, the lack of end-load monitoring (or as we might call it: submetering)
or recording energy consumption “behind the meter”, e.g., at system-level or into individual appliances,
have been an insurmountable barrier up to now. However, at some point in the future, submetering
will be somewhat mandatory. In some cases, submetering in the multi-residential buildings can reduce
the average electricity consumption by 34% for non-electrically heated buildings, and by 27% for
electrically heated buildings [2]. However, submetering could be an important way not only to identify
opportunities for operational efficiency but also to regulate demand, e.g., through virtual aggregation
of different submeters, for a power system which progressively relies on variable and Distributed
Energy Resources (DER).
Power Quality (PQ) refers to deviations of the voltage or current waveform from the ideal
single-frequency sine wave of constant amplitude and frequency. PQ deterioration is due to transient
disturbances or events (voltage sags, voltage swells, impulses, etc.) and steady-state disturbances
(harmonic distortion, unbalance, flicker). A consistent set of definitions and extensive overview to this
important area can be found in [3]. Presently, PQ disturbances are of increasing concern due to present
widespread use of power electronics equipment in industrial, commercial and residential buildings.
White and brown goods are specifically sensitive to such imperfections.
Among all categories of power disturbances, voltage sag (or dip), and momentary interruptions
are the swords of Damocles of the automated industrial processes. Sag durations are subdivided in
IEEE Std. 1159 [4] into three categories-instantaneous, momentary, and temporary. In distribution
networks, power system faults are principally the origin of voltage sags. Fault occurrences elsewhere
can create voltage sags that may disturb consumers to different extents depending on their position
in the electrical network. Voltage sags affect a larger number of customers and, for some of them,
extremely serious problems may be caused. Some examples are sensitive equipment that do not have
adequate ride-through capabilities to withstand fluctuations in the electrical supply [5]. The need for
line voltage regulation remains in order to meet demands for high industrial productivity. There are
several conditioning solutions that have been developed to provide protection to PQ problems [6].
Correlating and categorizing (e.g., event type, magnitude, and duration) can be classified
according to i.e., EN 50160 [7] or IEEE Std. 1159 [4] standards. However, only the standard EN
50160 establishes limits of the voltage supplied by the public distribution network. PQ events should
be measured, depending on their deterministic or stochastic nature, by following the IEC 61000-4-30 [8]
standard. In the other hand, steady-state signal variations such as harmonics are processed according
to IEC 61000-4-7 [9]. Amplitude-related distortions should be pre-processed and recorded only if they
have the potential to affect any device in the facility. Mostly, the likelihood of PQ event occurrence
is evaluated based on the sine waveform Root-Mean-Square (RMS) change across a sliding window.
According to IEC 61000-4-30, this RMS value should be measured over one waveform cycle, starting at
a fundamental zero-crossing, and refreshed each half cycle (VRMS(1/2) ). Thus, this standard establishes
voltage sags, swells, and interruptions as a variation in RMS below 90%, above 110%, and below 10%
of the nominal value, respectively.

1.1. Motivation
The decreasing costs of Information and Communication Technologies (ICT), combined with
increased environmental and regulatory pressures towards energy efficiency and reduction of
greenhouse gas emissions, means that many Smart Cities and Communities are now looking at the
Internet of Things (IoT) as the proper way to address energy-saving within residential and commercial
buildings. The concept of IoT comprises a plethora of applications and technologies and a good
definition of IoT can be found in [10]. Inspired by the recent IoT model, and released by the National
Appl. Sci. 2018, 8, 1320 3 of 23

Institute of Standards and Technology [11], four core primitives can be established and employed
here: sensor, aggregator, analysis and decision trigger. The set of technologies that founded the IoT
promised to swerve any device into a self-information source.
At the heart of this ecosystem is data, remotely collected from IoT sensors and feed to cloud-based
applications. Through IoT software platforms, the information can be analyzed, stored and visualized
in a well-designed way, and what is most important is that it can be accessible from any part of the
world. This data can be then analyzed through big data techniques, to enable deeper knowledge
at a granular level of the localized supply and use of electricity. In this context, the power utilities
Advanced Metering Infrastructure (AMI) play a main role, mostly because it is necessary to harmonize
the integration of IoT PQ sensors in the existing Smart-Grid standards-based architecture of connected
Intelligent Electronic Devices (IEDs).
PQ is a concern not only because of the harm produced in equipment and the electrical distribution
system itself but because it wastes energy and reduces electrical capacity. PQ problems in EU-25
countries create financial loss of more than €150 billion per year [12]. Detecting a problem from the
beginning, before it worsens and when it is easy to tackle, minimizes the likelihood of costly equipment
damage or costly business interruptions.
If AMI and IoT continue overlapping trends—and they will—smart meters could be better
supplemented with information from embedded IoT PQ submetering devices. This will enable
appliances to self-monitor not only their electrical energy consumption but also quality, a hitherto
unexplored approach. Subsequently, this would drive the development of more disruptive energy
behavioral tools for making the energy data generated by IoT manageable by customers. As a
conclusion, with an IoT PQ platform, it would be possible to offer advanced functionalities for energy
management applications to final consumers, building managers, and municipalities on a single
cost-effective and scalable multi-tenant platform.

1.2. Power Quality Literature Survey


Automated PQ analysis entails the following stages: detection, segmentation, and characterization
of the PQ event. There exists a very extensive body of knowledge related to these stages, where the
most advanced techniques have been applied, from the area of signal processing to artificial intelligence.
See for example the latest works presented in [13–15].
The most advanced PQ analyzer in the market today, which costs between €4,495 and €13,460 [16],
provides three-phase high-performance PQ monitoring with built-in EN 50160 or IEEE Std. 1159
monitoring, statistics and reports. These analyzers can be divided between a portable solution for
load studies and PQ audits, or to be fixed for 24/7 continuous long-term monitoring. As can be
seen, most of these analyzers present good characteristics, but they are usually very expensive,
consequently only considered to be connected at the entrance of the facility. While all major events can
be captured, this could result in excessive data from non-critical events. Manual analysis methods are
expensive, time-consuming, and error-prone. Thus, designing a system that can analyze, condensing
and interpreting voluminous raw data so that levels can be assessed against limits, as well as can be
easily expanded, would become the most significant challenge in the present PQ measurement arena.
Besides the professional PQ meters, plug-in voltage quality (VQ) recorders that detect and record
different disturbances are available at prices around €900. Consequently, a low-cost system able to
observe PQ data on a continuous basis is needed.
In recent years, different works have been published in energy metering fields at the customer
level, and an excellent review can be found in [17], where the current state of the art of energy
management through Intrusive Load Monitoring (ILM) and Non-intrusive Load Monitoring (NILM) is
presented. Another interesting paper presents an advanced IoT-based system for intelligent energy
management in buildings [18]. The proposed system extends existing approaches and integrates
cross-domain data, such as building data, energy production, energy prices, weather data and
end-user behavior, to develop daily and weekly action plans for end-users with actionable, customized
Appl. Sci. 2018, 8, 1320 4 of 23

information. Considering both concepts, in [19] the residential energy scheduling optimization problem
is solved using two-stage Mixed Integer Linear Programming (MILP) considering the customer
preferences and appliances’ specifications. Similarly, but applied in a particular case, in [20] a testbed
is designed where each housing unit is equipped with sensors, actuators, smart plugs, smart meters,
and Unified Home Gateway (UHG). The paper also shows results from implemented applications in
Demand Response Management (DRM), energy management, home automation, dynamic pricing, and
home security. However, no information regarding PQ is traditionally measured. Paper [21] describes
a gamification framework that aims to achieve greater energy conservation in public buildings.
The framework leverages IoT-enabled low-cost devices to improve energy disaggregation mechanisms,
providing energy use and—consequently—wastage information at the device, area and end-user
level. Another example is found in [22] where a smart-grid testbed at the Singapore University
of Technology and Design (SUTD) is developed which is able to monitor, analyze, and evaluate
smart-grid communication network design and control mechanisms, and test the suitability of various
communications networks for both residential and commercial buildings. One of the main reasons
behind these works is to make users aware of their electricity consumption to reduce their carbon
footprint and eventually save money on their electricity bills. An interesting point to be added to the
existing resources is recording information about PQ, as it is also a source of losses, meaning that
energy consumption can also be achieved with an appropriated PQ within an installation.
In the state-of-the-art literature, energy metering has mainly been considered, as in [23] which
presents a detailed survey of behind-the-meter energy management systems, or [24] which monitors
energy usage, but also adding information about individual appliances allowing identification of
which appliance is using energy, and in turn speculate on the activity and number of users. Some
other authors have also considered the measurement of PQ parameters as in [25], which studies how
to take advantage of the basic PQ measures inherent in most of today’s smart meters in the context of
a smart building with Energy Management System (EMS), particularly the implementation details
and results at laboratory scale. With similar in mind, paper [26] proposes a signal analysis framework
for simplified PQ informative methods based on a lightweight assessment of these measures to
allow optimal real-time network operation and market-correlated services. They all use existing
smart meters provided by the electrical company to gather extra information aside from for billing
purposes, meaning that the information is aggregated by individual consumers, making it difficult
to act over individual loads and implement measures to anticipate faults in an early stage. To that
end, the ground-breaking smart meter developed in paper [27] provides standard PQ information as
Total Harmonic Distortion (THD); in addition to event detections such as sags, swells, or interruptions,
a complementary NILM approach is implemented in the prototype to identify appliances or industrial
equipment. However, data are stored in an external micro-SD memory, so access to the data are
offline, meaning no control can be done with it, and it exists only for monitoring purposes. In [28],
the same ADE7758 Integrated Circuit (IC) selected here is employed to monitor energy parameters,
and complemented with overvoltage and overcurrent alarms functionality; however, the solution
does show data in an LCD display, so data are not stored to be later processed. Paper [29] presents
a Wi-Fi smart plug which, in addition to monitoring energy consumption, can remotely activate the
electrical appliances connected, but power quality data are not calculated. In [30] authors present a
small-size power sensor able to measure the appliance power down to 1 W and generate power for its
Microcontroller Unit (MCU) and radio frequency module by energy harvesting; they emphasize that
the sensor does not consume power when the electrical appliance is off. The inconvenience is that only
power consumption is measured, and a Personal Computer (PC) is needed to upload data to the cloud
system, so the sensor is not provided with internet access. Authors of [31] criticize most approaches
for being “distributor-centric” rather than “customer-centric,” undermining user acceptance, so they
have designed a customer-centric and scalable architecture to facilitate user acceptance. According to
the authors, this architecture (1) facilitates the integration of smart-grid applications with other home
applications; (2) can gather data from heterogeneous communication protocols; (3) provides secure
Appl. Sci. 2018, 8, 1320 5 of 23

access to data; and (4) allows unequivocal mapping of each sensor and actuator to common abstraction
layers so that applications easily can identify them.

1.3. Internet of Things Platform Review


A set of IoT platforms has been analyzed to select the one that allows the sensor to send a
reasonable number of messages without demanding a long integration process within the device.
The most interesting IoT platforms are below briefly analyzed:
Kaa [13] is a free open-source middleware platform for IoT that supports a variety of hardware
devices. It is a reliable and secure platform for developing connected things. Furthermore, Kaa server
provides services such as data management, integration and visualization. Other platforms similar to
Kaa are ThingsBoard [32], OpenIoT [33,34] and Thinger [35].

• Carriots [36] is a Platform as a Service (PaaS) designed for IoT and machine-to-machine
(M2M) projects. It allows users to collect and store data from various devices and build
powerful applications through its Software Development Kit (SDK) engine. Compared to Kaa,
the development process as well as the information exchanged between the devices and the
platform makes necessary the use of an Application Programming Interface (API). In contrast,
Carriots only allows users to freely manage two devices.
• Particle [37] is ecosystem (hardware and software) to facilitate the IoT development applications.
From the software point of view, it provides real-time events, automatic cross-platform
Over-The-Air (OTA) firmware distribution and management, self-healing module introspection,
and secure and efficient messaging. Compared to Carriots, it allows freely management of up to
25 devices which can send up to 250,000 messages per month.
• ThingSpeak [38,39] is an IoT platform that enables users to collect, store, analyze, visualize, and
act on data from sensors or actuators.

1.4. Contributions
In short, all previous developments are partial attempts to meet to the challenge in question. What
is needed is an IoT low-cost solution (much cheaper than €900 per node) that distributes monitors and
controls critical variables inside the facility; this would be extremely beneficial for management of
a building and thus ensure seamless business operations. Previously publications consider that the
recorded PQ parameters which are in the Cloud system can help to reduce energy consumption in
a building. However, those data can also be used to automatically detect PQ disturbances and even
compare to standard values. An open platform that measures and compares values with standard
limits has not been implemented to this end.
To our knowledge, there does not exist any low-cost IoT systems devoted to simultaneous PQ
and energy monitoring. The paper introduces the first low-cost device able to analyze power quality
parameters and upload them to an IoT cloud platform. This is the novelty of the paper: the ability
to measure and send aggregated on-time PQ data to the cloud system, as well as process data and
check with the standard compliance. The important point here is that this information is accessible by
any device that has an Internet connection and a search engine. A mobile phone can access all data,
without requiring any additional configuration or application. Voltage sags are on-time monitored
through amplitude and duration, moreover categorized according to the SEMI F-47 curve. This is
suitable for submetering industrial or commercial facilities as PQ sensor data can be an indication of
the equipment performance regarding efficiency and accomplishment of PQ standards. In fact, users
will be able to detect not only most PQ steady-state disturbances but events such as voltage sags which
anticipate faults with early-stage alerts.
The rest of the paper is organized as follows: Section 2 describes the system architecture, including
the description of the hardware implemented. Section 3 resumes the PQ functionality implemented
Appl. Sci. 2018, 8, 1320 6 of 23

in the PQ sensor. The IoT PQ sensor cloud platform integration is included in Section 4. Results are
included in Section 5. Section 6 puts forward several conclusions.
Appl. Sci. 2018, 8, x FOR PEER REVIEW 6 of 23
2. IoT Power Quality Sensor
2. IoT Power Quality Sensor
2.1. System Architecture
2.1. System Architecture
To contextualize the integration of the IoT PQ smart sensor in a grid, the system is described
first fromTo the
contextualize
hardwarethe integration
point of viewofand,
the IoT PQ smart sensor
subsequently, frominthe
a grid,
ICT the system is Figure
viewpoint. described
1 shows
first from the hardware point of view and, subsequently, from the ICT viewpoint. Figure 1
the general system architecture. It shows the complete procedure followed with the IoT PQ sensorshows the
general system architecture. It shows the complete procedure followed with the IoT PQ sensor
implemented: since the PQ event is detected by the sensor until it is stored in the cloud database
implemented: since the PQ event is detected by the sensor until it is stored in the cloud database
where it will be available for the customer. Through a cloud system, users can access data from their
where it will be available for the customer. Through a cloud system, users can access data from their
installations with their mobile devices such as tablets or mobile phones.
installations with their mobile devices such as tablets or mobile phones.

Figure 1. System architecture.


Figure 1. System architecture.
The proposed smart sensor can be installed in a non-intrusive way inside a building. It allows
The proposed
on-time access to smart sensor can
data collected be installed
through the IoT in a non-intrusive
cloud platform. This way inside
smart a building.
sensor is based Itonallows
ATMega
on-time technology,
access as it is used
to data collected to acquire
through data
the IoT and platform.
cloud send it to the
Thiscloud
smartsystem.
sensorItisintegrates
based onthe ATMega
ADE7758 IC to measure power quality parameters according to the standard IEC
technology, as it is used to acquire data and send it to the cloud system. It integrates the ADE7758 IC61000-4-30, a Real-
Time Counter
to measure power (RTC) peripheral
quality precise
parameters information
according about
to the timestamp,
standard IEC as well as anaESP8266
61000-4-30, Real-TimeWi-Fi
Counter
module to send data to the cloud. To visualize the recorded data, the IoT PQ sensor utilizes a mobile
(RTC) peripheral precise information about timestamp, as well as an ESP8266 Wi-Fi module to send
device such a smartphone or tablet. ThingSpeak offers a flexible and easy way of storing the
data to the cloud. To visualize the recorded data, the IoT PQ sensor utilizes a mobile device such a
information collected by sensors in the Cloud, so ThingSpeak platform has been chosen not simply
smartphone or tablet. ThingSpeak offers a flexible and easy way of storing the information collected
to monitor data recorded by the designed IoT PQ sensor, but also for its ability to operate with data
by that
sensors in theMATLAB
supports Cloud, so ThingSpeak
® code platform
integration. has voltage
Therefore, been chosen noton-time
sags are simplymonitored
to monitorasdata
wellrecorded
as
by categorized
the designed IoT PQ sensor, but also
according to the SEMI F-47 curve. for its ability to operate with data that supports MATLAB®
code integration.
Focusing onTherefore,
the IoT PQvoltage sags are
sensor device on-time
itself, monitored
it measures voltageas and
wellcurrent
as categorized
RMS, activeaccording
and to
theapparent
SEMI F-47 curve.
energy, as well as detecting voltage sags in a three-phase distribution system. The hardware
description
Focusingfromon thetheIoT
IoTPQPQ sensor
sensor device
is now considered. Figure 2voltage
itself, it measures shows theandblock diagram
current RMS,ofactive
the and
components
apparent of as
energy, thewell
PQ monitoring
as detecting prototype. This in
voltage sags system, based on distribution
a three-phase an IoT paradigm, incorporates
system. The hardware
in its construction
description from the theIoT
following
PQ sensorcomponents:
is now ATMega328P-PU
considered. Figure MCU,2 ADE7758
shows the IC,block
and the ESP8266 of the
diagram
Wi-Fi module. To power the system, a dual power source—5 V & 9 V (one for each chip)—is needed.
components of the PQ monitoring prototype. This system, based on an IoT paradigm, incorporates
An RTC peripheral is added to the ATMega328P to do timestamp. Finally, a signal conditioning
in its construction the following components: ATMega328P-PU MCU, ADE7758 IC, and the ESP8266
circuit is needed at the ADC ADE7758 voltage input.
Wi-Fi module. To power the system, a dual power source—5 V & 9 V (one for each chip)—is needed.
An RTC peripheral is added to the ATMega328P to do timestamp. Finally, a signal conditioning circuit
is needed at the ADC ADE7758 voltage input.
Appl. Sci. 2018, 8, 1320 7 of 23
Appl. Sci. 2018, 8, x FOR PEER REVIEW 7 of 23

Power Source

Current

Signal conditioning SPI ATMEGA328 UART ESP 8266


ADE7758
Circuit to ADC MCU Wi-Fi
Voltage

I2C
RTC

Figure 2. Interfacing block diagram for the IoT PQ sensor prototype.


Figure 2. Interfacing block diagram for the IoT PQ sensor prototype.

The ATMega328P-PU is a low-power single-chip 8-bit enhanced RISC-based microcontroller


The ATMega328P-PU
that combines 32 kB ISP Flash is memory
a low-power withsingle-chip 8-bit enhanced
read-while-write RISC-based
capabilities, microcontroller
1 kB EEPROM, 2 kB SRAM, that
combines 32 kB ISP Flash memory with read-while-write capabilities,
23 I/O lines, 32 working registers and serial programmable Universal Synchronous and 1 kB EEPROM, 2 kB SRAM,
23 I/O lines, 32 Receiver-Transmitter
Asynchronous working registers and serial programmable
(USART). Universalcan
More features Synchronous
be found andinAsynchronous
[40]. This
Receiver-Transmitter
microcontroller, (USART).
specifically More features
designed can beand
for in-home found in [40].automation,
building This microcontroller,
manages specifically
this cost-
designed for in-home and building automation, manages this cost-effective
effective and flexible PQ Meter, allowing the communication between multifunction energy metering and flexible PQ Meter,
allowing the communication between multifunction energy metering
ADE7758 IC [41] and the Wi-Fi chip ESP8266 [42]. The timestamp, a critical part in a measuring ADE7758 IC [41] and the Wi-Fi
chip ESP8266
device, has been[42]. The timestamp,
addressed with the use a critical part peripheral
of an RTC in a measuring device, [43]
(DS1307ZN) has been addressedwith
communicated with
the use of an RTC peripheral (DS1307ZN) [43] communicated with
the ATMega328P through I2C bus. Finally, the enhanced prototype includes the ESP8266 Wi-Fi the ATMega328P through I2C
bus. Finally,
System on Chip the(SoC)
enhancedmodule,prototype
which is includes
a low-costthe ESP8266
Wi-Fi chip Wi-Fi
withSystem on Chip
full TCP/IP (SoC)
stack andmodule,
MCU
which is a low-cost Wi-Fi chip with full TCP/IP stack and MCU capability,
capability, based on serial interfacing requirements [42]. The ESP8266 module was selected due to based on serial interfacing
requirements
recent popularity [42].inTheIoTESP8266
prototype module wasand
research selected due to recent
its affordable cost.popularity in IoT prototype research
andThe
its affordable cost. part of the prototype is ADE7758 IC [41] representing the heart of the
most interesting
design. This multifunctionpart
The most interesting of the
energy prototype
metering hasisaADE7758 IC [41] representing
voltage channel the heart
with single-ended of theinputs
voltage design.
and a differential current channel. The voltage value is driven to the voltage channel ADC, and and
This multifunction energy metering has a voltage channel with single-ended voltage inputs witha
differential
the appropriated current channel. The
configuration, thevoltage valuezero-crossing,
chip detects is driven to the voltage
giving channel
several ADC, andthrough
PQ parameters with the
different internal registers. On the other hand, the current differential channel adapts itsthrough
appropriated configuration, the chip detects zero-crossing, giving several PQ parameters phase
different
current internal
levels to aregisters. On thedifferential
proportional other hand,voltage
the current differential
measured by the channel
ADC adapts
for thisitspurpose.
phase current
The
levels to a proportional differential voltage measured by the ADC for this
differential voltage levels can be configured depending on the requirement of the equipment to be purpose. The differential
voltage levels
measured. can be the
Regarding configured
aim of the depending
paper, theon selected
the requirement
constraintsof the
are equipment
RMS voltage to and
be measured.
current,
Regarding
voltage sagsthe aim of the
duration, the minimum
paper, the sag selected
RMSconstraints
voltage, and areactive
RMS andvoltage and current,
apparent energy.voltage
Moreover,sags
duration, the minimum sag RMS voltage, and active and apparent
what is more interesting for the application, the timestamp measurement showing exactly the energy. Moreover, what is more
interesting
moment when forthe
themeasurement
application, the timestamp
is done. measurement
This chip showing exactly
and the ATMega328P the moment when
are communicated through the
measurement is done. This
Serial Peripheral Interface (SPI) [44]. chip and the ATMega328P are communicated through Serial Peripheral
Interface (SPI) [44].
2.2. Sensor Signal Conditioning
2.2. Sensor Signal Conditioning
The ADE7758 IC requires a signal conditioning circuit at the voltage input for the voltage and
The ADE7758 IC requires a signal conditioning circuit at the voltage input for the voltage and
current measurements. Voltage and current sensors are now described from the hardware point of
current measurements. Voltage and current sensors are now described from the hardware point
view.
of view.
2.2.1. Voltage Sensor
2.2.1. Voltage Sensor
The used voltage sensor following manufacturer recommendations [41] is shown in Figure 3. At
The used voltage sensor following manufacturer recommendations [41] is shown in Figure 3.
the terminal of this circuit, the Vin level is ±0.5 V when the phase voltage is ±500 V (353.55 VRMS).
At the terminal of this circuit, the Vin level is ±0.5 V when the phase voltage is ±500 V (353.55 VRMS ).
In this application, the input voltage level must be adjusted, as the phase nominal voltage in Europe
In this application, the input voltage level must be adjusted, as the phase nominal voltage in Europe
is 230 VRMS (considering an ideal sine wave at 50 Hz) and the voltage peak is, approximately, 325 V,
is 230 VRMS (considering an ideal sine wave at 50 Hz) and the voltage peak is, approximately, 325 V,
so the Vin level is ±0.325 V.
so the Vin level is ±0.325 V.
Appl. Sci. 2018, 8, 1320 8 of 23
Appl. Sci. 2018, 8, x FOR PEER REVIEW 8 of 23

1M VA
Appl. Sci. 2018, 8, x FOR PEER REVIEW 8 of 23
230 V
50 Hz 1M 1k 33 nF V
A

230 V
50 Hz 1k 33 nF
Figure 3. Signal conditioning circuit to voltage ADC.
Figure 3. Signal conditioning circuit to voltage ADC.
2.2.2. Current Sensor
2.2.2. CurrentThe
Sensor Figure 3. Signal conditioning circuit to voltage ADC.
current conditioning circuit has been implemented following the manufacturer
recommendations
The2.2.2.
current Sensor[41] and iscircuit
Currentconditioning shown inhas Figurebeen4. The active phase wire
implemented passes through
following a current
the manufacturer
transformer (CT) with a transform ratio of 1:1000. The current seen in the secondary of the
recommendations [41] and
The current is shown in Figure
conditioning 4.been
Theimplemented
active phasefollowing
wire passes
the through a current
transformer depends on the load circuit
resistor has
(RL) used to measure a proportional voltage manufacturer
to the current
transformer (CT) with
recommendations a transform
[41] and is ratio
shown ofin1:1000.
Figure The
4. current
The active seen
phase in the
wire secondary
passes of
through
of this secondary circuit. Thus, a suitable design of this resistor is determined to have an appropriated the
a transformer
current
dependstransformer
on therange
current (CT)
load with
onresistor
the a (R
transform
measured usedratio
L ) circuit. of 1:1000.
to measure
The input a The
current current
proportional
range seen
is limited in to
the
voltage
due secondary
to of theof this
the current
functional limitations
transformer
secondaryofcircuit. depends
Thus, The
the prototype. on the
a suitable load resistor
design of
CT bandwidth (R
this
is 50 L) used to measure a proportional voltage to the current
Hzresistor is determined
so that the to haveenergy
measured waveform an appropriated current
in frequencies
of this secondary circuit. Thus, a suitable design of this resistor is determined to have an appropriated
range on beyond the fundamental
the measured circuit. component
The inputwill be attenuated.
current range is limited due to functional limitations of the
current range on the measured circuit. The input current range is limited due to functional limitations
prototype. The CT bandwidth is 50 Hz so that the measured waveform energy in frequencies beyond
of the prototype. The CT bandwidth is 50CTHz so that the measured waveform energy in frequencies
the fundamental IP 1:1000 IS 1k
beyond thecomponent
fundamentalwill be attenuated.
component will be attenuated. IA+
Active Phase 33 nF

CT RL
IP 1:1000 IS 60 1 k
IA+
Active Phase 1k 33 nF
IA-
RL 33 nF
60

1k
IA-
33 nF
Figure 4. Signal conditioning circuit to current ADC.

The final implemented design allows current measurements in a single phase from 0 to 5.8926
ARMS. The resistor-capacitor Figure 4. Signal
circuit in conditioning
each node of circuit
thetodifferential
current ADC. analog input is used as an
Figure 4. Signal conditioning circuit to current ADC.
antialiasing filter, filtering frequencies above the sampling frequency at the ADC input.
The final implemented design allows current measurements in a single phase from 0 to 5.8926
The finalThe
A RMS.Calibration
2.3. resistor-capacitor
implemented design circuit
allows in each nodemeasurements
current of the differential in aanalog
singleinput
phase is from
used as0 toan5.8926
antialiasing filter, filtering frequencies above the sampling frequency at the ADC input.
ARMS . The resistor-capacitor circuit inineach
Considering design conditions nodestate,
the steady of the the differential analogsystems
conditioning circuit inputfor is voltage
used as an
antialiasing
and filter,
currentfiltering
2.3. Calibration frequencies
measurements were above
calibrated the
in sampling
the PQ sensor frequency
prototype. at
Thethe ADC
completed input.
measurement
system and conditioning circuits were calibrated for the verification of voltage and current algorithm
Considering
2.3. Calibration
processing. design conditions
The equipment used forinthesethe steady state, tests
calibration the conditioning
was composed circuit
of ansystems for voltage
AC programmable
and current measurements were calibrated in the PQ sensor prototype. The
power system, a programmable active load, and the PQ sensor connected to the output of the power completed measurement
Considering
system
system. and design
The conditions
conditioning
AC programmable inpower
circuits were the steady
calibrated
system, state,
for the conditioning
the verification
California of voltage
Instruments circuit systems
and current
3001iX [45], for voltage
algorithm
integrates a
processing.
and current The
measurements equipment
were used for
calibrated thesein calibration
the PQ tests
sensor was composed
prototype.
transient network analyzer and can also run several standardized PQ tests as voltage sags. The of
The an AC programmable
completed measurement
power
system and system, a programmable
conditioning
programmable circuits
active load,were active load,
calibrated
California andforthethe
Instruments PQ3091LD
sensor connected
verification[46], of to the output
voltage
provides of the
and current
precisely power
algorithm
controlled,
system.
nonlinear The AC programmable
loads for testing power system, California Instruments 3001iX [45], integrates a
processing. The equipment usedAC forpower
thesegeneration
calibration equipment.
tests was Therefore,
composed usingofdifferent
an AC voltage and
programmable
transient network
current levels, the analyzer
quality ofand can also run system
the measurement several over
standardized PQ tests
a wide dynamic as voltage
range sags. Theas
was determined
power system, a programmable
programmable activeof load, active load,Instruments
California and the PQ3091LD sensor connected toprecisely
the output of the power
well as the stability different signal generation conditions. A[46], provides
program locally executedcontrolled,
on the IoT
system. nonlinear
The AC programmable power system, California Instruments 3001iX using[45], integrates aand
transient
PQ meterloadsdeviceforwas
testing AC power
specifically generation
designed to thisequipment.
aim. Table Therefore,
1 shows a calibrationdifferent voltage
test of the voltage
networkcurrent
analyzer and
levels, thecan also
quality run
of the several
measurement standardized
system overPQ a tests
wide as voltage
dynamic
measurement system where the electronic load is configured as a resistive load (constant current)rangesags.
was The programmable
determined as
well
active load, as the stability
and California of different
connected toInstruments
a pure sine wave,signal
3091LD generation
[46],
achieving conditions.
theprovides A program
unity totalprecisely
Power Factor locally
controlled, executed on
nonlinear
(tPF) required the IoT
loads for
by the tested
PQ
testing AC meter
power
load. device was specifically
generation equipment. designed to this aim.using
Therefore, Table different
1 shows a calibration
voltage and test current
of the voltage
levels, the
measurement system where the electronic load is configured as a resistive load (constant current)
quality of the measurement system over a wide dynamic range was determined as well as the stability
and connected to a pure sine wave, achieving the unity total Power Factor (tPF) required by the tested
of different
load.signal generation conditions. A program locally executed on the IoT PQ meter device was
specifically designed to this aim. Table 1 shows a calibration test of the voltage measurement system
where the electronic load is configured as a resistive load (constant current) and connected to a pure
sine wave, achieving the unity total Power Factor (tPF) required by the tested load.
Typical tolerance figures for components used in the meter are 5%, which means the assembled
meter has an inherent error of the same magnitude. Hence, each sensor must be calibrated before
accurate results can be measured. In this case, the voltage and current calibration has been done using
Appl. Sci. 2018, 8, x FOR PEER REVIEW 9 of 23

Table 1. Voltage Calibration Results.


Appl. Sci. 2018, 8, 1320 9 of 23
Reference Value (V) RMS before Calibration % Deviation RMS after Calibration % Deviation
230 230.3 0.13 230.05 0.02
50 50.2 0.30 50.06 0.11
two calibration points for each parameter as recommended in the IC datasheet [41]. Results are shown
in Tables 1 and 2. A maximum deviation of 0.11% for voltage and 0.26% for current measurements
Typical tolerance figures for components used in the meter are 5%, which means the assembled
were reached after the calibration tests.
meter has an inherent error of the same magnitude. Hence, each sensor must be calibrated before
accurate results can be measured. In this1.case,
Table theCalibration
Voltage voltage and current calibration has been done using
Results.
two calibration points for each parameter as recommended in the IC datasheet [41]. Results are shown
Reference Value (V) RMS before Calibration % Deviation
in Tables 1 and 2. A maximum deviation of 0.11% for voltageRMS
andafter Calibration
0.26% % Deviation
for current measurements
230 230.3 0.13 230.05 0.02
were reached after
50
the calibration tests.
50.2 0.30 50.06 0.11

Table 2. Current Calibration Results.


Table 2. Current Calibration Results.
Reference Value (A) RMS before Calibration (A) % Deviation RMS after Calibration (A) % Deviation
Reference Value (A) RMS before Calibration (A) % Deviation RMS after Calibration (A) % Deviation
2.95 2.9811 1.06 2.9521 0.07
2.95
0.05 2.9811
0.0504 1.06
0.84 2.9521
0.0501 0.070.26
0.05 0.0504 0.84 0.0501 0.26

2.4. Comunication Technology


2.4. Comunication Technology
The ESP8266 is used as a Wi-Fi adapter with built-in antenna to provide Wi-Fi capabilities to the
The ESP8266 is used as a Wi-Fi adapter with built-in antenna to provide Wi-Fi capabilities to
MCU. This module is a self-contained SoC with integrated TCP/IP protocol stack that can give
the MCU. This module is a self-contained SoC with integrated TCP/IP protocol stack that can give
ATmega328 microcontroller access to a Wi-Fi network [42]. This module supports 802.11 b/g/n and
ATmega328 microcontroller access to a Wi-Fi network [42]. This module supports 802.11 b/g/n
has Wi-Fi direct along with capability for a software enabled access point. This is a low-power device
and has Wi-Fi direct along with capability for a software enabled access point. This is a low-power
specifically designed for mobile devices, wearable electronics and networking applications.
device specifically designed for mobile devices, wearable electronics and networking applications.
Communication standards as SPI and Universal Asynchronous Receiver-Transmitter (UART) are
Communication standards as SPI and Universal Asynchronous Receiver-Transmitter (UART) are used
used
for communication with with
for communication the module.
the module. This Wi-Fi
This Wi-Fi modulemodule
is alsoisvery
alsocost
very cost effective,
effective, makingmaking
it ideal it
ideal
to use toand
useimplement
and implement on scale.
on a large a large scale. has
ESP8266 ESP8266 has been because
been employed employed because
of its of its ready
ready availability
availability
in the market as well as its economic advantage. ESP8266 has been configured to continuously sendto
in the market as well as its economic advantage. ESP8266 has been configured
continuously
sensor data tosend sensor data cloud
an open-source to an open-source cloud
platform via the platform
Wi-Fi module. via the Wi-Fi module.

2.5.
2.5.Final
FinalPrototype
Prototype
Finally,
Finally, at
at hardware
hardware level,
level, the device was implemented
implemented using using Printed
PrintedCircuit
CircuitBoard
Board(PCB)
(PCB)
techniques and
techniques and a regular
regularprotoboard.
protoboard.Figure 5 shows
Figure 5 showsthe the
finalfinal
implemented
implementedprototype. The right-hand
prototype. The right-
board
hand in Figure
board 5 corresponds
in Figure to ATMega
5 corresponds microcontroller
to ATMega microcontroller with with
its conditioning circuit,
its conditioning as well
circuit, as
as well
the RTC peripheral. The left-hand board corresponds to the ADE 7758 IC itself
as the RTC peripheral. The left-hand board corresponds to the ADE 7758 IC itself and the and the conditioning
voltage and current
conditioning voltagecircuit described
and current in Section
circuit 2.2. in Section 2.2.
described

Dual Power Source

Current
conditioning
circuit to ADC ADE7758

ATMEGA328 MCU

Active phase wire


Measured
(Current)
DS1307 RTC
Peripheral
Active phase wire
measured
(Voltage)
Voltage
conditioning ESP8266
circuit to ADC

Figure
Figure 5.
5. Prototype IoT PQ
Prototype IoT PQ sensor
sensor board
boarddeveloped.
developed.
Appl. Sci. 2018, 8, 1320 10 of 23

3. Power Quality Functionality Implementation


Appl. Sci. 2018, 8, x FOR PEER REVIEW 10 of 23
The designed IoT PQ sensor prototype can measure stationary PQ data as current and voltage
RMS,3. Power
as well Quality Functionality
as events as voltage Implementation
sags. Active and apparent energy is also measured, as it can
help identify not only
The designed IoTthe
PQpresence of inductive
sensor prototype loads from
can measure appliance
stationary PQ data compressors
as current and and motors but
voltage
the RMS,
increasingly
as well asabundant
events as nonlinear
voltage sags. loads,
Activewhich can introduce
and apparent energy phase imbalances
is also measured, as and
it canincrease
help the
disturbing harmonic
identify not only thecontent
presenceon of the powerloads
inductive line.from
PQappliance
information is meaningful
compressors and motorsfor but
knowing
the the
increasingly abundant nonlinear loads, which can introduce phase imbalances
origin and to determine the responsibilities of the network operator, appliance manufacturer, or final and increase the
disturbing
customer. PQharmonic
analyticscontent on the power
also support line. PQ information
the forensic investigation is meaningful
of how to for knowing
chain the origin
the events that have
and to determine the responsibilities of the network operator, appliance
occurred. All those data are then uploaded to the Cloud, and accessible through an electronic manufacturer, or final device
customer. PQ analytics also support the forensic investigation of how to chain the events that have
with an Internet connection, as it was previously stated in Section 2. System Architecture, and will be
occurred. All those data are then uploaded to the Cloud, and accessible through an electronic device
further described in the Results section.
with an Internet connection, as it was previously stated in Section 2. System Architecture, and will be
In resource-constrained
further described in the Results devices it is important to apply aggregation data techniques to reduce the
section.
amount In of resource-constrained
transmitted data which implies, on the one
devices it is important tohand,
apply the reduction
aggregation of energy
data consumption
techniques to reduce of the
device and, on the other, the upload to the Cloud of only the relevant information.
the amount of transmitted data which implies, on the one hand, the reduction of energy consumption The measurement
of the device
frequency interval and, on the other,
is software the upload
configurable andto depends
the Cloudonofthe only theupload
data relevant information.
ratio given by Thethe Cloud
measurement
platform—in thisfrequency
case is 30 interval
s. Theisstored
softwareRMSconfigurable and depends
value calculated on IoT
by the the data upload ratio
PQ sensor is thegiven
average of
the by the Cloud
input valuesplatform—in
between two this case is 30 s. uploads
consecutive The stored toRMS value calculated
the cloud platform, by theifIoT
e.g., 30 PQ sensor between
s elapses is
the average of the input values between two consecutive uploads to the cloud platform, e.g., if 30 s
two consecutive sendings, the RMS voltage and current measurement will be a cycle-to-cycle average
elapses between two consecutive sendings, the RMS voltage and current measurement will be a cycle-
in this period, then aggregated within the considered interval. When an upload to the cloud platform
to-cycle average in this period, then aggregated within the considered interval. When an upload to
is done, the saved voltage and current RMS value is reset to 0 V or 0 A, but managed by a different
the cloud platform is done, the saved voltage and current RMS value is reset to 0 V or 0 A, but
routine to
managed thebyone responsible
a different routinefortohandling the received
the one responsible data. the received data.
for handling

3.1. 3.1.
RMS RMS
TheThemeasurement
measurementof of voltage andcurrent
voltage and currentRMSRMS values
values is carried
is carried out
out in theinATMega328P,
the ATMega328P,by by
reading the the
reading ADE7758
ADE7758 IC internal register
IC internal at aatconstant
register sampling
a constant frequency,
sampling andand
frequency, following the the
following flowchart
flowchart
shown shown
in Figure in Figure 6.toAccording
6. According to the manufacturer’s
the manufacturer’s recommendations,
recommendations, and tostability
and to ensure ensure in the
stability in the measurement procedure, the RMS measurement is synchronized with
measurement procedure, the RMS measurement is synchronized with the positive voltage zero-crossing the positive
voltage zero-crossing detected by a platform interrupt request (zero crossing in the voltage channel
detected by a platform interrupt request (zero crossing in the voltage channel of Phase A -ZXA flag- is
of Phase A -ZXA flag- is set in Reset Status Register -RSTATUS-), following IEC 61000-4-30. Therefore,
set in Reset Status Register -RSTATUS-), following IEC 61000-4-30. Therefore, when a zero-crossing
when a zero-crossing takes place, the current and voltage RMS measurement corresponds to the
takes place, the current and voltage RMS measurement corresponds to the previous line cycle.
previous line cycle.

Start

Test interrupt flag

Yes No
No Interrupt Vrms_averaged = 0
Request?

Yes Set first Vrms value Average the new Vrms

Read RSTATUS

No
ZXA is set? Yes No
Irms_averaged = 0

Yes
Manage other
Read Vrms register
interrupt sources
Set first Irms value Average the new Irms

Read Irms register

Figure 6.
Figure 6. RMS
RMSreading
readingprocess
processimplemented in the
implemented in MCU.
the MCU.
Appl. Sci. 2018, 8, 1320 11 of 23
Appl. Sci. 2018, 8, x FOR PEER REVIEW 11 of 23

AsAs previously stated, the MCU is communicated with the IC with SPI bus communication.
previously stated, the MCU is communicated with the IC with SPI bus communication. The
The communication starts when the zero-crossing flag is set in the RSTATUS register. Figure 7 contains
communication starts when the zero-crossing flag is set in the RSTATUS register. Figure 7 contains
in channel 4 a reading of the VRMS (0x0D) register, and the request seen in Master Output Slave Input
in channel 4 a reading of the VRMS (0x0D) register, and the request seen in Master Output Slave Input
(MOSI) line. The Master Input Slave Output (MISO) line corresponds to the VRMS reading, in this case,
(MOSI) line. The Master Input Slave Output (MISO) line corresponds to the VRMS reading, in this case,
228.4 VRMS . The Serial Clock Input for the Synchronous Serial Interface (SCLK) is set to 4 kHz.
228.4 VRMS. The Serial Clock Input for the Synchronous Serial Interface (SCLK) is set to 4 kHz.

Figure 7. Communication between ADE7758 IC and ATMega328P when the VRMS register is read
Figure 7. Communication between ADE7758 IC and ATMega328P when the VRMS register is read
(Ch1. SS, Ch2. SCLK, Ch3. MOSI, Ch4. MISO).
(Ch1. SS, Ch2. SCLK, Ch3. MOSI, Ch4. MISO).

3.2. Energy
3.2. Energy
Following
Followingthe thesame
sameworking
working methodology
methodology as as in
in the
the case
caseofofRMS,
RMS,the thedesigned
designed prototype
prototype hashas
been
been calibrated
calibrated totomeasure
measureactiveactiveandandapparent
apparentenergy.
energy.TheTheMCU MCUhas hasbeen
been programmed
programmed to to access
access to
thetoADE7758
the ADE7758 IC [41], which has several registers to calculate the energy consumed. The energy is is
IC [41], which has several registers to calculate the energy consumed. The energy
calculated
calculated bybyintegrating
integratingthe theinstantaneous
instantaneous power power (active
(active or or apparent)
apparent)ofofthe thephase
phasetotobebemeasured.
measured.
The energy integration factor is programmable; therefore, when this integration
The energy integration factor is programmable; therefore, when this integration ends, an interruption ends, an interruption
request
requestis istriggered
triggered(In (Inline
lineenergy
energy accumulation (LENERGY) flag
accumulation (LENERGY) flagininRSTATUS)
RSTATUS)inin thetheICICandand thethe
register
registerallocating
allocating the theaccumulated
accumulated energy
energy is accessed
is accessed (see flowchart
(see flowchart in Figurein 8). Figure 8). resolution
The energy The energy
resolution of thisisregister
of this register is programmed,
programmed, i.e., in otheri.e.,words,
in otherthewords, the of
resolution resolution
the energy of meter
the energy meter in
in Wh/LSB
Wh/LSB (Watts-Hour per Less Significant Bit) is programmed for each increase in the energy
(Watts-Hour per Less Significant Bit) is programmed for each increase in the energy meter, and in meter,
this
particular
and case, represents
in this particular a value of 0.00906997
case, represents a value of mWh/LSB
0.00906997 in the accumulation
mWh/LSB register. The register.
in the accumulation MCU
extracts the measurement updating the active and apparent energy
The MCU extracts the measurement updating the active and apparent energy consumed since consumed since the start of thethe
measurement,
start adding the last
of the measurement, energy
adding thecalculated
last energyby integration.
calculatedThe by active energy The
integration. accumulated can
active energy
be found in the watt-hour accumulation register (WATTHR) and
accumulated can be found in the watt-hour accumulation register (WATTHR) and the apparentthe apparent energy in the VA-hour
accumulation
energy register (VAHR).
in the VA-hour accumulation register (VAHR).
3.3. Voltage Sag
The flowchart followed by the software implemented in the MCU is depicted in Figure 9.
The interrupt request is continuously being checked. If an interrupt request is detected, the MCU
reads the RSTATUS register in the ADE7758 IC through the SPI port, and the process continues if the
sag interrupts flag is activated. If that happens, the first step is to read the VRMS of the sag, further
updating the minimum saved value if the last reading contains a smaller RMS value. Whenever a
sag occurs for the first time, the start time is saved (with a 1 s resolution obtained from the RTC
Start

Test interrupt flag

Appl. Sci. 2018, 8, 1320 12 of 23

InterruptNo
Read WATTHR register
Request?
peripheral). As the minimum resolution in the IC is 20 ms (1 cycle in the 50 Hz system), the next time
that the interrupt request is detected, the sag duration
Yes
is increased in 20 ms, and the same holds for the
Update WATTHR
following detections. A more detailed explanation for the consecutive detections is shown in Figure 9.
accumulated
Figure 10 shows the timeline sequence in a Read
sag RSTATUS
detection.
Appl. Sci. 2018, 8, x FOR PEER REVIEW 12 of 23
Read VAHR register
Start
No
LENERGY is set?
Update VAHR
accumulated
Yes
Test interrupt flag
Manage other interrupt
sources
No Interrupt Read WATTHR register
Request?
Figure 8. Energy measurement process implemented in the MCU.
Yes Update WATTHR
3.3. Voltage Sag accumulated
Read RSTATUS
The flowchart followed by the software implemented in the MCU is depicted in Figure 9. The
Read VAHR register
interrupt request is continuously being checked. If an interrupt request is detected, the MCU reads
the RSTATUS register in the ADE7758 IC No through the SPI port, and the process continues if the sag
LENERGY is set?
interrupts flag is activated. If that happens, the first step is to read the Update VAHR
VRMS of the sag, further
accumulated
updating the minimum saved value if the last reading contains Yes a smaller RMS value. Whenever a sag
occurs for the firstManage
time, other
the interrupt
start time is saved (with a 1 s resolution obtained from the RTC
peripheral). As the minimum resolution in the IC is 20 ms (1 cycle in the 50 Hz system), the next time
sources
that the interrupt request is detected, the sag duration is increased in 20 ms, and the same holds for
the following detections. A more detailed explanation for the consecutive detections is shown in
Figure
Figure 8. 8. Energy
Energy measurement
measurement process implemented in the MCU.
Figure 9. Figure 10 shows the timeline sequence process
in a sagimplemented
detection. in the MCU.

3.3. Voltage Sag Start

The flowchart followed by the software implemented in the MCU is depicted in Figure 9. The
interrupt request is continuously being checked.
Test interrupt flag If an interrupt request is detected, the MCU reads
the RSTATUS register in the ADE7758 IC through the SPI port, and the process continues if the sag
Vrms_sag lower No
interrupts flag is activated. If No
that happens,
Interrupt
the first step is to read the VRMS of
than saved?
the sag, further
updating the minimum saved value if the last reading contains a smaller RMS value. Whenever a sag
Request?

occurs for the first time, the start timeYes is saved (with a 1 s resolution obtained from the RTC
Yes

peripheral). As the minimum resolution in the


Read RSTATUS
IC is 20 ms (1 cycle in the
Update 50 Hz
Vrms_sag system), the next time
saved

that the interrupt request is detected, the sag duration is increased in 20 ms, and the same holds for
the following detections. A more detailed explanation for the consecutive detections No
is shown in
No Yes First detection in
Figure 9. Figure 10 shows the timeline sequence
Voltage SAG? in a sag detection. the same SAG?

StartYes
Read RTC sag start time Duration_sag (s) =
Manage other interrupt
Read Vrms_sag value Duration_sag (s)+ 0.02
sources
Test interrupt flag Duration_sag (s) = 0.02

Vrms_sag lower No
No Interrupt than saved?
Figure 9. Sag detection
detection process implemented inthe
Figure 9. Sag Request? process implemented in theMCU.
MCU.
Yes
Yes
Update Vrms_sag saved
In this case, the communication
Readstarts
RSTATUSwhen the sag interrupt flag is set in the RSTATUS register.
Figure 11 contains a reading of the VRMS (0x0D) register, request seen in MOSI line. The MISO line
corresponds to the VRMS reading, in this case, 192.52 VRMS . No
No Yes First detection in
Voltage SAG? the same SAG?

Yes
Read RTC sag start time Duration_sag (s) =
Manage other interrupt
Read Vrms_sag value Duration_sag (s)+ 0.02
sources

Duration_sag (s) = 0.02


Appl. Sci. 2018, 8, x FOR PEER REVIEW 13 of 23

Appl. Sci. 2018, 8, 1320 13 of 23


Appl. Sci. 2018, 8, x FOR PEER REVIEW 13 of 23

Figure 10. Timeline sequence in a sag detection process.

In this case, the communication starts when the sag interrupt flag is set in the RSTATUS register.
Figure
Figure 11 contains a reading of10.
theTimeline sequence
VRMS (0x0D) in a sagrequest
register, detection process.
seen in MOSI line. The MISO line
Figure 10. Timeline sequence in a sag detection process.
corresponds to the VRMS reading, in this case, 192.52 VRMS.
In this case, the communication starts when the sag interrupt flag is set in the RSTATUS register.
Figure 11 contains a reading of the VRMS (0x0D) register, request seen in MOSI line. The MISO line
corresponds to the VRMS reading, in this case, 192.52 VRMS.

Figure 11. Communication


Figure 11. Communication between
between ADE7758
ADE7758 IC
IC and
and ATMega328P
ATMega328Pwhen
whenthe
theVVRMS
RMS register is
is read
read
(Ch1.
(Ch1. SS,
SS, Ch2.
Ch2. SCLK, Ch3.
Ch3. MOSI, Ch4. MISO).

Figure 11. Communication between ADE7758 IC and ATMega328P when the VRMS register is read
(Ch1. SS, Ch2. SCLK, Ch3. MOSI, Ch4. MISO).
Appl. Sci. 2018, 8, 1320 14 of 23

4. IoT PQ Sensor Cloud Integration


The novelty of this paper is the ability to measure and send aggregated on-time PQ data to the
Cloud, as well as process data and check with the standard compliance. The important point here is
that this information is accessible by any device that has an internet connection and a search engine.
A mobile phone can access all data, without requiring any additional configuration or application,
but there are several free applications with a friendly interface that can be used if the user prefers a
faster way to access the platform.
Compared to platforms such as Kaa, ThingsSpeak is less time consuming in terms of
development as users must only use an API, and, compared to Carriots or Particle, ThingSpeak
is free for non-commercial small projects (<3 million messages/year or around 8200 messages/day).
The mentioned advantages make ThingSpeak the chosen platform in the developed IoT PQ sensor to
collect, analyze and visualize data from the developed IoT PQ Sensor presented here. Another reason
is the compatibility feature between this cloud platform and the software MATLAB, allowing better
analysis from the data, apart from a proper visualization. The integration of MATLAB code is possible
within the platform, so authors have implemented extra features for better data analysis.
ThingSpeak offers a flexible and easy way of storing the information collected by sensors into the
cloud, so the used platform has been used to show data recorded by the designed IoT PQ sensor. To do
that, ThingSpeak introduces the concept of channel. Each channel allows storage of up to eight fields of
data, using up to 255 alphanumeric characters each. There are also four dedicated fields for positional
data: description, latitude, longitude, and elevation. All incoming data is time- and data-stamped, and
receives a sequential ID. Furthermore, a channel can be setup to be either private or public.
In the developed IoT PQ sensor, a public channel has been created to store four energy variables
(VRMS , IRMS , Active Energy, Apparent Energy) which are obtained after analyzing the information
received from the current and voltage sensors in the ADE7758, and read by the MCU. Moreover,
two other fields are used to monitor information when a sag occurs, one of them containing in a coded
way the joint information of the minimum VRMS and the sag duration, and the other field and most
deterministic, the start time of the sag, i.e., the timestamp, which is given by the hardware equipment
(RTC). As ThingSpeak is not a real-time but an on-time platform, the exact time of the sag occurrence
is provided to the cloud system with this extra variable.
There is a data limitation in the ThingSpeak version that is used in this experiment, meaning that
only one datum every 15 s can be uploaded, so the compromise followed here is to send both VRMS
and IRMS every 30 s. However, using another IoT platform from the above, described in Section 1,
will allow data to be uploaded in shorter time scale, if required by the application.
The information collected by the IoT PQ sensor can be written into the ThingSpeak channels
through two different methods: Representational State Transfer (REST) [47] and Message Queue
Telemetry Transport (MQTT) [48]. The former is designed as a request/response model that
communicates over HTTP and it is advisable to be used to retrieve large amounts of data, as well as to
create, view, clear or delete a channel, or even when a response to your GET or POST request is needed.
However MQTT is a publish/subscribe model that runs over TCP/IP sockets or WebSocket [49] which
should be used if the device updating the channel is power-constrained, as the MQTT publish operation
is faster and consumes less energy. This is the main reason the MQTT method has been chosen to
manage the information flow from the data registered by the designed IoT PQ sensor. Figure 12 depicts
the MQTT publish/subscribe model. MQTT broker is the central point of communication, dispatching
all messages between the sender and the rightful receivers. Our IoT PQ Sensor device is the client that
connects to the broker to publish different energy parameters under different topics. Alternatively,
there are other clients (laptops, mobiles phones, tablets etc.) that can communicate with the broker to
subscribe to topics they are interested in.
Appl. Sci. 2018, 8, 1320 15 of 23
Appl. Sci. 2018, 8, x FOR PEER REVIEW 15 of 23

Figure12.
Figure Publishto
12.Publish toaachannel
channelfield
fieldfeed.
feed.

5.5.Evaluation
Evaluationand
andExperimental
ExperimentalResults
Results
AA complete
complete platform
platform to to generate
generate voltage
voltage sags
sags andand different
different voltage
voltage RMS
RMS values
values has
has been
been
developed.
developed. The experimental
experimentalplatform
platformis is composed
composed of aofthree-phase
a three-phase programmable
programmable AC power
AC power source,
source,
California California
InstrumentsInstruments 3001iX
3001iX [45], [45], a three-phase
a three-phase electronic
electronic load, load,
California CaliforniaModel
Instruments Instruments
3091LD,
Model 3091LD,computer
and a desktop and a desktop
used computer used for
for configuring andconfiguring
monitoringand the monitoring
power system. the An
power system.
overview ofAn
the
overview of the system
system is shown in Figureis 13.
shown
This in Figureis13.
platform This
part platform
of the is part
Smart-Grid ofbench
test the Smart-Grid test bench
(SGTB) laboratory test
(SGTB)
bench
Appl. laboratory
Sci.for 8, x FORtest
Smart-Grid
2018, bench
research
PEER fordescribed
REVIEW Smart-Grid research described in [43].
in [43]. 16 of 23
In our experimental test, the IoT PQ sensor has been connected between the AC power source
and the electronic load, so that the IoT PQ sensor is continuously recording the voltage from the
Yokogawa Tektronix
power source and current at the terminal of the electronic load, and, at the same time, uploading it to
MDO3024
DL850E
the Cloud (ThingSpeak platform). The advantage of using both programmable loads are that the
Oscilloscope
reliability of the platform can be checked, as the registered and uploaded values by the sensor can be
checked with values generated by the power source and consumed by the load, as they both integrate
measuring devices. Programmable
The AC programmable power system integrates a transient Power Sourceanalyzer and can also run
network
several standardized PQ tests as voltage sags following IEC 61000-4-11. To have a controlled set of
measurements, different voltage sags (according to the standardized tests provided by the power
source) as well as different voltage RMS values, have been generated using the power source, to
supply the electronic load, which has also been changed simulating different appliances.
Simultaneously, the IoT PQ Sensor is measuring real voltage, current, energy as well as other power
values and detecting voltage sags. To check the quality of the measurement, apart from the above
equipment, two oscilloscopes have been connected for different purposes. The Yokogawa DL850E
oscilloscope isPQ recording
Meter the generated voltage waveforms at the terminal of the electronic load (i.e.,
the same voltage as the IoT PQ sensor is recording, and the RMS value can be also checked with it).
Moreover, the Tektronix MDO3024 Mixed Domain Oscilloscope is recording the SPI communication
Dual Power
signals between ADE7758 IC and the MCU Source(to check communication stability).

Electronic Load

Figure 13.
Figure 13. Overview
Overviewof
ofthe
thelaboratory
laboratorytest
testbench.
bench.

The sensor uploads information from the VRMS, IRMS, Active Energy and Apparent Energy
variables, which are obtained by aggregating several raw data points. Additionally, voltage sags are
also on-time monitored and stored in the Cloud. All those data uploaded to the Cloud are accessible
through an electronic device with an Internet connection. In fact, Figure 14 has been taken directly
from the channel of ThingSpeak used for this experiment [50] using a search engine on a PC. Figure 14
Appl. Sci. 2018, 8, x FOR PEER REVIEW 16 of 23

Yokogawa Tektronix
DL850E MDO3024
Appl. Sci. 2018, 8, 1320 Oscilloscope 16 of 23

In our experimental test, the IoT PQ sensor has been connected between the AC power source
Programmable
and the electronic load, so that the IoT PQ sensor is continuously recording the voltage from the
Power Source
power source and current at the terminal of the electronic load, and, at the same time, uploading it
to the Cloud (ThingSpeak platform). The advantage of using both programmable loads are that the
reliability of the platform can be checked, as the registered and uploaded values by the sensor can be
checked with values generated by the power source and consumed by the load, as they both integrate
measuring devices.
The AC programmable power system integrates a transient network analyzer and can also run
several standardized PQ tests as voltage sags following IEC 61000-4-11. To have a controlled set of
measurements, PQdifferent
Meter voltage sags (according to the standardized tests provided by the power
source) as well as different voltage RMS values, have been generated using the power source, to supply
the electronic load, which has also been changed simulating different appliances. Simultaneously,
Dual Power
the IoT PQ Sensor is measuring real Source voltage, current, energy as well as other power values and
detecting voltage sags. To check the quality of the measurement, apart from the above equipment,
two oscilloscopes have been connected for different purposes. The Yokogawa DL850E oscilloscope
is recording the generated voltage waveforms at the terminal of the electronic Electronic Load(i.e., the same
load
voltage as the IoT PQ sensor is recording, and the RMS value can be also checked with it). Moreover,
the Tektronix MDO3024 Mixed Domain Oscilloscope is recording the SPI communication signals
Figure 13. Overview of the laboratory test bench.
between ADE7758 IC and the MCU (to check communication stability).
The
The sensor
sensor uploads
uploads information
information fromfrom the
the VVRMS , I RMS, , Active
RMS, IRMS
Active Energy
Energy andand Apparent
Apparent Energy
Energy
variables,
variables, which
which are
are obtained
obtained by
by aggregating
aggregating several
several raw
raw data
data points. Additionally, voltage
points. Additionally, voltage sags
sags are
are
also on-time monitored and stored in the Cloud. All those data uploaded to the Cloud
also on-time monitored and stored in the Cloud. All those data uploaded to the Cloud are accessible are accessible
through
through an an electronic
electronic device
device with
with an
an Internet
Internet connection.
connection. In In fact,
fact, Figure
Figure 14
14 has
has been
been taken
taken directly
directly
from
from the
the channel
channel ofofThingSpeak
ThingSpeakusedusedforforthis
thisexperiment
experiment[50] [50]using
usingaasearch
searchengine
engineon onaaPC.
PC. Figure
Figure 14
14
(directly obtained from the ThingSpeak platform) shows the instant values as well
(directly obtained from the ThingSpeak platform) shows the instant values as well as the time stamp as the time stamp
of
of the
the upload
upload data,
data, given
given by
by ThingSpeak. Figure 14.
ThingSpeak. Figure 14. (a)
(a) VRMS
VRMS (b) (b) IRMS
IRMS uploaded
uploaded in in ThingSpeak.
ThingSpeak.
Figure
Figure 14a,b,
14a,b,represent
representthethe
voltages at the
voltages terminals
at the of theofprogrammable
terminals the programmable load andloadtheand
current
the flowing
current
through it due to applied voltage respectively, representing an appliance.
flowing through it due to applied voltage respectively, representing an appliance.

(a) (b)
Figure 14. (a) VRMS (b) IRMS uploaded in ThingSpeak.
Figure 14. (a) VRMS (b) IRMS uploaded in ThingSpeak.

To ensure the reliability of the system, the prototype was subjected to a long-term monitoring
test. To
Forensure the reliability
one hour, the IoT PQof the system,
sensor wasthe prototype the
monitoring wasabove
subjected to a long-term
variables monitoring
under different test.
supply
For one hour,
voltages the IoT
and load PQ in
states, sensor
total was monitoring
six different teststhe
of above
15 minvariables
duration under different
each, and supply
uploading voltages
data every
and load states, in total six different tests of 15 min duration each, and uploading data
30 s to the Cloud (aggregating values between sendings). The VRMS was changed in two different every 30 s to the
Cloud
voltage(aggregating values
levels (220 and 230 between sendings).
V), and the The V
current was was changed
RMSchanged
also in different
in three two different voltage
levels levels
(0.5, 0.8 and
(220 and 230 V), and the current was also changed in three different levels (0.5, 0.8 and 2 A). Figure 15
shows the monitored voltage and current values taken by the sensor during long-term monitoring test.
30 points were recorded in every test, all showing the stability of the sensor.
Appl.
Appl.Sci.
Sci.2018,
2018,8,8,xxFOR
FORPEER
PEERREVIEW
REVIEW 17
17 of
of 23
23

22A). Figure
A).Sci.
Appl. Figure 15 shows
showsthe
151320
2018, 8, themonitored
monitoredvoltage
voltageand
andcurrent
currentvalues
valuestaken
takenby
bythe
thesensor
sensorduring
duringlong-term
long-term
17 of 23
monitoring
monitoringtest.
test.30
30points
pointswere
wererecorded
recordedin
inevery
everytest,
test,all
allshowing
showingthe
thestability
stabilityof
ofthe
thesensor.
sensor.

Figure
Figure15.
Figure 15.Voltage
15. Voltage(blue)
Voltage and
(blue)and
(blue) current
andcurrent (dark
current(dark green)
(darkgreen) during
green)during the
duringthe long-term
thelong-term monitoring
long-termmonitoring test.
monitoringtest.
test.

To
To quantify
quantify thethe reliability
reliability of
of the
the sensor,
sensor, the
the cumulative
cumulative distribution
distribution function
function of of the
the
To quantify the reliability of the sensor, the cumulative distribution function of the measurements
measurements
measurementsshows showsthat
thatwhen
whensetting
setting220
220VVin
inthe
thepower
powersource,
source,thetheinterval
intervalbetween
between10%
10%andand90%
90%
shows that when setting 220 V in the power source, the interval between 10% and 90% of the registered
of
of the
the registered
registered values
valuesgives
gives 220.27
220.27toto220.4
220.4VV(Figure
(Figure 16a).
16a). In
Inthis
this interval,
interval, the
theaverage
averageisis220.3
220.3VV
values gives 220.27 to 220.4 V (Figure 16a). In this interval, the average is 220.3 V with 0.05 V standard
with
with0.05
0.05VVstandard
standarddeviation.
deviation.The
Thesame
sameratio
ratioappears
appearswhen
whensetting
settingthethepower
powersource
sourcetoto230
230V,V,in
in
deviation. The same ratio appears when setting the power source to 230 V, in this case the sensor
this
thiscase
casethe
thesensor
sensormeasurement
measurementvaries
variesfrom
from230.45
230.45to
to230.6
230.6VV(10–90%
(10–90%confidence
confidenceinterval)
interval)(Figure
(Figure
measurement varies from 230.45 to 230.6 V (10–90% confidence interval) (Figure 16b). The average
16b).
16b).The
Theaverage
averagevoltage
voltageisis230.4
230.4VV(with
(withaastandard
standarddeviation
deviation0.040.04V).
V).
voltage is 230.4 V (with a standard deviation 0.04 V).

(a)
(a) (b)
(b)

Figure 16. Cumulative distribution function of registered values with 220 (a) and 230 V (b).
Figure
Figure16.
16.Cumulative
Cumulativedistribution
distributionfunction
functionof
ofregistered
registeredvalues
valueswith
with220
220(a)
(a)and
and230
230VV(b).
(b).

In
In the
the case
case of
ofthe
thecurrent,
current, the
the standard
standard deviation
deviation isis below
below 0.01
0.01 A.
A.Regarding
Regarding the
the active
active and
and
apparent
apparent monitored energy data (Figure 17), both trends are equal as the load was configured asaa
monitored energy data (Figure 17), both trends are equal as the load was configured as
pure
pureresistive
resistiveload
resistive loadwith
load withunit
with unitpower
unit powerfactor.
power factor.
factor.
Appl. Sci. 2018, 8, 1320 18 of 23
Appl.Sci.
Appl. Sci.2018,
2018,8,8,xxFOR
FORPEER
PEERREVIEW
REVIEW 18 of
18 of 23
23

(a)
(a) (b)
(b)
Figure17.
Figure 17.(a)
(a)Active
ActiveEnergy
Energyduring
duringthe
thelong-term
long-termmonitoring
monitoringtest.
test.(b)
(b)Apparent
ApparentEnergy
Energyduring
duringthe
the
Figure 17. (a) Active Energy during the long-term monitoring test. (b) Apparent Energy during the
long-termmonitoring
long-term monitoringtest.
test.
long-term monitoring test.

Apartfrom
Apart fromvoltage
voltageand andcurrent
currentmagnitudes,
magnitudes, different
differentvoltage
voltagesags
sags(with
(withdifferent
differentmagnitudes
magnitudes
and Apart from
durations) voltage
have and
been current
created magnitudes,
in the power different
source and voltage
fed tosags
and durations) have been created in the power source and fed to the electronic load to be monitoredthe (with different
electronic load magnitudes
to be and
monitored
durations)
by the
by the IoT have
IoT PQ been
PQ meter
meter andcreated
and checkin the
check the power
the event source
event detectionand fed to the
detection functionality. electronic
functionality. Therefore, load to
Therefore, the be monitored
the California by
California Power the
Power
IoT PQ
Sourcewas
Source meter and
wasconfigured check
configuredto the event
tocreate detection
createuser-defined functionality.
user-definedsags. sags.The
Thefirst Therefore,
firstsag
sagtested the
testedwas California
wasaa380 380ms Power
ms83.5%
83.5%VVNOMSource was
(Figure
NOM(Figure
configured
18)where
18) wherethe to create
theVVRMS user-defined
changefrom
RMSchange fromthe sags. The
thenominal first
nominalvalue sag tested
value(230(230V) was
V)to a
to192.05380 ms 83.5%
192.05VVduring
during19 V19line (Figure
linefrequency
NOM 18) where
frequencycycles,cycles,
the
andVafter
and afterchange
RMS these from
these 380
380 ms,thethere
ms, nominal
there isis aavalue
recovery(230and
recovery V) tothe
and 192.05
the V during
voltage
voltage 19 to
returns
returns line frequency
to 230
230 V. Figure
V. cycles,
Figure and after
18 shows
18 shows the
the
these
voltage
voltage 380measured
ms, there iswith
measured a recovery
with the and the voltage
the Yokogawa
Yokogawa DL850E
DL850E returns to 230 V. Figure
Oscilloscope
Oscilloscope 18 shows with
and processed
and processed the
withvoltage
MATLAB.
MATLAB. measured This
This
with
allows
allows thegraphical
Yokogawa
graphical DL850E
testing
testing of Oscilloscope
of the voltage
the and processed
voltage waveform
waveform and with
and MATLAB.as
consideration
consideration This
as allows graphical
aa reference
reference to compare
to comparetesting
the
the
of the voltage
measurements waveform
measurementsrecorded recordedby and
bythe consideration
theIoT IoTPQ PQsensor.as
sensor.Ina reference
Infact,
fact,the to
thedata compare
datathat the
thatare measurements
areuploaded
uploadedto recorded
toThingSpeak
ThingSpeakare by
are
the IoT
those PQ
that sensor.
are In
important fact, the
to data
quantify that
a are
sag, uploaded
i.e., the to
voltageThingSpeak
magnitude
those that are important to quantify a sag, i.e., the voltage magnitude of the sag (in this case 192.05areofthose
the that
sag are
(in important
this case to
192.05
quantify
V)and
V) andthe a sag, i.e.,
theduration the
duration(380 voltage
(380ms msin magnitude
inthis
thiscase). of
case).The the sag
Theresult (in
resultof this
ofthis case
thisfirst 192.05 V)
firstmeasurement and
measurementgiven the duration
givenby bythe (380
theIoT ms
IoTcloud in
cloud
this case). The
systemisisshown
system result
shownin inthe of this
thefirst first
firstrow
rowin measurement
inthe
theTable
Table33Saggiven by
SagReport. the
Report. IoT cloud system is shown in the first row
in the Table 3 Sag Report.

Figure18.
Figure 18.Example
Exampleof
ofSag
Sag11(380
(380ms
ms83.5%
83.5%VVNOM
NOM).).
Figure 18. Example of Sag 1 (380 ms 83.5% VNOM ).

Another magnitude
Another magnitude and and duration
duration has
has been
been selected.
selected. The
The second
second voltage
voltage sag
sag generated
generated and
and
monitored by
monitored by the
the sensor
sensor isis aa 210
210 ms
ms 79.6%
79.6% VVNOM (Figure 19).
NOM (Figure 19). The
The measurement
measurement registered
registered at
at the
the
ThingSpeak platform
ThingSpeak platform byby the
the IoTIoT PQ
PQ sensor
sensor isis shown
shown atat row
row 22 of
of Table
Table 3,3, showing
showing the
the magnitude
magnitude
Appl. Sci. 2018, 8, 1320 19 of 23

Table 3. Sag Report.

SAG Timestamp SAG Duration (s) Minimum VRMS Value


31 January 2018 10:48:51 0.38 192.5
31 January 2018 10:50:22 0.21 183.4
31 January 2018 10:51:52 1.2 101.2
31 January 2018 12:26:29 0.16 191.3
31 January 2018 12:31:14 0.28 197.6
31 January 2018 12:33:44 0.18 184.6

Another magnitude and duration has been selected. The second voltage sag generated
Appl. Sci. 2018, 8, x FOR PEER REVIEW
and
19 of 23
monitored by the sensor is a 210 ms 79.6% VNOM (Figure 19). The measurement registered at the
ThingSpeak
(183.4 V) andplatform by the(210
the duration IoTms)
PQ without
sensor isno
shown
error at
in row 2 of Table 3, showing
the measurement. the magnitude
In this case, the voltage
(183.4 V) and the duration (210 ms) without no error in the measurement. In this
waveform measured by the Yokogawa DL850E instrument is shown in Figure 19. The sag changes case, the voltage
waveform measured
from the nominal by to
value thea Yokogawa DL850E
voltage level instrument
of 183.1 is shown
V, kept during 10.5 in Figureat19.
periods lineThe sag changes
frequency.
from the nominal value to a voltage level of 183.1 V, kept during 10.5 periods at line frequency.

Figure 19. Example of Sag 2 (210 ms 79.6% VNOM).


Figure 19. Example of Sag 2 (210 ms 79.6% VNOM ).

The report shown in Table 3 is generated within the ThingSpeak platform, done with MATLAB
The report shown in Table 3 is generated within the ThingSpeak platform, done with MATLAB
code included in the Cloud. The report contains the historic sag events measured by the IoT sensor.
code included in the Cloud. The report contains the historic sag events measured by the IoT sensor.
The two first voltage sags represent the sags previously shown in Figures 18 and 19 respectively. This
The two first voltage sags represent the sags previously shown in Figures 18 and 19 respectively. This is
is another novelty of this paper: a sag report generated in the Cloud with data from an IoT PQ sensor.
another novelty of this paper: a sag report generated in the Cloud with data from an IoT PQ sensor.
The interesting point here is that the sag timestamp comes from the RTC peripheral information, so
The interesting point here is that the sag timestamp comes from the RTC peripheral information, so it is
it is a precise value. The disadvantage with ThingSpeak is that the timestamp is given by the time
a precise value. The disadvantage with ThingSpeak is that the timestamp is given by the time when the
when the measurement is uploaded, but in this case, the information sent to the Cloud also contains
measurement is uploaded, but in this case, the information sent to the Cloud also contains information
information about the timestamp.
about the timestamp.
Extra functionality has been implemented
Table in ThingSpeak
3. Sag Report. with a MATLAB code integrated in the
application. For the usefulness of the management operator, not only is a PQ report needed, but also a
SAG Timestamp
graphical way of looking, such as includingSAG Duration
the ability (s) ifMinimum
to show VRMS
the recorded Value
sag meets the standard.
31 January 2018 10:48:51 0.38 192.5
Therefore, an advanced visualization option has been considered to incorporate the SEMI-F47 voltage
31 January
sag immunity standard 2018
curve 10:50:22
[49] in the ThingSpeak 0.21web page itself (Figure
183.420). Similar to Figure 14,
31 January
this curve can also be seen2018
with10:51:52
a cellular phone 1.2 or tablet, as long as it101.2
has an Internet connection.
31 January 2018 12:26:29 0.16 191.3
SEMI-F47 graphs sag depth vs. duration, in a similar manner to the ITI-CBEMA curve [51]. To this end,
31 January 2018 12:31:14 0.28 197.6
31 January 2018 12:33:44 0.18 184.6

Extra functionality has been implemented in ThingSpeak with a MATLAB code integrated in
the application. For the usefulness of the management operator, not only is a PQ report needed, but
Appl. Sci. 2018, 8, 1320 20 of 23

a MATLAB code has been incorporated in ThingSpeak, which plots the limits given by the standard
Appl. Sci. 2018, 8, x FOR PEER REVIEW 20 of 23
(in terms of duration and magnitude of the sag). Moreover, once a voltage sag is recorded, taking
the
andinformation from the report,
its voltage magnitude (%) with the sag is
a blue represented
cross. Figure 20through
shows someits duration
voltage (insagss)used
and initsthis
voltage
new
magnitude (%) with a blue cross. Figure 20 shows some voltage sags used in this
experiment, which, in contrast to the report and as indicated above, allows the user a graphical way new experiment,
which, in contrast
of accessing to the report in
the information andrelation
as indicated
to theabove, allows theMainly,
phenomenon. user a graphical
this sag way
depthof accessing the
vs. duration
information
representation in relation
shows iftothe
thesag
phenomenon.
is (or not) inMainly, this sag area.
an acceptable depthThis
vs. duration
curve canrepresentation shows if
offer, at first glimpse,
the sag is (or not) in an acceptable area. This curve can offer, at first glimpse, all the
all the sag experimented in the facility during a period. Accordingly, facility managers may confront sag experimented
in the
this facility during
information withathe
period. Accordingly,
voltage facility capability
sag ride-through managers information
may confront ofthis
the information with the
equipment installed.
voltage sag ride-through capability information of the equipment installed. Therefore,
Therefore, they can take advantage of this curve whenever they purchase new equipment complying they can take
advantage of
to this standard. this curve whenever they purchase new equipment complying to this standard.

Figure 20. SEMI-F47-curve showing the sags programmed in the experiment.


Figure 20. SEMI-F47-curve showing the sags programmed in the experiment.

6. Conclusions and Future Work


6. Conclusions and Future Work
Uninterrupted operations and business continuity are key requirements for any highly
Uninterrupted
automated building operations
located underand business continuity
the Industry are key requirements
4.0 paradigm, for which for any highly
Power Quality automated
plays an
building located under the Industry 4.0 paradigm, for which Power
extremely important role. Power Quality is a complex domain, covering over a dozen problem Quality plays an extremely
important
areas. Early role.detection
Power Quality is a complex
and analysis of suchdomain,Power covering
Quality over a dozen problem
disturbances areas. Early
are essential for
detection and analysis of such Power Quality disturbances are essential
improving the quality of service and enhancing the productivity of the system. At present, most for improving the quality of
service and enhancing
energy-intensive the productivity
buildings suffer from of athe system.
certain At present,
degree from most
poor energy-intensive
Power Quality, buildings
adopting
suffer
partial solutions to each problem. However, there is no single solution.solutions
from a certain degree from poor Power Quality, adopting partial Relatively tolittle
eachattention
problem.
However, there is no single
has been focused on Power Quality. solution. Relatively little attention has been focused on Power Quality.
The
The advantage
advantage of of the
the system
system presented
presented is is that
that sensor
sensor data
data could
could also
also be
be indicative
indicative of of equipment
equipment
performance
performance regarding efficiency and Power Quality standards. With the current Internet of
regarding efficiency and Power Quality standards. With the current Internet of Things
Things
prototype,
prototype, the user will be able to detect not only most Power Quality steady-state disturbances but
the user will be able to detect not only most Power Quality steady-state disturbances but
events
events such
such as as voltage
voltage sag,
sag, while
while alsoalso monitoring
monitoring the the energy
energy consumption.
consumption.
To
To our
ourknowledge,
knowledge, there
theredoes notnot
does existexist
any anyInternet of Things
Internet systemsystem
of Things devoted to Power
devoted to Quality
Power
monitoring. This is very
Quality monitoring. Thissuitable
is veryfor industrial
suitable for or commercial
industrial facility submetering.
or commercial Through the
facility submetering.
Cloud-based
Through theInternet of Things
Cloud-based platform,
Internet the information
of Things platform, canthebe accessed,
information analyzed,
can bestored, and
accessed,
visualized throughand
analyzed, stored, different devices
visualized in a user-friendly
through different devicesmanner,in aavoiding the need
user-friendly for significant
manner, avoiding
investment in proprietary software infrastructure typically required for
the need for significant investment in proprietary software infrastructure typically required other measurement systems.
for
Future work can
other measurement systems. be done towards customizing Power Quality statistics that are relevant to a
particular
Future appliance
work canorbe system
done to better forecast
towards customizing overall facility
Power health.
Quality In fact, that
statistics a meshare of Internet
relevant toofa
Things Power Quality sensors and their raw measurement data can be aggregated
particular appliance or system to better forecast overall facility health. In fact, a mesh of Internet of to correlate and help
identify sourcesQuality
Things Power of disturbances
sensors andin thetheir
nearraw
future using machine-learning
measurement data can be strategies.
aggregatedThose sensors and
to correlate can
help identify sources of disturbances in the near future using machine-learning strategies. Those
sensors can also be embedded into the appliance for tighter integration and surveillance. This could
support higher understanding of the currently consumed electricity e.g., by the comparison between
identical devices consumption, monitoring trends and conditions, or even further, allowing an
Appl. Sci. 2018, 8, 1320 21 of 23

also be embedded into the appliance for tighter integration and surveillance. This could support higher
understanding of the currently consumed electricity e.g., by the comparison between identical devices
consumption, monitoring trends and conditions, or even further, allowing an optimized maintenance
scheduling focused on preventative maintenance only when it is required. Moreover, the detection of
Power Quality disturbance leads to the anticipation of faults with early-stage alerts based on on-time
data streams. These data can be used to continuously track and diagnose ride-through capabilities
within devices to withstand the fluctuations in the electrical supply, pro-actively and remotely identify
and manage reliability issues, establishing whether the responsibility is from the distribution system or
because of incidents inside customer premises, thereby boosting the ability to act and react in real-time,
or near real-time, for the effective and efficient use of electricity.
In the future, authors will make the prototype smarter from two points of view. At the initial
level, algorithms might be designed and executed within the prototype to help in selecting only the
relevant information from an energy point of view. At a higher level, on the Cloud side, authors would
consider applying machine learning to exploit all the received information from the Internet of Things
Power Quality sensors to discover possible disturbances and anomalous behavior.

Author Contributions: A.M.-M. made a comprehensive review of the existing literature. A.G.d.-C. address
the conception, research, and design of the work presented here. M.A.-R. and R.M.-G. were involved in the
development and integration of the system’s components. E.C.-C. guided the whole work, edited the language,
and provided their comments on the manuscript. All authors contributed to writing and reviewing the paper.
Funding: This research received no external funding.
Acknowledgments: This research is supported by the Spanish Ministry of Economy and Competitiveness
under Project TEC2016-77632-C3-2-R. Also, the authors would like to thank the support of the University
of Cordoba, through the program “III Becas Semillero de Investigación” and III Plan Propio Galileo,
modalidad IV-UCO-SOCIAL-INNOVA.
Conflicts of Interest: The authors declare no conflict of interest.

References
1. Ouf, M.M.; Issa, M.H. Energy consumption analysis of school buildings in Manitoba, Canada. Int. J. Sustain.
Built Environ. 2017, 6, 359–371. [CrossRef]
2. Marinakis, V.; Doukas, H. An Advanced IoT-based System for Intelligent Energy Management in Buildings.
Sensors 2018, 18, 610. [CrossRef] [PubMed]
3. Moreno-Muñoz, A. Power Quality: Mitigation Technologies in a Distributed Environment; Springer: London,
UK, 2007.
4. Institute of Electrical and Electronics Engineers Standards Association (IEEE-SA). Recommended Practice for
Monitoring Electric Power Quality; IEEE Std 1159-2009 (Revision of IEEE Std 1159-1995); IEEE: Piscataway, NJ,
USA, 2009; p. 81.
5. Gulachenski, E.M. The low cost alternative to UPS. In Proceedings of the Electro/International, Boston, MA,
USA, 21–23 June 1995; pp. 97–107.
6. Moreno-Munoz, A.; Pallares, V.; Galisteo, P.; Gonzalez-de-la-Rosa, J.J. Study of voltage sag in a highly
automated plant. In Proceedings of the MELECON 2006 IEEE Mediterranean Electrotechnical Conference,
Malaga, Spain, 16–19 May 2006; pp. 1060–1063.
7. CENELEC Std. EN 50160: 2010 Voltage Characteristics of Electricity Suppplied by Public Electricity Networks;
CENELEC: Brussels, Belgium, 2010.
8. International Electrotechnical Commission, IEC 61000-4-30:2015, Electromagnetic Compatibility (EMC).
Part 4-30: Testing and Measurement Techniques—Power Quality Measurement Methods; IEC: Geneva,
Switzerland, 2015.
9. International Electrotechnical Commission, IEC 61000-4-7:2002+A1:2008, Electromagnetic Compatibility
(EMC). Part 4-7: Testing and Measurement Techniques—General Guide on Harmonics and Interharmonics
Measurements and Instrumentation, for Power Supply Systems and Equipment Connected Thereto; IEC: Geneva,
Switzerland, 2018.
Appl. Sci. 2018, 8, 1320 22 of 23

10. Institute of Electrical and Electronics Engineers Standards Association (IEEE-SA). IEEE P2413-Standard for
an Architectural Framework for the Internet of Things; IEEE: New York, NY, USA, 2016.
11. Voas, J. NIST Special Publication 800-183. Networks of ‘Things’. 2016. Available online: https://csrc.nist.
gov/publications/detail/sp/800-183/final (accessed on 30 July 2018).
12. Thingworx. Available online: https://www.thingworx.com/ (accessed on 30 July 2018).
13. Kaa IoT Development Platform. Available online: https://www.kaaproject.org/ (accessed on 30 January 2017).
14. Predix. Available online: https://www.predix.io/registration/ (accessed on 30 January 2017).
15. Oracle Cloud. Available online: https://cloud.oracle.com/iot (accessed on 30 January 2017).
16. Microsoft Azure. Available online: https://www.microsoft.com/en-us/cloud-platform/internet-of-things-
azure-iot-suite (accessed on 30 July 2018).
17. Abubakar, I.; Khalid, S.N.; Mustafa, M.W.; Shareef, H.; Mustapha, M. Application of load monitoring in
appliances’ energy management—A review. Renew. Sustain. Energy Rev. 2017, 67, 235–245. [CrossRef]
18. Salesforce. Available online: http://www.salesforce.com/iot-cloud/ (accessed on 30 July 2018).
19. Amini, M.H.; Frye, J.; Ilić, M.D.; Karabasoglu, O. Smart residential energy scheduling utilizing two stage
Mixed Integer Linear Programming. In Proceedings of the 2015 North American Power Symposium (NAPS),
Charlotte, NC, USA, 4–6 Octpber 2015; pp. 1–6.
20. Viswanath, S.K.; Yuen, C.; Tushar, W.; Li, W.T.; Wen, C.K.; Hu, K.; Chen, C.; Liu, X. System design of the
internet of things for residential smart grid. IEEE Wirel. Commun. 2016, 23, 90–98. [CrossRef]
21. Cisco IoT. Available online: http://www.cisco.com/c/en/us/solutions/internet-of-things/overview.html
(accessed on 30 July 2018).
22. Tushar, W.; Yuen, C.; Chai, B.; Huang, S.; Wood, K.L.; Kerk, S.G.; Yang, Z. Smart Grid Testbed for Demand
Focused Energy Management in End User Environments. IEEE Wirel. Commun. 2016, 23, 70–80. [CrossRef]
23. Bayram, I.S.; Ustun, T.S. A survey on behind the meter energy management systems in smart grid.
Renew. Sustain. Energy Rev. 2017, 72, 1208–1232. [CrossRef]
24. Bahrami, S.; Amini, M.H.; Shafie-khah, M.; Catalao, J.P. A Decentralized Electricity Market Scheme Enabling
Demand Response Deployment. IEEE Trans. Power Syst. 2018, 33, 4218–4227. [CrossRef]
25. Palacios-Garcia, E.J.; Rodriguez-Diaz, E.; Anvari-Moghaddam, A.; Moreno-Munoz, A. Using smart meters
data for energy management operations and power quality monitoring in a microgrid. In Proceedings of the
2017 IEEE 26th International Symposium on Industrial Electronics (ISIE), Edinburgh, UK, 19–21 June 2017;
pp. 1725–1731.
26. Albu, M.M.; Sănduleac, M.; Stănescu, C. Syncretic Use of Smart Meters for Power Quality Monitoring in
Emerging Networks. IEEE Trans. Smart Grid 2017, 8, 485–492. [CrossRef]
27. Morales-Velazquez, L.; de Jesus Romero-Troncoso, R.; Herrera-Ruiz, G.; Morinigo-Sotelo, D.; Osornio-Rios, R.A.
Smart sensor network for power quality monitoring in electrical installations. Measurement 2017, 103, 133–142.
[CrossRef]
28. Guimarães, A.M.F. Smart energy monitoring system with ADE7758 IC. In Proceedings of the 2015 5th
International Youth Conference on Energy (IYCE), Pisa, Italy, 27–30 May 2015; pp. 1–5.
29. Thongkhao, Y.; Pora, W. A low-cost Wi-Fi smart plug with on-off and Energy Metering functions.
In Proceedings of the 13th International Conference on Electrical Engineering/Electronics, Computer,
Telecommunications and Information Technology (ECTI-CON), Chiang Mai, Thailand, 28 June–1 July 2016;
pp. 1–5.
30. Tsunoda, Y.; Tsuchiya, C.; Segawa, Y.; Sawaya, H.; Hasegawa, M.; Ishigaki, S.; Ishibashi, K. A Small-Size
Energy-Harvesting Electric Power Sensor for Implementing Existing Electrical Appliances Into HEMS.
IEEE Sens. J. 2016, 16, 457–463. [CrossRef]
31. Spanò, E.; Niccolini, L.; Di Pascoli, S.; Iannacconeluca, G. Last-Meter Smart Grid Embedded in an
Internet-of-Things Platform. IEEE Trans. Smart Grid 2015, 6, 468–476. [CrossRef]
32. ThingsBoard. Available online: https://thingsboard.io/docs/ (accessed on 30 July 2018).
33. Open IoT. Available online: http://www.openiot.eu/?page_id=70 (accessed on 30 July 2018).
34. Kotsampopoulos, P.; Rigas, A.; Kirchhof, J.; Messinis, G.; Dimeas, A.; Hatziargyriou, N.; Rogakos, V.;
Andreadis, K. EMC Issues in the Interaction Between Smart Meters and Power-Electronic Interfaces.
IEEE Trans. Power Deliv. 2017, 32, 822–831. [CrossRef]
35. Thinger. Available online: http://docs.thinger.io/ (accessed on 30 July 2018).
36. Carriots. Available online: https://www.carriots.com/ (accessed on 30 July 2018).
Appl. Sci. 2018, 8, 1320 23 of 23

37. Particle. Available online: https://docs.particle.io/ (accessed on 30 July 2018).


38. Getting Started with ThingSpeak. Available online: https://es.mathworks.com/help/thingspeak/getting-
started-with-thingspeak.html (accessed on 30 January 2017).
39. Subhani, S.C.V.; Coben, J.F.G. A Literature Survey on Power Quality Disturbances in the Frequency Range
of 2–150 kHz. In Proceedings of the International Conference on Renewable Energies and Power Quality
(ICREPQ’14), Málaga, Spain, 4–6 April 2017.
40. ATMega328P-PU Datasheet. Available online: http://ww1.microchip.com/downloads/en/DeviceDoc/
Atmel-42735-8-bit-AVR-Microcontroller-ATmega328-328P_Datasheet.pdf (accessed on 30 January 2017).
41. ADE7758 Datasheet. Available online: http://www.analog.com/media/en/technical-documentation/data-
sheets/ADE7758.pdf (accessed on 30 January 2017).
42. ESP8266EX Datasheet. Available online: http://www.espressif.com/sites/default/files/documentation/0a-
esp8266ex_datasheet_en.pdf (accessed on 30 January 2017).
43. DS1307ZN I2C Real-Time Clock Datasheet. Available online: http://datasheets.maximintegrated.com/en/
ds/DS1307.pdf (accessed on 30 January 2017).
44. Alfieri, L.; Bracale, A.; Larsson, A. New power quality indices for the assessment of waveform distortions
from 0 to 150 kHz in power systems with renewable generation and modern non-linear loads. Energies 2017,
10, 1633. [CrossRef]
45. ix 3001 California Instrument. Available online: http://www.programmablepower.com/ac-power-source/i-
iX-Series-II/Specifications.htm (accessed on 30 July 2018).
46. Amazon AWS. Available online: https://aws.amazon.com/es/ (accessed on 30 July 2018).
47. JWG C4/C6.29 Power Quality Aspects of Solar Power—Progress Report. Available online: http://c4.cigre.
org/WG-Area/JWG-C4-C6.29-Power-Quality-Aspects-of-Solar-Power (accessed on 30 July 2018).
48. MQTT Version 3.1.1. Available online: http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.
html (accessed on 30 January 2017).
49. SEMI F47-0706. Specification for Semiconductor Processing Equipment Voltage Sag Immunity. 2006.
Available online: http://ams.semi.org/ebusiness/standards/SEMIStandardDetail.aspx?ProductID=211&
DownloadID=594 (accessed on 30 July 2018).
50. PQ Sensor. Available online: https://thingspeak.com/channels/438573 (accessed on 30 July 2018).
51. Information Technology Industry Council. ITI (CBEMA) Curve Application Note; Technology Committee 3
(TC3) of the ITI Council: Washington, DC, USA, 2000.

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

You might also like