SlideShare a Scribd company logo
5
Most read
8
Most read
9
Most read
Internet of Things (COS7039-B)
IoT Based Smart Energy
Meter
Author: Bilal Amjad
UoB # 19014392
Programme: Smart Grids and Energy Systems
Faculty: Faculty of Engineering and Informatics
Date submitted: 13th
December 2019
Table of Contents
Abstract........................................................................................................................................... 4
1 Introduction............................................................................................................................. 5
1.1 Smart energy meter .......................................................................................................... 5
1.2 Internet of Things............................................................................................................. 5
1.3 The smart grid .................................................................................................................. 5
1.4 Problem statement............................................................................................................ 6
2 Literature review..................................................................................................................... 7
3 Design and methodology ........................................................................................................ 8
3.1 Components and hardware............................................................................................... 8
3.2 Hardware Implementation................................................................................................ 8
3.3 Measurement of electrical parameters: ............................................................................ 9
3.3.1 Tariff measurements: .............................................................................................. 10
3.4 Online platform:............................................................................................................. 10
3.5 Text massage alerts and updates: ................................................................................... 10
4 Results and discussion .......................................................................................................... 11
4.1 Dashboard of energy monitoring system ....................................................................... 11
4.1.1 Mobile Application................................................................................................. 12
5 Conclusion ............................................................................................................................ 13
6 Future work........................................................................................................................... 13
7 References............................................................................................................................. 14
Appendices.................................................................................................................................... 15
Appendix A............................................................................................................................... 15
Appendix B............................................................................................................................... 18
List of Figures
Figure 1: IoT technology [3]........................................................................................................... 5
Figure 2:PZEM-004T Version 3.0 [11] .......................................................................................... 8
Figure 3: PZEM-004T diagram [11]............................................................................................... 8
Figure 4: Arduino connection with PZEM-004T [11].................................................................... 9
Figure 5:Circuit diagram of smart energy meter............................................................................. 9
Figure 6(a & b): The dashboard of energy monitoring system..................................................... 11
Figure 7: Energy consumption profile on mobile application ..................................................... 12
List of Tables
Table 1: Units of electrical parameters for PZEM-00T................................................................ 10
Abstract
Internet of Things (IoT) is widely used in industries and businesses like, smart cites, smart grids,
automotive industries, logistics and healthcare. In Electric Power and Energy Systems (EPESs),
smart grids techniques are being implementing to meet the energy demands, improve the energy
efficiency, and reduce energy loses by implementing latest sensing and communication
technologies. In several developed countries, automatic meter reading (AMR), advanced metering
infrastructure (AMI) or smart energy meter with instantaneous energy information report have
been applied at the domestic level. This project, design and implement a low-cost IoT energy
monitoring system (smart energy meter) for real time monitoring of all electrical parameters i.e.
AC voltage, AC current, active power, total energy consumption, power factor, frequency, and
tariff. The design is based on a low-cost PZEM-004T, using non-invasive Current Transformer
(CT) sensors, Arduino and Raspberry pi. Electrical measurements are done by PZEM-004T and
CT sensors through Arduino. Raspberry pi communicates with Arduino through serial
communication to retrieve these sensor’s data and send it to server via internet. As a result, the
developed energy monitoring system can successfully record the voltage, current, active power,
power factor, frequency, accumulative power consumption and tariff. Consumers will be able to
see their electricity usage and the tariff according to the energy usage in real-time through web
and mobile application. In case of any fault e.g. short circuit or power supply cut off, the consumer
will receive a text massage on his mobile number. Moreover, consumer will be able to receive the
tariff on weekly or monthly basis.
1 Introduction
1.1 Smart energy meter
The smart energy meter is a wireless energy monitoring system containing an energy meter with a
communication network topology to efficiently send data from the meters to a server or
coordinator and a cloud platform to visualize the data in actual [1].
1.2 Internet of Things
Internet of Thigs (IoT) is a new architype in communications technology now a days. IoT
concept that is "anything, anywhere, anytime" inspires the development of communication
technology. IoT framework has three elementary concepts, things oriented, internet oriented,
and semantic oriented [2].
Figure 1: IoT technology [3]
1.3 The smart grid
The smart grid term is very widely used in EPES. Smart grid encompasses the entire energy
conversion, transmission, distribution, and utilization cycle. It consists of advance actuators,
sensors, communication infrastructure, IT systems, advanced monitoring, control and decision-
making applications. There are multiple objectives to develop and deploy Smart Grid technologies.
The key objectives are [4]:
• To improve efficiency and economy in electrical conversion, transmission, distribution,
storage and utilization
• To enhance security and safety in system operation by increasing the observability and
controllability of the power grid
• To improve the reliability and availability of the electric supply to customers
• To enable and promote the integration and utilization of renewable and sustainable energies
• To maintain and improve the quality of power delivery to increase the shares of digital
loads
1.4 Problem statement
As IoT is implementing in every business and industry, Electric Power and Energy System (EPES)
is also digitalising by integrating latest IoT, communication, computing and control technologies
to make it smart. In EPES, measuring the energy consumption at consumer level is very important
and useful. Electric companies always try to keep balance between electric supply, and it demand.
By knowing the demand of electricity, the electric companies can forecast the load demand and
can take decisions for future. Here comes the term, smart energy meter. Smart energy meter can
help to simultaneous communicate between the consumer and the grid, rise the capacity of the
electricity system of integrated services, meet the demand of energy and increase quality of service
by promptly detecting the fault when it occurs. Each consumer can always monitor the status of
their homes and avoid theft [5].
2 Literature review
Several studies have proposed the design of smart energy meter. In [6] [7], their strategy were
based on GSM network and employed database management to deliver energy usages data for
their customs. In [12], ZigBees mutual with GSM based was anticipated, in such system the energy
metering nodes use the ZigBees, interconnect with the central node and send information to central
computer via GSM. K Chooruang and K Meekul developed an IoT low-cost energy monitoring
system that use Wi-Fi, and MQTT (Message Queuing Telemetry Transport) protocol. The system
contains the Peacefair PZEM -004T sensor, a CT (current transformer) sensor and Raspberry pi 3
model B. It can send comprehensive measurement of energy usage and the patterns of energy
consumption [8].
B. K. Barman et al proposed smart energy meter controls and computes the energy consumption using
ESP 8266 12E, a Wi-Fi module and uploads it to the cloud from where the customer or supplier can
view the electric energy consumption. Consequently, energy analyzation by the consumer turn out to
be much easier and governable. This system also helps in sensing power theft [9].
3 Design and methodology
The project is divided in two parts, measuring electrical parameters and sending data to online
platform. First, electrical parameters of the systems will be measured and then theses parameters
will be sent over the server.
3.1 Components and hardware
The main components are:
• PZEM-004T and CT
• Arduino
• Raspberry pi 3 Model B
• Connecting wires
• Thinkspeak (online platform IoT)
• Nexmo (for sending text massages)
3.2 Hardware Implementation
The PZEM-004T measures RMS voltage, RMS current and calculates active power and total
energy usage over time or accumulative power consumption. It has very good measurement
accuracy. Figure 2 and 3 show the PZEM-004T module and circuit diagram, respectively. and
datasheet is available here [10].
Figure 2:PZEM-004T Version 3.0 [11]
Figure 3: PZEM-004T diagram [11]
The figure 4 show the connection configuration of PZEM-004T module with Arduino. GND and
5V points of module relate to GND and 5V pins of Arduino, and TX and RX points of module
relate to 9 and 10 pins of Arduino.
Figure 4: Arduino connection with PZEM-004T [11]
Now the Arduino is coroneted with Raspberry pi through USB cable. Raspberry pi receive data
from Arduino by serial communication and send it to server. Figure 5 shows the complete circuit
diagram of smart energy meter. The code for Arduino and Raspberry pi is attached in appendix B
and C, respectively.
Figure 5:Circuit diagram of smart energy meter
3.3 Measurement of electrical parameters:
PZEM-004T (v3.0) module is responsible for measuring all electrical parameters. The module
does TTL communication to transmitting or receiving data. Still, there is no library of this
module available for Raspberry pi in python language, but its library is available for Arduino.
Arduino use PZEM-004Tv30.h library [10] to communicate with the module through TX and
RX pins and the Arduino code is added in to the appendix A. The table 1 shows the units used
for measurement of all parameters.
Table 1: Units of electrical parameters for PZEM-00T
Sr. No. Parameter Unit
1. Voltage volt (V)
2. Current ampere (A)
3. Power Watt (W)
4. Energy kilo watt hour (kWh)
5. Frequency Hertz (Hz)
6. Power Factor No unit
3.3.1 Tariff measurements:
Currently, in Bradford region the price of electric energy per kilo watt hour is 13.92. So, tariff can
be calculated by multiplying total energy consumption with 13.92.
3.4 Online platform:
ThingSpeak platform is used here for real time monitoring. It is a free online IoT platform, very
easy to understand and interface with Raspberry pi. Every user has its own channel ID and API
key. The Raspberry pi receives the data from Arduino and sent over the server to thingspeak
dashboard every second (for Raspberry pi python code, refer to appendix B).
3.5 Text massage alerts and updates:
Nexmo service is used for sending text massages to the user. Here for this project, user will be able
to receive two types of text massages. One is about tariff updates; the consumer will receive the
update of tariff on weekly or monthly bases. Second type is alerts massage; if the module gets the
voltage value zero, it means there is any fault or power supply cut off. In such case the consumer
will receive the alert massage “Supply Disconnected!!!”.
4 Results and discussion
This section will explain the results from smart energy meter. As the meter is connected at main
electric supply unit, so the dashboard will show the electric consumption of whole building or
home.
4.1 Dashboard of energy monitoring system
Figure 6 (a and b) shows the user-interface console. It is created on Thingspeak. It comprises of
the measures that show the current tariff, total energy consumption, Power Factor, AC voltage,
AC current and power. The charts characterize the measured energy information with respect to
time. The system send data every second throughout the day and data can be shown concurrently
on the console.
(a)
(b)
Figure 6(a & b): The dashboard of energy monitoring system
4.1.1 Mobile Application
In Figure 7, the energy patterns on android mobile application. The thingspeak application is
available in google app store. Afte installing the application user will login by his channel ID to
see the dashboard.
Figure 7: Energy consumption profile on mobile application
5 Conclusion
The presented smart energy meter is wireless meter reading system that can display and
investigate the information at every interval giving precise outcomes with fewer mistake. This
smart system can be useful for energy management, power saving from power section,
automatic control of energy meter, to make consumer monitor their energy usage pattern and
power theft detection. Sometime the system takes time to upload the data depending on the
internet speed and module baud rate. The IoT idea can also be applied in numerous working
situation such as home automation, automatic water level detector and traffic control system
etc.
6 Future work
Number of improvements can be done in future in term of
• Integrating home automation with smart energy meter dashboard to control electric loads
• Process data for short-term load forecasting and real time decision making.
7 References
[1] S. Yasir, C. Noel, H. R. Mubashir and C. Rebecca, “Internet of Things-aided Smart Grid:
Technologies, Architectures, Applications, Prototypes, and Future Research Directions,”
IEEE Access, vol. 7, pp. 62962 - 63003, 2019.
[2] L. Atzori, A. Iera and GiacomoMorabito, “The Internet of Things: A survey,” Comuputer
Networks, vol. 15, no. 54, pp. 2787-2805, 2010.
[3] M. Yun and B. Yuxin, “Research on the Architecture and Key Technology of Internet of
Things (loT) Applied on Smart grid,” International Conference on Advances in Energy
Engineering, pp. 69-72, 2010.
[4] L. T. Berger and K. Iniewski, Smart Grid Applications, Communications and Security, New
Jersey: John Wiley & Sons, Inc, 2012.
[5] A. C. Swastika, R. Pramudita and R. Hakimi, “IoT-based Smart Grid System Design for
Smart Home,” International Conference on Wireless and Telematics, pp. 49-53, 2017.
[6] H. G. R. Tan, C. H. Lee and V. H. Mok, “Automatic power meter reading system using GSM
network,” International Power Engineering Conference, pp. 465-469, 2017.
[7] M. Wasi-ur-Rahman, M. T. Rahman, T. H. Khan and S. M. L. Kabir, “Design of an
intelligent SMS based remote metering system,” International Conference on Information
and Automation, pp. 1040-1043, 2009.
[8] K. Chooruang and K. Meekul, “Design of an IoT Energy Monitoring System,” International
Conference on ICT and Knowledge Engineering, 2018.
[9] B. K. Barman, S. N. Yadav, S. Kumar and S. Gope, “IOT Based Smart Energy Meter for
Efficient Energy Utilization in Smart Grid,” IEEE journal, 2018.
[10] J. Mandula, “Interface library for the upgraded version of PZEM-004T v3.0,” Get Hub, 2019.
[Online]. Available: https://github.com/olehs/PZEM004T. [Accessed 28 11 2019].
[11] [Online]. Available: https://www.innovatorsguru.com/pzem-004t-v3/. [Accessed 09 12
2019].
Appendices
Appendix A
The PZEM-00T library is available on Get Hub [10].
Arduino code:
//* Code to get the voltage, current and power from two AC PZEM
sensors connected to the Arduino Mega microcontroller, then all the
values *//
// are concatenated in one char variable in order to send it through
serial communication
//
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
/
#include <SoftwareSerial.h>
#include <PZEM004Tv30.h>
//#include <PZEM004T.h>
PZEM004Tv30 pzem(11, 12); //Rx,Tx pin of arduino
// IPAddress ip(192,168,1,11);
// IPAddress ip1(192,168,1,10);
char Vx[10];
char Ix[10];
char Px[10];
char Ex[10];
char Fx[10];
char PFx[10];
char conc[360];
float V; //Voltage
float I; //Current
float P; //Power
float E; //Energy
float F; //Frequency
float PF;//Power Factor
void setup() {
Serial.begin (9600);
}
void loop() {
float voltage = pzem.voltage();
if( !isnan(voltage) ){
V=voltage;
//Serial.print("Voltage: "); Serial.print(voltage);
Serial.println("V");
} else {
V=0;
// Serial.println("Error reading voltage");
}
float current = pzem.current();
if( !isnan(current) ){
I=current;
//Serial.print("Current: "); Serial.print(current);
Serial.println("A");
} else {
I=0;
//Serial.println("Error reading current");
}
float power = pzem.power();
if( !isnan(power) ){
P=power;
//Serial.print("Power: "); Serial.print(power);
Serial.println("W");
} else {
P=0;
//Serial.println("Error reading power");
}
float energy = pzem.energy();
if( !isnan(energy) ){
E=energy;
//Serial.print("Energy: "); Serial.print(energy,3);
Serial.println("kWh");
} else {
E=0;
//Serial.println("Error reading energy");
}
float frequency = pzem.frequency();
if( !isnan(frequency) ){
F=frequency;
//Serial.print("Frequency: "); Serial.print(frequency, 1);
Serial.println("Hz");
} else {
F=0;
//Serial.println("Error reading frequency");
}
float pf = pzem.pf();
if( !isnan(pf) ){
PF=pf;
//Serial.print("PF: "); Serial.println(pf);
} else {
PF=0;
//Serial.println("Error reading power factor");
}
//PZEM004T pzem(10,11); //(RX TX)
//pzem.setAddress (ip);
//V=pzem.voltage(ip); //voltage obtained from the pzem library
//i = pzem.current(ip); //current obtained from the pzem library
//p = pzem.power(ip);//power obtained from the pzem library
dtostrf(V,7,3,Vx); //function used to stored the voltage value in the
char variable ix, specifying 3 as the number of digits after the point
dtostrf(I,7,3,Ix); //function used to stored the current value in the
char variable iy, specifying 3 as the number of digits after the point
dtostrf(P,7,3,Px); //function used to stored the power value in the
char variable iz, specifying 3 as the number of digits after the point
dtostrf(E,7,3,Ex); //function used to stored the total energy value
in the char variable ix, specifying 3 as the number of digits after
the point
dtostrf(F,7,3,Fx); //function used to stored the frequency value in
the char variable ix, specifying 3 as the number of digits after the
point
dtostrf(PF,7,2,PFx); //function used to stored the power factor value
in the char variable ix, specifying 1 as the number of digits after
the point
delay(1000);
sprintf(conc,": %s, : %s, : %s, : %s, : %s, : %s,n", Vx, Ix, Px, Ex,
Fx, PFx); // function used to concatenate all the values in one unique
char variable
Serial.write(conc);
}
Appendix B
Raspberry pi python code:
import serial
import time
import re
import thingspeak
import urllib.request
import datetime
import nexmo
start_time = time.time()
chid = 935217
tskey = "TYILB5PXIGBNYSGW"
tsurl =
"https://api.thingspeak.com/update?api_key=TYILB5PXIGBNYSGW&field1=0"
ts = thingspeak.Channel(chid, tsurl, tskey)
print("System is getting ready!!!")
time.sleep(3)
port = "/dev/ttyACM0"
s1 = serial.Serial(port,9600)
def bill_sms():
client = nexmo.Client(key='17e0c2af', secret='eo8eHPkUh4yS9UtR')
client.send_message({'from': 'Nexmo','to': '+447749532518','text':
' Your Electricity Bill is: '+str(Tariff) +"£"})
print("bill sent")
def sms_alert():
client = nexmo.Client(key='17e0c2af', secret='eo8eHPkUh4yS9UtR')
client.send_message({'from': 'Nexmo','to': '+447749532518','text':
' Supply Disconnected!!! '})
def readData():
global Voltage
global Current
global Power
global Energy
global Frequency
global Power_Factor
global Tariff
V = m.group(1).replace(" ","") ## command used to saved the
information splitted before in a the variable
I = m.group(2).replace(" ","")
P = m.group(3).replace(" ","")
E = m.group(4).replace(" ","")
F = m.group(5).replace(" ","")
PF = m.group(6).replace(" ","")
Voltage = float(V)
Current = float(I)
Power = float(P)
Energy = float(E)
Frequency = float(F)
Power_Factor = float(PF)
Tariff = Energy*13.94
print("n","----Smart Energy Meter----n")
print(" Voltage:",+Voltage,"V")
print(" Current:",+Current,"A")
print(" Power:",+Power,"W")
print(" Energy:",+Energy,"kWh")
print(" Frequency:",+Frequency,"Hz")
print(" Power Factor",+Power_Factor)
print(" Tariff:",round(Tariff, 2),"£")
#else:
# print("Waiting")
# time.sleep(3)
def sendDataTs():
data = {"field1": Voltage,
"field2": Current,
"field3": Power,
"field4": Energy,
"field5": Frequency,
"field6": Power_Factor,
"field7": Tariff,
}
Ts = urllib.request.urlopen(tsurl +
'&field1=%s&field2=%s&field3=%s&field4=%s&field5=%s&field6=%s&field7=%
s' % (Voltage,Current,Power,Energy,Frequency,Power_Factor,Tariff ))
#print ("Data sent for 6 fields: ", Voltage, Current, Power,
Energy, Frequency, Power_Factor)
while True:
if s1.inWaiting()>0:
inputValue = s1.readline().decode()
#x = "None"
if inputValue:
m =
re.search('.*:(.*),.*:(.*),.*:(.*),.*:(.*),.*:(.*),.*:(.*),',inputValu
e) # command used to read the information and split it between the
charcaters ':' and ','
if m:
readData()
try:
sendDataTs()
T=(time.time() - start_time)/60 #time in minutes
if T>5:
bill_sms()
time.sleep(10)
if Voltage==0:
print("Supply Discunnected")
sms_alert()
time.sleep(15)
except (KeywordInterrupt):
print("Finishing")

More Related Content

What's hot (20)

PPTX
Smart door project ppt shivnaresh likhar
Shivnaresh Likhar
 
PPTX
STREET LIGHT THAT GLOWS ON DETECTING VEHICLE MOVEMENT
m sivareddy
 
PPTX
Artificial intelligence in power system
Bittu Goswami
 
PDF
IoT for the energy sector
IET India
 
PPTX
Internet of Things (IoT) Based Smart Security & Home Automation System.
sayed78
 
PPTX
ppt on Smart Grid
agr_vandana30
 
PPTX
Smart Grid Components Control Elements & Smart Grid Technology
SurajPrakash115
 
PPT
smart street light ppt
Surya Karan
 
PPTX
Password based door locking system
Arjun Singh
 
PPTX
Smart grid ppt
Ravish Pandey
 
PPTX
Iot based water quality monitoring system
Binayakreddy
 
PPTX
Wireless charging technology ppt
Ankit Gupta
 
PPT
Smart grid
Praneeth Reddy
 
PPTX
Smart street light system
Kuriakose Mathew
 
PPTX
Smart grid
Shivangni Sharma
 
DOCX
smart street light system using IOT
Karthikeyan T
 
PPTX
Smart irrigation system
VISHALDWIVEDI27
 
PPTX
Smart grid
sohan prajapati
 
PPTX
Home automation using IoT
Athira_1993
 
PDF
IRJET- IoT based Smart Energy Meter
IRJET Journal
 
Smart door project ppt shivnaresh likhar
Shivnaresh Likhar
 
STREET LIGHT THAT GLOWS ON DETECTING VEHICLE MOVEMENT
m sivareddy
 
Artificial intelligence in power system
Bittu Goswami
 
IoT for the energy sector
IET India
 
Internet of Things (IoT) Based Smart Security & Home Automation System.
sayed78
 
ppt on Smart Grid
agr_vandana30
 
Smart Grid Components Control Elements & Smart Grid Technology
SurajPrakash115
 
smart street light ppt
Surya Karan
 
Password based door locking system
Arjun Singh
 
Smart grid ppt
Ravish Pandey
 
Iot based water quality monitoring system
Binayakreddy
 
Wireless charging technology ppt
Ankit Gupta
 
Smart grid
Praneeth Reddy
 
Smart street light system
Kuriakose Mathew
 
Smart grid
Shivangni Sharma
 
smart street light system using IOT
Karthikeyan T
 
Smart irrigation system
VISHALDWIVEDI27
 
Smart grid
sohan prajapati
 
Home automation using IoT
Athira_1993
 
IRJET- IoT based Smart Energy Meter
IRJET Journal
 

Similar to IoT Based Smart Energy Meter using Raspberry Pi and Arduino (20)

PDF
IRJET- Review on Design of Residential IoT based Smart Energy Meters
IRJET Journal
 
PDF
IRJET - Wireless Energy Meter with Home Automation
IRJET Journal
 
PPTX
pFBJHGGHJEAGHGHGEHGHEQRJGHEJHHGJKERHGKJERGHpt.pptx
yeshwanth845
 
PDF
IRJET- Iot Based Smart Meter
IRJET Journal
 
PDF
[IJET V2I3P5] Authors: Jamuna H G, Shobha Hugar
IJET - International Journal of Engineering and Techniques
 
PDF
IRJET- Iot Based Smart Energy Monitoring
IRJET Journal
 
PDF
IoT Based Smart Energy Metering with Blynk Application
ijtsrd
 
PPTX
mpGNNKJQERHGUERGHJGHEKJGHJKEJHGJKHGJEH1.pptx
yeshwanth845
 
PDF
IRJET - IoT based Energy Monitoring System for Energy Conservation
IRJET Journal
 
PDF
IRJET - IoT based Smart Monitoring in Distribution System
IRJET Journal
 
PPT
J.N-FEP 26.02.22.ppt
Nagen87
 
PPTX
A PROFICIENT SENSOR NETWORK BASED SMART METER MULTI-DEMAND RESPONSE SYSTEM US...
aravind Guru
 
PDF
IRJET- Energy Meter Reading over Internet
IRJET Journal
 
PDF
An IOT based smart metering development for energy management system
IJECEIAES
 
PDF
New Age Energy Monitoring System
IRJET Journal
 
PDF
IoT based Smart Energy Meter
IRJET Journal
 
PPTX
PPT_IOT LAB.pptx of minum bif aggaa hands on appoajcj
kailashjadhave154
 
PDF
IRJET- IoT based Monitoring and Controlling of Smart Speaking Energy Mete...
IRJET Journal
 
PDF
energy meter reader (1).pdf
DEEPAKAIT20
 
PDF
IRJET - Dynamic Domestic Energy Utility Monitoring and Management using IoT
IRJET Journal
 
IRJET- Review on Design of Residential IoT based Smart Energy Meters
IRJET Journal
 
IRJET - Wireless Energy Meter with Home Automation
IRJET Journal
 
pFBJHGGHJEAGHGHGEHGHEQRJGHEJHHGJKERHGKJERGHpt.pptx
yeshwanth845
 
IRJET- Iot Based Smart Meter
IRJET Journal
 
[IJET V2I3P5] Authors: Jamuna H G, Shobha Hugar
IJET - International Journal of Engineering and Techniques
 
IRJET- Iot Based Smart Energy Monitoring
IRJET Journal
 
IoT Based Smart Energy Metering with Blynk Application
ijtsrd
 
mpGNNKJQERHGUERGHJGHEKJGHJKEJHGJKHGJEH1.pptx
yeshwanth845
 
IRJET - IoT based Energy Monitoring System for Energy Conservation
IRJET Journal
 
IRJET - IoT based Smart Monitoring in Distribution System
IRJET Journal
 
J.N-FEP 26.02.22.ppt
Nagen87
 
A PROFICIENT SENSOR NETWORK BASED SMART METER MULTI-DEMAND RESPONSE SYSTEM US...
aravind Guru
 
IRJET- Energy Meter Reading over Internet
IRJET Journal
 
An IOT based smart metering development for energy management system
IJECEIAES
 
New Age Energy Monitoring System
IRJET Journal
 
IoT based Smart Energy Meter
IRJET Journal
 
PPT_IOT LAB.pptx of minum bif aggaa hands on appoajcj
kailashjadhave154
 
IRJET- IoT based Monitoring and Controlling of Smart Speaking Energy Mete...
IRJET Journal
 
energy meter reader (1).pdf
DEEPAKAIT20
 
IRJET - Dynamic Domestic Energy Utility Monitoring and Management using IoT
IRJET Journal
 
Ad

More from Bilal Amjad (20)

PDF
Power Systems analysis with MATPOWER and Simscape Electrical (MATLAB/Simulink)
Bilal Amjad
 
PDF
Solar Radiation monthly prediction and forecasting using Machine Learning tec...
Bilal Amjad
 
PDF
Big Data in Smart Grid
Bilal Amjad
 
PPTX
Flexibility of Power System (Sources of flexibility & flexibility markets)
Bilal Amjad
 
PDF
Assembly Language Programming By Ytha Yu, Charles Marut Chap 10 ( Arrays and ...
Bilal Amjad
 
PDF
Assembly Language Programming By Ytha Yu, Charles Marut Chap 8 (The Stack and...
Bilal Amjad
 
PDF
Assembly Language Programming By Ytha Yu, Charles Marut Chap 7 (Logic, Shift,...
Bilal Amjad
 
PDF
Assembly Language Programming By Ytha Yu, Charles Marut Chap 6 (Flow Control ...
Bilal Amjad
 
PDF
Assembly Language Programming By Ytha Yu, Charles Marut Chap 5 (The Processor...
Bilal Amjad
 
PPTX
Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...
Bilal Amjad
 
PDF
Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...
Bilal Amjad
 
PDF
Assembly Language Programming By Ytha Yu, Charles Marut Chap 1(Microcomputer ...
Bilal Amjad
 
PPTX
Binary and hex input/output (in 8086 assembuly langyage)
Bilal Amjad
 
PPTX
bubble sorting of an array in 8086 assembly language
Bilal Amjad
 
PPTX
assembly language programming organization of IBM PC chapter 9 part-2(decimal...
Bilal Amjad
 
PPTX
assembly language programming organization of IBM PC chapter 9 part-1(MULTIPL...
Bilal Amjad
 
PPTX
Limit of complex number
Bilal Amjad
 
PPTX
simple combinational lock
Bilal Amjad
 
PPTX
4-bit camparator
Bilal Amjad
 
PPTX
Orthogonal trajectories
Bilal Amjad
 
Power Systems analysis with MATPOWER and Simscape Electrical (MATLAB/Simulink)
Bilal Amjad
 
Solar Radiation monthly prediction and forecasting using Machine Learning tec...
Bilal Amjad
 
Big Data in Smart Grid
Bilal Amjad
 
Flexibility of Power System (Sources of flexibility & flexibility markets)
Bilal Amjad
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 10 ( Arrays and ...
Bilal Amjad
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 8 (The Stack and...
Bilal Amjad
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 7 (Logic, Shift,...
Bilal Amjad
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 6 (Flow Control ...
Bilal Amjad
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 5 (The Processor...
Bilal Amjad
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...
Bilal Amjad
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...
Bilal Amjad
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 1(Microcomputer ...
Bilal Amjad
 
Binary and hex input/output (in 8086 assembuly langyage)
Bilal Amjad
 
bubble sorting of an array in 8086 assembly language
Bilal Amjad
 
assembly language programming organization of IBM PC chapter 9 part-2(decimal...
Bilal Amjad
 
assembly language programming organization of IBM PC chapter 9 part-1(MULTIPL...
Bilal Amjad
 
Limit of complex number
Bilal Amjad
 
simple combinational lock
Bilal Amjad
 
4-bit camparator
Bilal Amjad
 
Orthogonal trajectories
Bilal Amjad
 
Ad

Recently uploaded (20)

PPTX
Structural Functiona theory this important for the theorist
cagumaydanny26
 
PPT
Oxygen Co2 Transport in the Lungs(Exchange og gases)
SUNDERLINSHIBUD
 
PDF
Ethics and Trustworthy AI in Healthcare – Governing Sensitive Data, Profiling...
AlqualsaDIResearchGr
 
PPTX
MobileComputingMANET2023 MobileComputingMANET2023.pptx
masterfake98765
 
PPT
inherently safer design for engineering.ppt
DhavalShah616893
 
PDF
A presentation on the Urban Heat Island Effect
studyfor7hrs
 
PDF
Unified_Cloud_Comm_Presentation anil singh ppt
anilsingh298751
 
PDF
MOBILE AND WEB BASED REMOTE BUSINESS MONITORING SYSTEM
ijait
 
PPTX
265587293-NFPA 101 Life safety code-PPT-1.pptx
chandermwason
 
PPTX
Hashing Introduction , hash functions and techniques
sailajam21
 
PPTX
EC3551-Transmission lines Demo class .pptx
Mahalakshmiprasannag
 
PPTX
Pharmaceuticals and fine chemicals.pptxx
jaypa242004
 
PDF
ARC--BUILDING-UTILITIES-2-PART-2 (1).pdf
IzzyBaniquedBusto
 
PPTX
The Role of Information Technology in Environmental Protectio....pptx
nallamillisriram
 
PPTX
Break Statement in Programming with 6 Real Examples
manojpoojary2004
 
PDF
monopile foundation seminar topic for civil engineering students
Ahina5
 
PPTX
Green Building & Energy Conservation ppt
Sagar Sarangi
 
PDF
Set Relation Function Practice session 24.05.2025.pdf
DrStephenStrange4
 
PPTX
Heart Bleed Bug - A case study (Course: Cryptography and Network Security)
Adri Jovin
 
PDF
POWER PLANT ENGINEERING (R17A0326).pdf..
haneefachosa123
 
Structural Functiona theory this important for the theorist
cagumaydanny26
 
Oxygen Co2 Transport in the Lungs(Exchange og gases)
SUNDERLINSHIBUD
 
Ethics and Trustworthy AI in Healthcare – Governing Sensitive Data, Profiling...
AlqualsaDIResearchGr
 
MobileComputingMANET2023 MobileComputingMANET2023.pptx
masterfake98765
 
inherently safer design for engineering.ppt
DhavalShah616893
 
A presentation on the Urban Heat Island Effect
studyfor7hrs
 
Unified_Cloud_Comm_Presentation anil singh ppt
anilsingh298751
 
MOBILE AND WEB BASED REMOTE BUSINESS MONITORING SYSTEM
ijait
 
265587293-NFPA 101 Life safety code-PPT-1.pptx
chandermwason
 
Hashing Introduction , hash functions and techniques
sailajam21
 
EC3551-Transmission lines Demo class .pptx
Mahalakshmiprasannag
 
Pharmaceuticals and fine chemicals.pptxx
jaypa242004
 
ARC--BUILDING-UTILITIES-2-PART-2 (1).pdf
IzzyBaniquedBusto
 
The Role of Information Technology in Environmental Protectio....pptx
nallamillisriram
 
Break Statement in Programming with 6 Real Examples
manojpoojary2004
 
monopile foundation seminar topic for civil engineering students
Ahina5
 
Green Building & Energy Conservation ppt
Sagar Sarangi
 
Set Relation Function Practice session 24.05.2025.pdf
DrStephenStrange4
 
Heart Bleed Bug - A case study (Course: Cryptography and Network Security)
Adri Jovin
 
POWER PLANT ENGINEERING (R17A0326).pdf..
haneefachosa123
 

IoT Based Smart Energy Meter using Raspberry Pi and Arduino

  • 1. Internet of Things (COS7039-B) IoT Based Smart Energy Meter Author: Bilal Amjad UoB # 19014392 Programme: Smart Grids and Energy Systems Faculty: Faculty of Engineering and Informatics Date submitted: 13th December 2019
  • 2. Table of Contents Abstract........................................................................................................................................... 4 1 Introduction............................................................................................................................. 5 1.1 Smart energy meter .......................................................................................................... 5 1.2 Internet of Things............................................................................................................. 5 1.3 The smart grid .................................................................................................................. 5 1.4 Problem statement............................................................................................................ 6 2 Literature review..................................................................................................................... 7 3 Design and methodology ........................................................................................................ 8 3.1 Components and hardware............................................................................................... 8 3.2 Hardware Implementation................................................................................................ 8 3.3 Measurement of electrical parameters: ............................................................................ 9 3.3.1 Tariff measurements: .............................................................................................. 10 3.4 Online platform:............................................................................................................. 10 3.5 Text massage alerts and updates: ................................................................................... 10 4 Results and discussion .......................................................................................................... 11 4.1 Dashboard of energy monitoring system ....................................................................... 11 4.1.1 Mobile Application................................................................................................. 12 5 Conclusion ............................................................................................................................ 13 6 Future work........................................................................................................................... 13 7 References............................................................................................................................. 14 Appendices.................................................................................................................................... 15 Appendix A............................................................................................................................... 15 Appendix B............................................................................................................................... 18
  • 3. List of Figures Figure 1: IoT technology [3]........................................................................................................... 5 Figure 2:PZEM-004T Version 3.0 [11] .......................................................................................... 8 Figure 3: PZEM-004T diagram [11]............................................................................................... 8 Figure 4: Arduino connection with PZEM-004T [11].................................................................... 9 Figure 5:Circuit diagram of smart energy meter............................................................................. 9 Figure 6(a & b): The dashboard of energy monitoring system..................................................... 11 Figure 7: Energy consumption profile on mobile application ..................................................... 12 List of Tables Table 1: Units of electrical parameters for PZEM-00T................................................................ 10
  • 4. Abstract Internet of Things (IoT) is widely used in industries and businesses like, smart cites, smart grids, automotive industries, logistics and healthcare. In Electric Power and Energy Systems (EPESs), smart grids techniques are being implementing to meet the energy demands, improve the energy efficiency, and reduce energy loses by implementing latest sensing and communication technologies. In several developed countries, automatic meter reading (AMR), advanced metering infrastructure (AMI) or smart energy meter with instantaneous energy information report have been applied at the domestic level. This project, design and implement a low-cost IoT energy monitoring system (smart energy meter) for real time monitoring of all electrical parameters i.e. AC voltage, AC current, active power, total energy consumption, power factor, frequency, and tariff. The design is based on a low-cost PZEM-004T, using non-invasive Current Transformer (CT) sensors, Arduino and Raspberry pi. Electrical measurements are done by PZEM-004T and CT sensors through Arduino. Raspberry pi communicates with Arduino through serial communication to retrieve these sensor’s data and send it to server via internet. As a result, the developed energy monitoring system can successfully record the voltage, current, active power, power factor, frequency, accumulative power consumption and tariff. Consumers will be able to see their electricity usage and the tariff according to the energy usage in real-time through web and mobile application. In case of any fault e.g. short circuit or power supply cut off, the consumer will receive a text massage on his mobile number. Moreover, consumer will be able to receive the tariff on weekly or monthly basis.
  • 5. 1 Introduction 1.1 Smart energy meter The smart energy meter is a wireless energy monitoring system containing an energy meter with a communication network topology to efficiently send data from the meters to a server or coordinator and a cloud platform to visualize the data in actual [1]. 1.2 Internet of Things Internet of Thigs (IoT) is a new architype in communications technology now a days. IoT concept that is "anything, anywhere, anytime" inspires the development of communication technology. IoT framework has three elementary concepts, things oriented, internet oriented, and semantic oriented [2]. Figure 1: IoT technology [3] 1.3 The smart grid The smart grid term is very widely used in EPES. Smart grid encompasses the entire energy conversion, transmission, distribution, and utilization cycle. It consists of advance actuators, sensors, communication infrastructure, IT systems, advanced monitoring, control and decision- making applications. There are multiple objectives to develop and deploy Smart Grid technologies. The key objectives are [4]: • To improve efficiency and economy in electrical conversion, transmission, distribution, storage and utilization • To enhance security and safety in system operation by increasing the observability and controllability of the power grid • To improve the reliability and availability of the electric supply to customers • To enable and promote the integration and utilization of renewable and sustainable energies • To maintain and improve the quality of power delivery to increase the shares of digital loads
  • 6. 1.4 Problem statement As IoT is implementing in every business and industry, Electric Power and Energy System (EPES) is also digitalising by integrating latest IoT, communication, computing and control technologies to make it smart. In EPES, measuring the energy consumption at consumer level is very important and useful. Electric companies always try to keep balance between electric supply, and it demand. By knowing the demand of electricity, the electric companies can forecast the load demand and can take decisions for future. Here comes the term, smart energy meter. Smart energy meter can help to simultaneous communicate between the consumer and the grid, rise the capacity of the electricity system of integrated services, meet the demand of energy and increase quality of service by promptly detecting the fault when it occurs. Each consumer can always monitor the status of their homes and avoid theft [5].
  • 7. 2 Literature review Several studies have proposed the design of smart energy meter. In [6] [7], their strategy were based on GSM network and employed database management to deliver energy usages data for their customs. In [12], ZigBees mutual with GSM based was anticipated, in such system the energy metering nodes use the ZigBees, interconnect with the central node and send information to central computer via GSM. K Chooruang and K Meekul developed an IoT low-cost energy monitoring system that use Wi-Fi, and MQTT (Message Queuing Telemetry Transport) protocol. The system contains the Peacefair PZEM -004T sensor, a CT (current transformer) sensor and Raspberry pi 3 model B. It can send comprehensive measurement of energy usage and the patterns of energy consumption [8]. B. K. Barman et al proposed smart energy meter controls and computes the energy consumption using ESP 8266 12E, a Wi-Fi module and uploads it to the cloud from where the customer or supplier can view the electric energy consumption. Consequently, energy analyzation by the consumer turn out to be much easier and governable. This system also helps in sensing power theft [9].
  • 8. 3 Design and methodology The project is divided in two parts, measuring electrical parameters and sending data to online platform. First, electrical parameters of the systems will be measured and then theses parameters will be sent over the server. 3.1 Components and hardware The main components are: • PZEM-004T and CT • Arduino • Raspberry pi 3 Model B • Connecting wires • Thinkspeak (online platform IoT) • Nexmo (for sending text massages) 3.2 Hardware Implementation The PZEM-004T measures RMS voltage, RMS current and calculates active power and total energy usage over time or accumulative power consumption. It has very good measurement accuracy. Figure 2 and 3 show the PZEM-004T module and circuit diagram, respectively. and datasheet is available here [10]. Figure 2:PZEM-004T Version 3.0 [11] Figure 3: PZEM-004T diagram [11] The figure 4 show the connection configuration of PZEM-004T module with Arduino. GND and 5V points of module relate to GND and 5V pins of Arduino, and TX and RX points of module relate to 9 and 10 pins of Arduino.
  • 9. Figure 4: Arduino connection with PZEM-004T [11] Now the Arduino is coroneted with Raspberry pi through USB cable. Raspberry pi receive data from Arduino by serial communication and send it to server. Figure 5 shows the complete circuit diagram of smart energy meter. The code for Arduino and Raspberry pi is attached in appendix B and C, respectively. Figure 5:Circuit diagram of smart energy meter 3.3 Measurement of electrical parameters: PZEM-004T (v3.0) module is responsible for measuring all electrical parameters. The module does TTL communication to transmitting or receiving data. Still, there is no library of this module available for Raspberry pi in python language, but its library is available for Arduino.
  • 10. Arduino use PZEM-004Tv30.h library [10] to communicate with the module through TX and RX pins and the Arduino code is added in to the appendix A. The table 1 shows the units used for measurement of all parameters. Table 1: Units of electrical parameters for PZEM-00T Sr. No. Parameter Unit 1. Voltage volt (V) 2. Current ampere (A) 3. Power Watt (W) 4. Energy kilo watt hour (kWh) 5. Frequency Hertz (Hz) 6. Power Factor No unit 3.3.1 Tariff measurements: Currently, in Bradford region the price of electric energy per kilo watt hour is 13.92. So, tariff can be calculated by multiplying total energy consumption with 13.92. 3.4 Online platform: ThingSpeak platform is used here for real time monitoring. It is a free online IoT platform, very easy to understand and interface with Raspberry pi. Every user has its own channel ID and API key. The Raspberry pi receives the data from Arduino and sent over the server to thingspeak dashboard every second (for Raspberry pi python code, refer to appendix B). 3.5 Text massage alerts and updates: Nexmo service is used for sending text massages to the user. Here for this project, user will be able to receive two types of text massages. One is about tariff updates; the consumer will receive the update of tariff on weekly or monthly bases. Second type is alerts massage; if the module gets the voltage value zero, it means there is any fault or power supply cut off. In such case the consumer will receive the alert massage “Supply Disconnected!!!”.
  • 11. 4 Results and discussion This section will explain the results from smart energy meter. As the meter is connected at main electric supply unit, so the dashboard will show the electric consumption of whole building or home. 4.1 Dashboard of energy monitoring system Figure 6 (a and b) shows the user-interface console. It is created on Thingspeak. It comprises of the measures that show the current tariff, total energy consumption, Power Factor, AC voltage, AC current and power. The charts characterize the measured energy information with respect to time. The system send data every second throughout the day and data can be shown concurrently on the console. (a) (b) Figure 6(a & b): The dashboard of energy monitoring system
  • 12. 4.1.1 Mobile Application In Figure 7, the energy patterns on android mobile application. The thingspeak application is available in google app store. Afte installing the application user will login by his channel ID to see the dashboard. Figure 7: Energy consumption profile on mobile application
  • 13. 5 Conclusion The presented smart energy meter is wireless meter reading system that can display and investigate the information at every interval giving precise outcomes with fewer mistake. This smart system can be useful for energy management, power saving from power section, automatic control of energy meter, to make consumer monitor their energy usage pattern and power theft detection. Sometime the system takes time to upload the data depending on the internet speed and module baud rate. The IoT idea can also be applied in numerous working situation such as home automation, automatic water level detector and traffic control system etc. 6 Future work Number of improvements can be done in future in term of • Integrating home automation with smart energy meter dashboard to control electric loads • Process data for short-term load forecasting and real time decision making.
  • 14. 7 References [1] S. Yasir, C. Noel, H. R. Mubashir and C. Rebecca, “Internet of Things-aided Smart Grid: Technologies, Architectures, Applications, Prototypes, and Future Research Directions,” IEEE Access, vol. 7, pp. 62962 - 63003, 2019. [2] L. Atzori, A. Iera and GiacomoMorabito, “The Internet of Things: A survey,” Comuputer Networks, vol. 15, no. 54, pp. 2787-2805, 2010. [3] M. Yun and B. Yuxin, “Research on the Architecture and Key Technology of Internet of Things (loT) Applied on Smart grid,” International Conference on Advances in Energy Engineering, pp. 69-72, 2010. [4] L. T. Berger and K. Iniewski, Smart Grid Applications, Communications and Security, New Jersey: John Wiley & Sons, Inc, 2012. [5] A. C. Swastika, R. Pramudita and R. Hakimi, “IoT-based Smart Grid System Design for Smart Home,” International Conference on Wireless and Telematics, pp. 49-53, 2017. [6] H. G. R. Tan, C. H. Lee and V. H. Mok, “Automatic power meter reading system using GSM network,” International Power Engineering Conference, pp. 465-469, 2017. [7] M. Wasi-ur-Rahman, M. T. Rahman, T. H. Khan and S. M. L. Kabir, “Design of an intelligent SMS based remote metering system,” International Conference on Information and Automation, pp. 1040-1043, 2009. [8] K. Chooruang and K. Meekul, “Design of an IoT Energy Monitoring System,” International Conference on ICT and Knowledge Engineering, 2018. [9] B. K. Barman, S. N. Yadav, S. Kumar and S. Gope, “IOT Based Smart Energy Meter for Efficient Energy Utilization in Smart Grid,” IEEE journal, 2018. [10] J. Mandula, “Interface library for the upgraded version of PZEM-004T v3.0,” Get Hub, 2019. [Online]. Available: https://github.com/olehs/PZEM004T. [Accessed 28 11 2019]. [11] [Online]. Available: https://www.innovatorsguru.com/pzem-004t-v3/. [Accessed 09 12 2019].
  • 15. Appendices Appendix A The PZEM-00T library is available on Get Hub [10]. Arduino code: //* Code to get the voltage, current and power from two AC PZEM sensors connected to the Arduino Mega microcontroller, then all the values *// // are concatenated in one char variable in order to send it through serial communication // ////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// / #include <SoftwareSerial.h> #include <PZEM004Tv30.h> //#include <PZEM004T.h> PZEM004Tv30 pzem(11, 12); //Rx,Tx pin of arduino // IPAddress ip(192,168,1,11); // IPAddress ip1(192,168,1,10); char Vx[10]; char Ix[10]; char Px[10]; char Ex[10]; char Fx[10]; char PFx[10]; char conc[360]; float V; //Voltage float I; //Current float P; //Power float E; //Energy float F; //Frequency float PF;//Power Factor void setup() { Serial.begin (9600); } void loop() { float voltage = pzem.voltage(); if( !isnan(voltage) ){
  • 16. V=voltage; //Serial.print("Voltage: "); Serial.print(voltage); Serial.println("V"); } else { V=0; // Serial.println("Error reading voltage"); } float current = pzem.current(); if( !isnan(current) ){ I=current; //Serial.print("Current: "); Serial.print(current); Serial.println("A"); } else { I=0; //Serial.println("Error reading current"); } float power = pzem.power(); if( !isnan(power) ){ P=power; //Serial.print("Power: "); Serial.print(power); Serial.println("W"); } else { P=0; //Serial.println("Error reading power"); } float energy = pzem.energy(); if( !isnan(energy) ){ E=energy; //Serial.print("Energy: "); Serial.print(energy,3); Serial.println("kWh"); } else { E=0; //Serial.println("Error reading energy"); } float frequency = pzem.frequency(); if( !isnan(frequency) ){ F=frequency; //Serial.print("Frequency: "); Serial.print(frequency, 1); Serial.println("Hz"); } else { F=0; //Serial.println("Error reading frequency"); } float pf = pzem.pf(); if( !isnan(pf) ){ PF=pf; //Serial.print("PF: "); Serial.println(pf);
  • 17. } else { PF=0; //Serial.println("Error reading power factor"); } //PZEM004T pzem(10,11); //(RX TX) //pzem.setAddress (ip); //V=pzem.voltage(ip); //voltage obtained from the pzem library //i = pzem.current(ip); //current obtained from the pzem library //p = pzem.power(ip);//power obtained from the pzem library dtostrf(V,7,3,Vx); //function used to stored the voltage value in the char variable ix, specifying 3 as the number of digits after the point dtostrf(I,7,3,Ix); //function used to stored the current value in the char variable iy, specifying 3 as the number of digits after the point dtostrf(P,7,3,Px); //function used to stored the power value in the char variable iz, specifying 3 as the number of digits after the point dtostrf(E,7,3,Ex); //function used to stored the total energy value in the char variable ix, specifying 3 as the number of digits after the point dtostrf(F,7,3,Fx); //function used to stored the frequency value in the char variable ix, specifying 3 as the number of digits after the point dtostrf(PF,7,2,PFx); //function used to stored the power factor value in the char variable ix, specifying 1 as the number of digits after the point delay(1000); sprintf(conc,": %s, : %s, : %s, : %s, : %s, : %s,n", Vx, Ix, Px, Ex, Fx, PFx); // function used to concatenate all the values in one unique char variable Serial.write(conc); }
  • 18. Appendix B Raspberry pi python code: import serial import time import re import thingspeak import urllib.request import datetime import nexmo start_time = time.time() chid = 935217 tskey = "TYILB5PXIGBNYSGW" tsurl = "https://api.thingspeak.com/update?api_key=TYILB5PXIGBNYSGW&field1=0" ts = thingspeak.Channel(chid, tsurl, tskey) print("System is getting ready!!!") time.sleep(3) port = "/dev/ttyACM0" s1 = serial.Serial(port,9600) def bill_sms(): client = nexmo.Client(key='17e0c2af', secret='eo8eHPkUh4yS9UtR') client.send_message({'from': 'Nexmo','to': '+447749532518','text': ' Your Electricity Bill is: '+str(Tariff) +"£"}) print("bill sent") def sms_alert(): client = nexmo.Client(key='17e0c2af', secret='eo8eHPkUh4yS9UtR') client.send_message({'from': 'Nexmo','to': '+447749532518','text': ' Supply Disconnected!!! '}) def readData(): global Voltage global Current global Power global Energy global Frequency global Power_Factor global Tariff V = m.group(1).replace(" ","") ## command used to saved the information splitted before in a the variable I = m.group(2).replace(" ","") P = m.group(3).replace(" ","") E = m.group(4).replace(" ","")
  • 19. F = m.group(5).replace(" ","") PF = m.group(6).replace(" ","") Voltage = float(V) Current = float(I) Power = float(P) Energy = float(E) Frequency = float(F) Power_Factor = float(PF) Tariff = Energy*13.94 print("n","----Smart Energy Meter----n") print(" Voltage:",+Voltage,"V") print(" Current:",+Current,"A") print(" Power:",+Power,"W") print(" Energy:",+Energy,"kWh") print(" Frequency:",+Frequency,"Hz") print(" Power Factor",+Power_Factor) print(" Tariff:",round(Tariff, 2),"£") #else: # print("Waiting") # time.sleep(3) def sendDataTs(): data = {"field1": Voltage, "field2": Current, "field3": Power, "field4": Energy, "field5": Frequency, "field6": Power_Factor, "field7": Tariff, } Ts = urllib.request.urlopen(tsurl + '&field1=%s&field2=%s&field3=%s&field4=%s&field5=%s&field6=%s&field7=% s' % (Voltage,Current,Power,Energy,Frequency,Power_Factor,Tariff )) #print ("Data sent for 6 fields: ", Voltage, Current, Power, Energy, Frequency, Power_Factor) while True: if s1.inWaiting()>0: inputValue = s1.readline().decode() #x = "None" if inputValue: m = re.search('.*:(.*),.*:(.*),.*:(.*),.*:(.*),.*:(.*),.*:(.*),',inputValu e) # command used to read the information and split it between the charcaters ':' and ',' if m:
  • 20. readData() try: sendDataTs() T=(time.time() - start_time)/60 #time in minutes if T>5: bill_sms() time.sleep(10) if Voltage==0: print("Supply Discunnected") sms_alert() time.sleep(15) except (KeywordInterrupt): print("Finishing")