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

378 JOURNAL 

OF ELECTRONIC SCIENCE AND TECHNOLOGY, VOL. 18, NO. 4, DECEMBER 2020
 

Digital Object Identifier: 10.11989/JEST.1674-862X.90616103
Article Number: 90616103

Smart Meter Development for Cloud-Based Home


Electricity Monitor System
Yeong-Chin Chen* | Sunneng Sandino Berutu | Yue-Hsien Wang
 
Abstract—Α cloud-based home electricity data-monitoring system, which is based on an Arduino Mega controller, is
proposed for monitoring the electricity consumption (electrical power) and power quality (PQ) in home. This system
is also capable of monitoring the fundamental frequency and supply-voltage transients to ensure that the appliances
operate in a safe operation range. The measured data (voltage and current) are transmitted through a WiFi device
between the Arduino controller and server. The transmission control protocol (TCP) server is set up to acquire the
high-data transmission rate. The server system immediately displays the calculated parameters and the waveform of
the acquired signal. A comparison with a standard measurement device shows that the proposed system, which can
be built at a low cost, exhibits the same functions as a factory product.

Index Terms—Arduino  controller,  cloud,  electrical  power,  power  monitoring,  transmission  control  protocol  (TCP)
server, WiFi.

1. Introduction
According to the statistics of Taipower, 24000 high-voltage consumers, who currently account for 60% of the
total electricity consumption in Taiwan, have installed smart meters. However, general-public users are not willing
to install these meters due to the high cost and need to send an application to Taipower before the installation. The
procedures  are  complicated  and  involve  many  communications  problems.  The  government  expected  an
installation[1] of 200000 smart meters by September 2018. However, only 150000 were completed. In recent years,
the  power  deficit  has  become  enormous  during  summer.  This  problem  results  in  power-supply  units  surging,
electricity  charge  rate  issues,  power  waste  issues,  and  even  worse,  the  endless  argument  on  the  non-nuclear
power-supply  issue.  However,  since  the  power  output  cannot  be  increased  immediately,  the  electrical  power
management for the efficient use of electricity has become an extremely important issue.
The Internet of things (IoT)[2] is a revolutionary technology capable of achieving sensing integration as well as
communications capabilities between common devices. IoT has enabled various devices to be used for monitoring
 
*Corresponding author
Manuscript received 2019-02-26; revised 2020-11-23.
This work was supported by MOST under Grant No. 106-2221-E-468 -011-MY2.
Y.-C.  Chen  and  S.  S.  Berutu  are  with  the  Department  of  Computer  Science  and  Information  Engineering,  Asia  University,
Taichung 41354 (e-mail: ycchenster@gmail.com; sandinoberutu@gmail.com).
Y.-H.  Wang  is  with  the  Department  of  Computer  Science  and  Engineening,  National  Chung  Hsing  Unversity,  Taichung  32001
(e-mail: qwerbakecool80001@gmail.com).
Color versions of one or more of the figures in this paper are available online at http://www.journal.uestc.edu.cn.
Publishing editor: Yu-Lian He
CHEN et al.: Smart Meter Development for Cloud-Based Home Electricity Monitor System 379

important electrical, physical, and environmental parameters. This information is then used to analyze, identify, and
solve various problems related to everyday life[2]. IoT has enabled power-monitoring devices to assist in solving this
problem by providing valuable information on electricity consumption and power quality (PQ)[3], which includes the
measurements of the fundamental frequency, the root mean square (RMS) of voltage, and the power factor (PF).
In this way, the purpose of power savings and power safety can be achieved.
Using the IoT smart power meters, the power consumption of various electrical appliances can be automatically
measured, logged, and analyzed. This will also help in identifying major power consumers and promoting energy
awareness  in  society.  In  this  research,  a  power-monitoring  system  is  proposed,  which  is  based  on  a  low-cost
Arduino controller[4] and some electricity sensors with embedded IEEE 802.11 (WiFi) wireless communications. The
instantaneous  power  signal  (voltage  and  current)  is  wirelessly  transmitted  to  a  remote  server  for  storage  and
analysis.  A  hypertext  preprocessor  (PHP)  web  program,  which  is  developed  to  analyze  the  power  signal  data,
simultaneously displays the analysis results, electrical power energy, electrical PF, and fundamental frequency[5] on
the  browser’s  window.  The  user  can  retrieve  statistically  analyzed  data  stored  on  the  server,  using  a
computer or a smartphone over the Internet. An early warning system is also provided. This system sends a
warning alarm to remind the user of a problem with the equipment when the electrical performance is out of
the  specified  range.  As  an  advanced  future  application,  the  server  could  also  provide  a  big-data  query  and
convert  the  queried  degree  into  a  form,  with  which  the  users  can  analyze  the  electricity  consumption,  thus
improving the power-usage strategy of users.
The rest of the paper is organized as follows. The research methods and materials are described in Section 2.
The results and conclusion are presented in Sections 3 and 4, respectively.

2. Methods and Materials


2.1. Methods
In this paper, the proposed system is schematically illustrated in Fig. 1.
Initially,  the  alternating-current  (AC)  voltage  is  connected  to  ZMPT101B[6]  and  transmitted  to  the  ACS712[7]
socket  to  measure  the  current.  Then,  the  signal  is  

ADC
processed  by  an  analog-to-digital  converter ZMPT- Smart plug
101B
(ADC)—Arduino[8].  By  employing  the  universal Arduino Mega
asynchronous receiver/transmitter (UART) transmission, ACS712
UART
the signal is transmitted to a node micro-controller unit
(NodeMCU)[9]  device  based  on  ESP  8266  WiFi.  This
NodeMCU Appliances
device  transfers  data,  using  a  transmission  control
protocol  (TCP)[10]  connection,  to  a  server  which  is  built
WiFi

with  an  open  source  programming  language  from


Google  (GO)[11].  Finally,  the  power  consumption Internet
performance  is  monitored  by  a  multiple-platform
display.  In  this  work,  the  signal’s  frequency  is
detected  and  calculated  by  using  the  zero-crossing GO server

algorithm[5].  Then,  the  Fourier  series  algorithm[5]  is


JSON

applied  to  filter  out  the  noise  and  high  harmonics. Platform Platform

RMS[12]  is  the  effective  value,  which  determines  the


electricity  variation.  PF  is  determined  by  the  phase Server and
database
between  the  measured  voltage  and  current  signals.
The power consumption is also calculated by using the Fig. 1. Proposed system architecture.
380 JOURNAL OF ELECTRONIC SCIENCE AND TECHNOLOGY, VOL. 18, NO. 4, DECEMBER 2020

RMS  values  of  the  voltage  and  current.  The  monitoring  system  flowchart  is  shown  in  Fig.  2.  Finally,  the  results
produced are compared with those obtained by a power measurement standard device (HIOKI PW3360)[13].

System start
System start
Transmission

Arduino catches 400 Alarm system


signals data System side
Device side
UART transmits
NodeMCU receives
data
WiFi TCP transmits
GO server receives
Server side data
JSON format
Database stores PHP and JavaScript start data algorithm, statistics
Database stores data
data calculation, and catch data continuously

Analyze
Start charting Display data
all exceptions

Database stores time, Normal factor value


Display web Start charting
site, and factor values calculation
alarm system
at that time

No Yes
Normal?

Fig. 2. Flowchart of the proposed home electricity monitoring system.

2.2. ZMPT101B Voltage Sensor


This  sensor  converts  the  AC  voltage  of  110  V  to
 

R
220  V  into  an  acceptable  value  range  for  the  Arduino
C r
controller. In Fig. 3, the variable resistor (r) adjusts the R′
AC-input voltage. In this way, a user can manually vary U1=0 to 1000 V −
this  voltage. The  output voltage  can  be  adjusted  to  an ZMPT101B
+
0P07
U2
amplitude range of 0 to 5 V, which is acceptable by the
Arduino  controller.  The  rated  operating  current  of
ZMPT101B  is  between  1  mA  and  2  mA.  When  the Fig.  3.  Schematic  diagram  of  the  ZMPT101B  sensor
equivalent  voltage  is  ≤ 100  V,  the  current  is  I = 2  mA, voltage.
whereas when the voltage is ≥ 220 V, the current is usually 1 mA ≤ I ≤ 2 mA to reduce the power consumed by the
resistor. Based on the application guide of ZMPT101B[14], the variable resistor ratio should be adjusted according to
the experimental requirements. In this work, the current limiting resistor (R ) is set to 60 kΩ (110 V/2 mA) to make

the  input  current  less  than  2  mA.  If  the  maximum  output  voltage  is  set  to  3.5  V,  the  sampling  resistor  R  can  be
obtained from
Voutput,max ′ 3.5
R= R = √ × 60000 = 1.35 kΩ. (1)
Viutput,max 110 × 2
CHEN et al.: Smart Meter Development for Cloud-Based Home Electricity Monitor System 381

2.3. ACS712 Current Sensor  

The  Arduino  controller  receives  only  the  output 4.5

voltage.  ACS712[7]  converts  the  input  current  into 4.0

voltage using a formula to obtain the real current value 3.5

of  a  home  appliance[8].  The  output  voltage  (Vout)  of 3.0

Vout (V)
ACS712 as a linear function of the actual current (Ip) is 2.5

shown in Fig. 4. 2.0

According  to  Fig.  4,  the  output  voltage  can  be 1.5

written as follows: 1.0
0.5
1
Vout = Ip + 2.5 (V) (2) 0
15 −30 −20 −10 0 10 20 30
Ip (A)
where  −30 A ≤ Ip ≤ 30 A .  The  Arduino  ADC  resolves
1  bit  to  10  bits  (0  to  1023),  and  the  Hall-current Fig. 4. Graph of the output voltage vs. input current.
sensing module can be used to measure the current. As the Arduino acquires a value v, which is the output
voltage of the current sensor, the sensing current can be obtained as follows:

Ip = [(
v
× 5) − 2.5] × 15 (A). (3)
1023
When there is no current input, i.e.  Ip = 0, the component itself will produce an output voltage of 2.5 V to the
Arduino controller.

2.4. Sampling Frequency Determination


The  Arduino  data-acquisition  approach  uses  the  analogRead(0)  instruction  to  convert  analog  information  into
digital information (ADC module). The chip used in the Arduino is the ATMega chip[15]. Its oscillation frequency is
16 MHz, and its internal ADC prescaler select (ADPS) bit setting is shown in Table 1[16].
Table 1: Prescaler setting for the Arduino ADC

Prescale ADPS2 ADPS1 ADPS0 Clock frequency (MHz) Sampling rate (kHz)


2 0 0 1 8.000 615.0
4 0 1 0 4.000 317.0
8 0 1 1 2.000 153.0
16 1 0 0 1.000 76.8
32 1 0 1 0.500 38.4
64 1 1 0 0.250 19.2
128 1 1 1 0.125   9.6

For the 16-MHz Arduino, if the default prescaler is set to 128 (16 MHz/128 = 125 kHz ) and the implementation


of an ADC function requires 13 cycles, then the sampling rate in the Arduino ADC module could be theoretically up
to approximately 9.62 kHz (125 kHz/13 = 9.615 kHz ). If the sampling accuracy is taken into account, the sampling
frequency  needs  to  be  maintained  more  than  ten  times  the  frequency  of  the  measured  signal.  Because  the
fundamental frequency of power signals is 60 Hz, and when multiplied by 25, the frequency of the harmonic wave
is only 1.5 kHz. Thus the Arduino ADC module can sufficiently meet the requirement of this study.
The estimation accuracy of the following zero-crossing algorithm can be maintained by tuning the Arduino
ADC  sampling  frequency  at  3  kHz.  This  can  be  achieved  by  inserting  a  time-delay  instruction  code  to
modulate the sampling rate according to the specifications. If the sampling rate is set to 3 kHz, the time slot
between  two  adjacent  samples  will  be  333  μm.  Since  the  signal  from  the  voltage  and  current  sensors  is
received  sequentially  for  each  ADC  loop,  it  will  spend  104  μm  between  the  adjacent  voltage  and  current
382 JOURNAL OF ELECTRONIC SCIENCE AND TECHNOLOGY, VOL. 18, NO. 4, DECEMBER 2020

acquired data with the ADC sampling rate of 9.6 kHz. In our experiment, the voltage and current signals are
assumed  to  be  acquired  at  the  same  time  that  the  prescaler’s  setting  is  switched  to  16  to  make  the  ADC
sampling rate equal to 76.8 kHz. This means that the ADC time delay reduces to 15 μs, whereas the voltage
and  current  phase  error  of  the  power  signal  is  reduced  from  (60 Hz/9.6 kHz) × 360 = 2.25   degrees  to
(60 Hz/76.8 kHz) × 360 = 0.28 degrees.
The sampling frequency was evaluated by using a standard sinusoidal wave of frequency 1 kHz in the Arduino
ADC  module,  and  the  delay  times  in  the  ADC  loop  were  set  to  150  μs,  200  μs,  250  μs,  300  μs,  and  350  μs,
respectively.  The  corresponding  sampling  points  per  period  obtained  with  the  zero-crossing  algorithm  were
5.085  points,  4.013  points,  3.315  points,  2.823  points,  

450
and  2.459  points,  respectively.  Since  a  frequency  of
1  kHz  was  used  in  the  Arduino  ADC  module,  the 400

sampling  frequencies  were  5.085 kHz,  4.013 kHz,


   

Sampling period Y
Y=c+aX
350
3.315  kHz,  2.823  kHz,  and  2.459  kHz,  respectively.
Using  the  linear  regression  theorem[17],  the  relationship 300

between the programmed delay time (X) and sampling
250
period (Y) was obtained as follows:
200
Y = c + aX (4)
where c = 39.12601 and a = 1.050209. 150
150 200 250 300 350
In  this  work,  the  sampling  frequency  was  set  to Delay time X

3  kHz  according  to  the  relationship  between  the  delay Fig.  5.  Relationship  between  the  delay  time  (X)  and
time (X) and sampling period (Y) in Fig. 5. The Arduino sampling period (Y) in the Arduino ADC module.
ADC delay time should be set to 280 μs.

2.5. RMS Current Calculation


RMS[12]  is  a  mathematical  method  used  to  define  the  effective  direct  current  (DC)  value  of  a  time-varying
sinusoidal  waveform  (AC  power),  which  produces  the  same  heating  effect  as  the  equivalent  DC  power.  For  a
sinusoidal waveform, which has m equal portions per cycle, its RMS value can be calculated as follows:
m √

Vrms = ∑ Vi 2 /m (5)
i=1

m √

Irms = ∑ Ii 2 /m (6)
i=1

where Vi  is the amplitude of the voltage at point i, Ii is  

200
the  amplitude  of  the  current  at  point  i,  and  m  is  the
100
Voltage (V)

sampled points per cycle.
In  our  experiments,  the  4-cycle  voltage  signal 0
0 50 100 150 200 250
(200  points)  with  50  equal  portions  per  cycle,  which  is −100
acquired by the  Arduino ADC, is shown in Fig. 6, and −200
the variation of RMS values (Vrms,slide (i)) of this signal is
Point number i

also shown in Fig. 6. In addition, RMS can be utilized to Fig.  6.  Voltage  signal  and  its  RMS  value  obtained  using
measure  the  PQ  disturbances  related  to  the  voltage the window-sliding method.
magnitude  variations,  such  as  the  voltage  drop,  voltage  sag,  voltage  swell,  under-voltage,  over-voltage,  and
interruption.
CHEN et al.: Smart Meter Development for Cloud-Based Home Electricity Monitor System 383

The  variation  of  this  signal’s  RMS  values  is Table 2: RMS values of voltage and current


calculated  using  the  window-sliding  method.  In  this Hair dryer state Vrms (V) Irms (A)
method,  each  RMS  value  is  calculated  from  the Off 120.79 0
On 116.35 6.98
values  in  the  window,  and  the  window  frame  is
sequentially slide by 1 point until the number of points
 

200

(50  points)  is  less  than  the  sampling  points  per  cycle. 150

The  window-sliding  RMS  method  for  the  voltage  and 100

current variations can be expressed as follows:

Voltage (V)
50

n−m+1 i+m−1 √ 0
Vrms,slide (i) = ∑ ∑ Vj /m

101
111
121
131
141
151
161
171
11
21
31
41
51
61
71
81
91
1
2
(7) −50
i=1 j=i
−100

n−m+1 i+m−1

Irms,slide (i) = ∑ ∑ Ij 2 /m
−150
(8)
i=1 j=i −200
Number of points
where  i = 1, 2, ⋯, n − m + 1; j = i, i + 1, ⋯, i + m − 1; Voltage without hair dryer Voltage with hair dryer
Vrms without hair dryer Vrms with hair dryer
n = 200 is the number of total points of the acquired
signal,  and  m = 50   is  the  total  number  of  sampled Fig.  7.  Voltage  waveform  and  variation  of  its  RMS  value
points per cycle. when the hair dryer is turned on and off.
Assuming  a  hair  dryer  with  the  specified  power
 

15
consumption of 8 W as a load, the voltage and current
RMS  values  when  the  hair  dryer  is  turned  on  and  off 10
are listed in Table 2.
By implementing the formula in (2), (3), (7), and (8), 5
Current (A)

the  voltage  and  current  signals  and  the  variations  of


their  RMS  values  are  shown  in  Figs.  7  and  8, 0
1
12
23
34
45
56
67
78
89
100
111
122
133
144
155
166
177
188
199
respectively.  The  experimental  results  show  a  current
−5
value close to zero as the hair dryer is turned off. The
Irms  value  increases  to  6.98  A,  when  the  hair  dryer  is
−10
turned on. However, the voltage signal exhibits a small
deviation when the hair dryer is turned on.
−15
Number of points
2.6. Fourier Series Algorithm Current without hair dryer Current with hair dryer
Irms without hair dryer Irms with hair dryer
The  voltage  and  current  signals  include  noise.  The
harmonic  signal  involved  will  distort  them  from  a  pure Fig.  8.  Current  waveform  and  variation  of  its  RMS  value
sinusoidal  wave.  As  a  result,  the  accuracy  of  the when the hair dryer is turned on and off.
fundamental frequency and phase angle determination might be affected.
The  acquired  power  signal  generally  can  be  presented  by  a  discrete  Fourier  series  (DFS)[5],[16],
expressed as follows:
i+m−1 i+m−1

V (i) ≅ m [ ∑ vn cos ( m n) − j ∑ vn sin ( m n)] = A(i) + jB(i) .


2 ωa Ta ωa Ta
(9)
n=i n=i

And A(i) and B(i) can be expressed as follows:
i+m−1

A(i) = m ∑ vn cos (ψn)


2
n=i
384 JOURNAL OF ELECTRONIC SCIENCE AND TECHNOLOGY, VOL. 18, NO. 4, DECEMBER 2020

i+m−1

B(i) = m ∑ vn sin (ψn)


2
n=i

where  vi is the  ith  sample  value  of  the  signal,  m  is  the  number  of  samples  obtained  by  a  fundamental
frequency  period,  and  ψ = (ωa Ta )/m = 2π/m   with  ωa   being  the  angular  frequency  of  the  fundamental
frequency and Ta being the sampling period.
Practically, the cosine and sine signals in (7) can be represented as a vector with the length of m:

COS = m [cos (ψ) , cos (2ψ) , ⋯, cos ((m − 1) ψ) , 1]


2 T
(10)

SIN = m [sin (ψ) , sin (2ψ) , ⋯, sin ((m − 1) ψ) , 0] .


2 T
(11)

The vector of signal samples is expressed as follows:

SAMs = [v1 , v2 , v3 , v4 , v5 , ⋯, vn ] .
T
(12)

Using an auxiliary vector of  COS and  SIN, (11) can be calculated using only multiplication and addition without


any trigonometric calculation. Thus, the calculations become very simple. After each sampling, the sampling points
should be re-arranged as follows:
v1 = v2 , v2 = v3 , ⋯, vn = vnew . (13)
Therefore, by moving the data window, the signal sample values are considered as scalar signal processing.
For  each  data  set  in  the  data  window,  the  corresponding  cos (A(t))  and  sin (B(t))  components  in  (7)  can  be
calculated. The voltage and current signals with and without applying the Fourier series filter are shown in Fig. 9. It
can be observed that the loading effect of the device tends to induce more noise to the power signal. The Fourier
series algorithm is capable of filtering out the noise and harmonics and produces a smooth fundamental frequency
signal for the frequency and phase angle determination.
 

200 15
10
2.7. Zero-Cross Algorithm 100

Current (A)
5
Voltage (V)

The  voltage  frequency  indicates  whether  a  power 0 0


11
22
33
44
55
66
77
88
99
110
121
132
143
154
165
0

line  reaches  an  equilibrium  state  between  the  supply −5


−100
and  demand.  Therefore,  the  frequency  is  a  very −10

important  indicator  of  the  reliability,  safety,  and −200 Number of points −15

economy  of  the  power  line  system.  In  this  paper,  the Voltage (before filter) Voltage (filtered)
zero-cross  algorithm[17]  is  applied  to  evaluate  the Current (before filter) Current (filtered)

voltage  frequency  provided  by  Taipower.  It  also Fig. 9. Power signal when a hair dryer is used as the load


provides information, which allows users to ensure PQ. and the Fourier series algorithm filters out the noise.
The  real  frequency  can  be  determined  by  calculating
the  number  of  points  (m)  in  a  cycle  shown  in  Fig.  10.
 

200

This  number  is  divided  by  the  constant  sampling  time 150 i point
100 i+m point
slot (Ts) of the Arduino ADC, and then the frequency is
Voltage (V)

50 i section i+m section


calculated  by  reversing  the  cycle  time  T = mTs ,  as 0
1 5 9 13 17 21 25 29 33 37 41 45 49 53 57
follows: −50 i−1 section
1 −100 i−1 point
i+m−1section
f= . (14) i+m−1 point
mTs −150
−200 Point number i
However,  since  the  waveform  is  divided  by  the
constant  sampling  rate,  there  are  two  small  segments Fig. 10. Graph showing the number of points in a cycle.
CHEN et al.: Smart Meter Development for Cloud-Based Home Electricity Monitor System 385

between the zero points of a cycle that cannot be counted and are included in the points measured. As shown in
Fig. 11, the segment  δ 2  is in the right portion of the point i−1 to point i and  δ 3  in the left portion of the point i+m to
point  i+m+1,  which  is  not  an  integer  point.  For  the  accurate  measurement,  the  cycle  time  of  this  sampled  signal
must be expressed as follows:

T = mTs + δ 2 + δ 3 = (
δ2 + δ3
+ m) Ts = mA Ts (15)
Ts
where T is the period of the sampled signal,  mA is the accurate number of sampling points between the zero
points of one cycle, and Ts  is the sampling time slot of the Arduino ADC.
 

Trigonometric yi+m+1
yi+1 yi+k−1
yi+k
……

yi
Voltage (V)

θi−1 θi+k−1
0 Ti+(T/2) θi+m Ti+1 θi+m+1
Ti θi θi+1 θi+k θi+m−1

δ2 δ4
yi+m−1 yi+m
Δθ
yi−1
δ1 δ3

Point number i

Fig. 11. Schematic diagram for the zero-cross algorithm.

Using a similar triangle principle, mA can be expressed as
∣yi ∣ ∣yi+m−1 ∣
∣yi ∣ + ∣yi−1 ∣ ∣yi+m−1 ∣ + ∣yi+m ∣
mA = m + + (16)

where  yi−1,  yi ,  yi+m−1,  and  yi+m  are  the  magnitudes  of  the  (i − 1)th,  i th,  (i + m − 1)th,  and  (i + m)th   points,
respectively. The accurate frequency of the signal can be estimated as
1
f= . (17)
mA Ts

2.8. PF Calculation
The  PF  algorithm  calculates  the  amplitude  of  the  phase  difference  between  two  waveforms[18].  In  electrical
engineering, PF of an AC electrical power system is defined as the ratio of the real power absorbed by the load to
the  apparent  power  flowing  in  the  circuit,  and  it  is  a  dimensionless  number  in  the  closed  interval  of  [−1,  1].  This
study aims at notifying users of the existence of a low-PF problem as well as understanding the performance of
electrical appliances, so as to consider whether it is necessary to replace or maintain the equipment. When PF is
too low, the current required to generate the same output power increases. As the current increases, the energy
loss in the circuitry increases, and the damage or the probability of the wires and associated electrical equipment
getting burned increases.
386 JOURNAL OF ELECTRONIC SCIENCE AND TECHNOLOGY, VOL. 18, NO. 4, DECEMBER 2020

In  this  work,  if  the  phase  between  the  voltage  and  

current  waveforms  is  calculated  from  a  sample  point,


which is located in the valley of the waveforms, at least Φ Φ
one  point-count  error  between  the  two  waveforms

1
8
15
22
29
36
43
50
57
64
71
78
85
92
99
106
113
120
127
134
141
148
exists.  This  is  because  the  sample  point  is  not  exactly
located  in  the  valley  of  both  the  voltage  and  current
waveforms, as shown in Fig. 12.
Since  the  number  of  sampling  points  per  cycle  is Fig. 12. Schematic for phase determining.
close  to  50,  one  point  error  of  the  points  counted  

between  two  valleys  will  result  in  a  phase  error  of


approximately 7.2 (360/50) degrees. The accuracy can
be  improved  by  applying  the  zero-cross  algorithm  to
cos (15°) = 0.96
determine  the  location  of  the  first  zero  point  of  the Error = 1%
voltage and current and calculate PF as follows:

PF = cos (Φ) = cos (


NV − NI Fig. 13. 15-degree phase difference test.
mA 360) (18)
 

where  Φ  is the phase in degrees;  NV  and  NI  are the


numbers  of  points  at  the  zero  point  for  the  voltage
and current, respectively.
If  the  phase  difference  exceeds  90  degrees,  the cos (30°) = 0.86
voltage and current directions are at 90 degrees apart, Error = 2%

and  only  the  phase  difference  is  deducted  by


180  degrees,  so  that  the  two  waveform  directions  can Fig. 14. 30-degree phase difference test.
be corrected.  

In  this  work,  a  LabVIEW  program  and  a  data


acquisition  (DAQ)  device[19]  (National  Instruments  (NI
myDAQ))  are  adopted  to  generate  two  signals  with  a
phase  difference  of  15  degrees,  45  degrees,  and cos (45°) = 0.70
60  degrees,  respectively.  LabVIEW  is  multi-pin  output, Error = 2.8%
which produces a waveform angle, set by the user. The
accuracy  is  quite  high  and  can  be  used  in  the
experiment.  In  this  experiment,  two  waveforms  are Fig. 15. 45-degree phase difference test.
produced,  one  of  which  is  set  to  0,  so  that  the  phase  difference  is  known  when  designing  the  angle  of  another
waveform.  The  experimental  results  are  shown  in  Figs.  13,  14,  and  15,  respectively.  The  error  range  is
approximately 1% to 3%. The PF accuracy of more than 5% is less reliable. The PF accuracy of less than 3%
is an acceptable normal error, which proves that the system’s PF calculation is accurate and acceptable.

2.9. TCP Server Setup


The  fast  network  transmission  is  required  to  transfer  the  timely  power  signal  and  calculate  the  data  per
second. NodeMCU is used as TCP to transfer data to the server. NodeMCU includes the officially recognized
WiFi  transmission  module  of  the  Arduino.  It  is  several  times  faster  than  the  Arduino’s  external  WiFi
component  and  suitable  for  transferring  large  amounts  of  data.  NodeMCU  has  only  one  ADC  interface  and
cannot  measure  the  voltage  and  current  values  simultaneously.  Thus,  the  Arduino’s  UART  transmission
method[8] is used to transfer the voltage and current data to NodeMCU. A diagram of the data transmission process
is shown in Fig. 16.
CHEN et al.: Smart Meter Development for Cloud-Based Home Electricity Monitor System 387
 

The  GO  language  server  is  set  up  to  process  the Transmit signals by UART
Arduino NodeMCU
data transmitted by NodeMCU and stores the data in a

Transmit data by WiFi


JSON  file  format  for  the  PHP  server.  In  the  UART
transmission, if the data transmitted are received as an
integer  type,  the  digital  ASCII  code  and  the  blank
character ASCII will be displayed. If a character type is
received,  the  character  of  the  digital  value  can  be
JSON data transmission
directly obtained. PHP server & GO language
MySQL database server
In this experiment, the NodeMCU WiFi transmission
data method used the high-bit and low-bit transmission Fig. 16. TCP server data transmission process.
to  reduce  the  burden  of  WiFi  transmission.  For  

Start
example,  the  number  713  is  represented  by  binary
digits  as  0010  1100  1001.  The  high-bit  part  is  0010 Data
and the low-bit part is 1100 1001. The low-bit part is Convert data to binary
extracted  using  the  AND  logical  operator  by
comparing  0xFF  values.  Finally,  the  data  are  stored High-bit (8 bits) Low-bit (8 bits)
in  an  array  and  then  transmitted  to  the  GO  server.
Low-bit=(Low-bit AND 0xFF)
Using  this  method,  the  size  of  the  713  integer
type—4  bytes  can  be  reduced  to  2  bytes.  This
Store high-bit and
increases  the  WiFi  transmission  speed  and  reduces low-bit into array
the  burden.  According  to  the  example,  the  high-bit
Receive data array by GO server
decimal value is 2, whereas the low-bit decimal value and store data as JSON format
is  201.  The  high-bit  and  low-bit  parts  are  stored  in
Using this formula to obtain original value
the  server.  The  original  value  in  the  client  side  can by computing (256×the high-bit+the low-bit)
be  obtained  by  calculating  (256 × the high-bit +
the low-bit ).  Based  on  this  example,  the  result  is  713. End

The transmission data process is shown in Fig. 17. By Fig.  17.  Flowchart  of  the  NodeMCU  transmission  data


implementing this method, the WiFi transmission speed method.
can reach more than one thousand data per second. Table 3: Taipower electricity charging policy

Range Summer price per Non-summer price per


2.10. Server Construction (degrees) degree (NT$) degree (NT$)
The GO language is a new programming language <120 1.63 1.63
121 to 330 2.38 2.10
appeared in recent years. This language combines the
331 to 500 3.52 2.89
advantages  of  many  other  programming  languages, 501 to 700 4.80 3.94
such as PHP, JavaScript, and Java. The thread can be 701 to 1000 5.66 4.60
>1001 6.41 5.03
executed  in  GO  with  only  one  line  of  codes.  The  GO
language is set up in the server to receive data from NodeMCU. These data are stored in the JSON format for the
PHP web page to obtain and calculate them.

2.11. Electricity Amount Enquiry


This experiment is used to provide consumers with details about the amount of money they spent every month
on the electricity provided by the Taipower policy. In this way, they can control and save their money in advance.
The web page calculates and displays the amount according to the Taipower charging policy, which is different in
summer and non-summer, and the amount of each degree required for each degree range, as presented in Table 3.
388 JOURNAL OF ELECTRONIC SCIENCE AND TECHNOLOGY, VOL. 18, NO. 4, DECEMBER 2020

3. Results and Discussion  

A hardware device (shown in Fig. 18) and software
were  built  and  implemented  to  monitor  home
appliances.
The  measurement  results  obtained  from  the
proposed  monitoring  device  are  displayed  through  a
web page. This page contains information, such as the
real frequency, RMS voltage, RMS current, PF, degree
per  second,  degree  per  hour,  alarm  (an  early  warning
system based on PF), and charts (RMS voltage, RMS
current,  phase  difference,  and  PF).  The  web  page
display is shown in Fig. 19. Fig. 18. Hardware of the monitoring device.
 

Fig. 19. Measurement and calculation displayed on a web page for a hair dryer.

This  system  also  displays  information  about  the  

electricity  usage  degree  and  charges  based  on  the


Taipower charging policy, as shown in Fig. 20.
Finally,  the  system  was  compared  with  a  power
measurement  standard  device  (HIOKI  PW3360)  to
estimate the measurement error. In this case, both the
proposed  system  and  HIOKI  measured  the  hair  dryer
performance. The results are presented in Table 4.
From  Table  4,  it  can  be  observed  that  the  error
percentages  of  the  RMS  voltage,  RMS  current,  real
frequency, and PF are small. Fig. 20. Display of the amount of degrees.

Table 4: Comparison between HIOKI and the proposed system

Vrms (V) Irms (A) Real frequency (kHz) PF


HIOKI 116.88 7.06 60.06 0.99
Proposed system 116.35 6.86 60.16 0.99
Error (%) 0.45 2.83 0.16 0

4. Conclusion
In this paper, a household electricity-measurement system based on IoT was developed to monitor the voltage,
CHEN et al.: Smart Meter Development for Cloud-Based Home Electricity Monitor System 389

current,  and  PQ  factor.  The  limitation  of  the  Arduino  related  to  data  transfer  was  handled  by  NodeMCU  (TCP
communications  technology).  An  approach  in  the  NodeMCU  coding  was  used  to  decrease  data  loading  by
implementing binary conversion and then dividing the data into high-bit and low-bit parts. Furthermore, the filtering
model was adopted to filter the noise and achieve the filtering effect. After filtering, the real frequency calculation
was  performed,  and  the  zero-cross  algorithm  was  applied  to  calculate  the  total  period  of  one  cycle,  which  was
divided by the sampling frequency to obtain the real frequency value. PF used three variables to find the trough in
one  cycle,  applied  the  formula  to  calculate  the  phase,  and  then  determined  the  phase  difference.  PF  was
calculated using the cos  (Φ) formula. Finally, by comparing the proposed system and HIOKI, an IoT system at a
low cost, which has the same function as the HIOKI measurement device, can be established.

Acknowledgment
The authors gratefully acknowledge the helpful comments and suggestions of the reviewers for improving the presentation.

Disclosures
The authors declare no conflicts of interest.

References
[1] United News Network. (January 2018). [Online]. Available: https://unitednewsnetwork.com.
[2] A.  Čolaković  and  M.  Hadžialić,  “Internet  of  things  (IoT):  A  review  of  enabling  technologies,  challenges,  and  open
research issues,” Computer Networks, vol. 144, pp. 17-39, Oct. 2018.
[3] L.  Morales-Velazquez,  R.  de  J.  Romero-Troncoso,  G.  Herrera-Ruiz,  D.  Morinigo-Sotelo,  and  R.  A.  Osornio-Rios,
“Smart sensor network for power quality monitoring in electrical installations,” Measurement, vol. 103, pp. 133-142,
Jun. 2017.
[4] Y.-C. Chen, H.-Y. Shen, H.-Y. Chen, and C.-H. Hsu, “Low cost Arduino DAQ development and implementation on an
Android app for power frequency measurement,” in Proc. of Intl. Symposium on Computer, Consumer and Control,
Xi’an, 2016, pp. 99-102.
[5] Y.-C.  Chen  and  J.-K.  Lan,  “Implementation  of  power  measurement  system  with  Fourier  series  and  zero-crossing
algorithm,” in Proc. of Intl. Symposium on Computer, Consumer and Control, Taichung, 2014, pp. 601-604.
[6] I. Abubakar, S. N. Khalid, M. W. Mustafa, H. Shareef, and M. Mustapha, “Calibration of ZMPT101B voltage sensor
module  using  polynomial  regression  for  accurate  load  monitoring,”  ARPN Journal of Engineering and Applied
Sciences, vol. 12, no. 4, pp. 1076-1084, Feb. 2017.
[7] L.  Li,  Y.-Z.  Chen,  H.-P.  Zhou,  H.-X.  Ma,  and  J.-P.  Liu,  “The  application  of  hall  sensors  ACS712  in  the  protection
circuit  of  controller  for  humanoid  robots,”  in  Proc. of Intl. Conf. on Computer Application and System Modeling,
Taiyuan, 2010, pp. V12:101-103.
[8] M. Margolis, Arduino Cookbook, Farnham: O’Reilly Media, 2011, pp. 133-135.
[9] M. Kashyap, V. Sharma, and N. Gupta, “Taking MQTT and NodeMCU to IoT: Communication in Internet of things,”
Procedia Computer Science, vol. 132, pp. 1611-1618, 2018, DOI: 10.1016/j.procs.2018.05.126.
[10] Y. Qin, W.-H. Yang, Y.-B. Ye, and Y. Shi, “Analysis for TCP in data center networks: Outcast and Incast,” Journal of
Network and Computer Applications, vol. 68, pp. 140-150, Jun. 2016.
[11] Golang. (December 2017). The GO programming language. [Online]. Available: http://www.golang.org.
390 JOURNAL OF ELECTRONIC SCIENCE AND TECHNOLOGY, VOL. 18, NO. 4, DECEMBER 2020

[12] S. H. Cho, C. H. Park, J. Han, and G. Jang, “A waveform distortion evaluation method based on a simple half-cycle
RMS calculation,” IEEE Trans. on Power Delivery, vol. 27, no. 3, pp. 1461-1467, Jul. 2012.
[13] Hioki. (January 2018). Clamp on power logger PW3360. [Online]. Available: https://www.hioki.com/en/products/detail/
?product_key=5589.
[14] Datasheetspdf. (December 2017). ZMPT101B datasheet. [Online]. Available: https://datasheetspdf.com/pdf/1031464/
ETC/ZMPT101B/1.
[15] Google.  (January  2018).  Arduino:  The  Arduino  DAQ  chronicles.  [Online].  Available:  https://sites.google.com/
site/measuringstuff/the-arduino.
[16] Yet  Arduino  Blog.  (November  2017).  [Online].  Available:  http://yaab-arduino.blogspot.com/2015/02/fast-sampling-
from-analog-input.html.
[17] H.-Y.  Shen,  Y.-C.  Chen,  and  C.-H.  Hsu,  “A  power  frequency  sensing  device  using  an  Arduino  device  and  zero-
crossing  algorithm  and  its  implementation  on  Android  app,”  Sensors and Materials,  vol.  29,  no.  6,  pp.  741-756,
Jun. 2017.
[18] L.  Sarıbulut,  “A  simple  power  factor  calculation  for  electrical  power  systems,”  Intl. Journal of Electrical Power &
Energy Systems, vol. 62, pp. 66-71, Nov. 2014.
[19] National Instruments. (October 2017). [Online]. Available: http://www.ni.com/examples/.

Yeong-Chin Chen  received  the  M.S.  and  Ph.D.  degrees  in  electrical  engineering  from  National
Cheng Kung University, Tainan City in 1989 and 1998, respectively. He worked with the Underwater
Technology Department, National Chung Shan Institute of Science and Technology, Taoyuan from
1989  to  2000,  as  a  senior  researcher.  He  is  currently  a  professor  in  computer  science  and
information  engineering  with  Asia  University,  Taichung.  His  research  interests  include  acoustical
transducer  engineering,  power  signal  measurement  &  analysis,  automatic  measurement,  and
software engineering. In recent years, his research has also been focused on smart power meters
implemented  on  the  Internet  of  things  (IoT)  platforms  for  big-data  power  saving  management
                                  applications.

Sunneng Sandino Berutu  was  born  in  Salak  in  1977.  He  received  the  B.S.  degree  in  computer
science  from  University  of  Christian  Immanuel,  Yogyakarta  in  2000  and  the  M.S.  degree  in
information system from University of Diponegoro, Semarang in 2013. He is currently pursuing the
Ph.D.  degree  with  the  Department  of  Computer  Science  and  Information  Engineering,  Asia
University. His research interests mainly focus on IoT and power quality.

Yue-Hsien Wang  was  born  in  Taichung  in  1996.  He  obtained  his  B.S.  degree  in  engineering  of
information science from Asia University in 2018. He worked as a software engineer and developed
an  IoT  website  for  handling  electricity  data.  Now,  he  is  pursuing  his  M.S.  degree  with  the
Department  Computer  Science  and  Engineering,  National  Chung  Hsing  University,  Taichung.  His
research interest focuses on loT smart meters.

You might also like