You are on page 1of 69

A PROJECT REPORT

ON

THE DESIGN AND IMPLEMENTATION OF A SMART ENERGY


METER

SUBMITTED BY

EZEOGUINE CHUKA DEAN

20151019863 (ECE OPTION)

ONYEKWERE SOMTOCHI
AMAUCHE

20151013083(ECE OPTION)

SUBMITTED TO

DEPARTMENT OF ELECTRICAL AND ELECTRONIC


ENGINEERING

IN PARTIAL FULFILLMENT OF THE REQUIREMENTS FOR THE AWARD


OF BACHELOR OF ENGINEERING(B.ENG)

AUGUST 2021

1
DEDICATION
This work is dedicated to God almighty for his unfailing love, enablement,
protection, and faithfulness in our lives and to our parents for their unending support
(financially, morally, and mentally) throughout our study in school.

2
CERTIFICATION

This is to certify that this work, “A THE DESIGN AND IMPLEMENTATION


OF A SMART ENERGY METER”, was an authentic work carried out by
EZEOGUINE, CHUKA DEAN, ONYEKWERE SOMTOCHI .A. in partial
fulfilment of the requirements for the award of the Bachelor of Engineering (B.
Eng.) degree in Electrical and Electronic Engineering, Federal University of
Technology, Owerri.

Approved By: Date:


…….…………………. …….……………
Engr. Ubbaonu Chinonso F.N

Seminar Supervisor

3
ACKNOWLEDGEMENTS

Special thanks to our supervisor, Engr.Ubbaonu Chinonso F.N for his expert idea
and encouragement throughout this study.

My appreciation also goes to all lecturers in the department of Electrical and


Electronic Engineering; Engr. Prof. E. N. Okafor, Prof. (Mrs.) Gloria Chukwudebe,
Engr. Prof. D. O. Dike, Engr. Prof. F. K. Opara, Prof. (Mrs.) G. N. Ezeh, Prof. I. E.
Achumba, Engr. Dr. C.C. Mbaocha, Engr. Dr. O. J. Onojo, Engr. Dr. L. O. Uzoechi,
Engr. Dr. C. K. Agubor, Engr. Dr. L. S. Ezema, Engr. Dr. I. O. Akwukwaegbu, Engr.
Dr. O. C. Nosiri, Engr. Dr. M. Olubiwe, Engr. R. O. Opara, Engr.Dr. N. C.
Onuekwusi, Engr. R. C. Okpara, Engr. Dr. A.O. Akande, Engr. O. S. Nduka, Engr.
P. U. Eze, Engr. C. J. Anyalewechi, Engr. E. U. Ekwueme, Engr. C. F. Paulinus,
Engr. E. O. Ezeugwu, and Mr. E. C. Ifediora. Your help has really been beneficial
to us all. May God almighty replenish your labors of love.

We say a big thank you to our parents for their support, both financially and
otherwise throughout this study. We appreciate all your efforts.

4
ABSTRACT

In an era of smart and connected devices, it has become easier for measurement and
monitoring to be done remotely. Of recent, most homes have been adopting the use of
pre-paid meters for their energy consumption measurement and billing. However, this
does not provide them with the ease of making payments automatically or remotely
viewing and visualizing their energy usage. The smart meter makes use of a current
sensor to accurately measure the amount of current being draws by the load connected
to it at any given time. This analogue signal is then sampled and quantized in a bid to
convert it to digital signals that can be processed by the microcontroller (ESP 8266 –
Node MCU). The processed value is sent to a server and stored in a database. This is
then parsed by the mobile application (Smartvac) and displayed to the consumer
through a mobile application. The smart meter helps measure the instantaneous current,
power, total power and total energy consumed. The meter also keeps check of power
consumption and automatically put offs the load when the power reading is above a set
value (this would put on the buzzer, and turn off the appliances connected to the meter.
This system helps to prevent energy wastage and give consumers a sense of their
energy consumption. It also helps ensure that consumers can easily pay for their
electricity usage without the hassles of going to an office to get can activation code.
Keywords: ESP 8266, Measurement, Monitoring, Smart Meter.

5
DEFINITION OF TERMS
Measurement – The process of associating numbers with physical quantities and
phenomena. Measurement is fundamental to the sciences; to engineering,
construction, and other technical fields; and to almost all everyday activities.

Monitoring – The process of observing and checking the progress or quality of


(something) over a period; kept under systematic review.

Sampling– Sampling is the reduction of a continuous-time signal to a discrete-


time signal.

Quantization– The process of mapping continuous amplitude (analog) signal into


discrete amplitude (digital) signal

Application Programming Interface – A set of functions and procedures


allowing the creation of applications that access the features or data of an operating
system, application, or other service.

Flutter – An open-source UI software development kit created by Google. It is


used to develop cross platform applications for Android, iOS, Linux, Mac,
Windows

DataBase – An organized collection of data stored and accessed electronically


from a computer system

GoLang– Go is an open source programming language that makes it easy to build


simple, reliable, and efficient software.

6
LIST OF SYMBOLS AND ABBREVIATIONS

IDE – Integrated Development Environment

LCD – Liquid Crystal Display

IOT – Internet of Things

AMR – Automatic Meter Reading.

API – Application Programming Interface

DISCOS - Distribution Companies

KWh - Kilowatt- hour

HTTP – Hyper Text Transfer Protocol

7
LIST OF TABLES
Table 1: ESP 8266 Pin Out Descriptions ........................................................................................................ 31

8
LIST OF FIGURES AND DIAGRAMS
Figure 1: Electromechanical Energy Meter........................................................................... 13
Figure 2: Input and output definitions of an Analog to Digital converter ............................ 21
Figure 3: ADC Process .......................................................................................................... 22
Figure 4: Sampling and Holding Circuit ............................................................................... 23
Figure 5: Block Diagram of the Smart Meter System ........................................................... 27
Figure 6:LCD Display ........................................................................................................... 29
Figure 7: Vero Board ............................................................................................................. 30
Figure 8:I2C........................................................................................................................... 31
Figure 9: A Detailed Design of the System ........................................................................... 37
Figure 10: Block Diagram of Overall System Architecture .................................................. 39
Figure 11: How Application Programming Interface works. ................................................ 40
Figure 12: Current Sensor Testing ........................................................................................ 47
Figure 13:HTTP Response when a Connection was Successful. .......................................... 49
Figure 14: Load Testing ........................................................................................................ 49
Figure 15: APP Authentication Testing ................................................................................ 50
Figure 16: Dashboard and Visualization Testing .................................................................. 51
Figure 17: Electricity Payment Testing ................................................................................. 52

9
TABLE OF CONTENTS
Dedication 2
Certification 3
Acknowledgements 4
Abstract 5
Definition Of Terms 6
List Of Symbols And Abbreviations 7
List Of Tables 7
List Of Figures And Diagrams 9
CHAPTER ONE - INTRODUCTION
1.1Background Of Study: 12
1.2: Problem Statement: 14
1.3: Aim/ Objectives 15
1.4 Significance Of The Study: 16
1.5: Scope Of Work 17
CHAPTER TWO - LITERATURE REVEW
2.1: Background Overview 19
2.2: Automatic Meter Reading 19
2.3: Current Measurement: 20
2.3.1: Analog To Digital Conversion: 21
2.3.2: Sampling And Holding 22
2.3.3: Quantizing And Encoding 23
2.4: Node Mcu: 24
CHAPTER THREE- MATERIALS/METHODOLOGY
3.1: Materials 26
3.2: Block Diagram: 27
3.3: Detailed Design 37

10
3.4: The Mobile Application: 37
3.4.1: Overview Of The Mobile Application 38
3.5: Application Programming Interface 39
3.6: Database 44

CHAPTER FOUR - RESULTS/DISCUSSION


4.1.1 Current Sensor Testing 46
4.1.2: Esp 8266 Testing: 47
4.1.3: Load Testing: 49
4.1.4 App Testing 50
4.2: Discussion 52
4.3: Advantages/Applications Of The System 53
4.4: Limitations/Problems Of The System 53
CHAPTER FIVE – CONCLUSION AND RECOMMENDATIONS
5.1: Conclusion 55
5.2: Recommendations 55
5.3 Future Trends 56
Appendix 57
Arduino Program 57
References 67

11
CHAPTER ONE

INTRODUCTION
1.1: BACKGROUND OF STUDY:

In recent years, domestic and industrial users have shifted from traditional meters to smart
meters. Electromechanical meters were a dominant part of electricity measurement before
1970 [1]. However, it had been identified that the requirement of a meter which could
communicate and measure the electrical energy along with other electrical parameters was
essential. Therefore, solid state electronic meters were introduced to measure the overall
electrical parameters. Between 1970 and 2000, automatic meter reading was added to
electronic meters and it was a great achievement since it could send the data in near time.
However, it could only provide one-way communication. This limitation was overcome by
the introduction of smart meters which can provide two-way communication. Smart meters
can measure all the electrical parameters like electronic meters and communicate data in a
meaningful way. The consumer is updated with details such as energy consumption, the
number of electricity units remaining and other required information.

Before the invention of smart meters, we had the electromechanical meters.


Electromechanical energy meter is the most traditional and widely used energy meter for over
a century. It can measure only the active energy which is typically displayed on a mechanical
counter.

It is basically designed with four major systems which are driving system, moving system,
braking system, and registering system. The driving system consists of two electromagnets
while the moving system consists of an aluminium disc. The permanent magnet acts as the
braking system while the gear train and counter act as the registering system.

12
The electromagnetic force is produced by the arrangement of voltage and current coils. The
voltage coil is connected across the supply while the current coil is connected in series with
the load. The voltage coil produces a magnetic flux in proportion to the voltage and the current
coil produces a magnetic flux proportional to the current. The aluminium disc is mounted on
a rigid axis. A mechanical force is exerted on the disc by the Eddy currents produced.

The register mechanism integrates the speed of the disk over the time by counting the number
of revolutions. Current coil or the series coil produces alternating flux which is proportional
and in phase with the load current. Voltage coil or the shunt coil carries a current proportional
to the supply voltage. The flux produced by the voltage coil is not in phase with the supply
voltage [2].

Above is the basic principle of an Electromechanical Meter.

Figure 1: Electromechanical Energy Meter

The use of microcontrollers in electricity metering is gaining ground when it comes to


electricity distribution. Here, the Node MCU is used to collect the current sensor data and
send this data over the internet. Here, we utilize the concept of Advanced Metering
Infrastructure (AMI). Advanced metering infrastructure (AMI) refers to systems that
measure, collect, and analyze energy usage, and communicate with metering devices such as
electricity meters, gas meters, heat meters, and water meters, either on request or on a
13
schedule. These systems include hardware, software, communications, consumer energy
displays and controllers, customer associated systems, meter data management software, and
supplier business systems.

Government agencies and utilities are turning toward advanced metering infrastructure (AMI)
systems as part of larger "smart grid" initiatives. AMI extends automatic meter reading
(AMR) technology by providing two-way meter communications, allowing commands to be
sent toward the home for multiple purposes, including time-based pricing information,
demand-response actions, or remote service disconnects. Wireless technologies are critical
elements of the neighborhood network, aggregating a mesh configuration of up to thousands
of meters for back haul to the utility’s IT headquarters. More details on how this is done will
be shared [3].

1.2: PROBLEM STATEMENT:

Estimated billing is commonplace in most African countries including Nigeria. Despite


Government efforts, over 4.6 million Nigerians are on the estimated billing system. Nigeria
has one of the highest aggregate technical, commercial and collection losses at 43.65%, which
has been attributed to low investments in distribution networks exacerbated by the slow
progress of metering of customers which has posed a protracted liquidity challenge to the
industry. There is a need to reduce these losses. [3]

The National Pre-Paid Metering Program initiated by the Federal Government, prior to the
privatization, sought to address this gap but failed, due to corruption, lack of coordination,
inefficiency, etc. The failure to complete metering of customers prior to the privatization was
worsened by the absence of data on the total number of registered customers, now estimated

14
at 7.47 million (likely still an underestimation of the number of customers, with the associated
outcome of an even larger metering gap).

Consequently, the huge metering gap in Nigeria presents a Herculean challenge for the
DisCos when it comes to measuring the consumption of their unmetered customers. In
recognition of the impossibility of comprehensive metering within the near to mid-term
period, the regulator, the Nigerian Electricity Regulatory Commission enacted a regulation
on Estimated Billing Methodology to guide the DisCos in their billing. Nonetheless,
application of the methodology remains a very contentious process, as we have seen cases of
overbilling (otherwise known as crazy billing) and cases of underbilling which, we, the
consumers never talk about. Understandably, estimated billing is a vexing issue to un-metered
customers, due to the perception of overbilling situations [4].

1.3: AIM/ OBJECTIVES

This project aims to solve the issue of estimated billing and wastage in power consumption.
This it does by utilizing the concept of Internet of Things.

The specific objectives of this project include:

1) To design and implement an automated top-up electricity smart meter.


2) To design a smart meter that turn off the load once it senses an over-load in the home
(Once load exceeds consumers set limit).
3) To design and implement an accompanying mobile application that allows the user to
monitor her energy consumption, check for alarms and set reminders.
4) To design a system that helps manage energy billing and is cost effective.

15
This system can send out real time power consumption reading over the internet to a server.
These reading is then consumed by an Application Programming Interface (API). The
extracted values are being displayed to the customers in the form of interactive dashboards.

Here, the NodeMCU microcontroller is utilized to send data over the internet and collect
current readings from a current transformer; to do this we would be making use of an ACS712
current sensor module.

This Data Acquisition System (DAQ) consists of the Smart Meter Kit (Hardware) and an
Android Mobile application which we called Smartvac. The aim of the Smart Meter Kit is to
measure the amount of current that a load which is being connected to it consumes. The
mobile application (Smartvac) helps the consumer monitor his/her energy consumption, pay
for her electricity bills , notifies the customer when his or her power consumption exceeds a
set limit and reminds the user to put off lights and appliances at home.

1.4 SIGNIFICANCE OF THE STUDY:

There are many problems in metering and billing processes like the going of meter reader to
each customer meter to manually take the meter reading, the probability of the non-existence
of the customers at their houses during that time, the lack of integrity and credibility of some
of the meter readers etc.

These myriad of problems leads to the need for a solution; a solution that removes the hassles
of energy measurement and management. This is where an electricity smart meter comes in.

A smart meter is an integrated system equipped with a communication network, linking


sensors, domestic appliances, and other electronic and electrical devices, that can be remotely

16
monitored [8], accessed or controlled and which provides services that respond to the needs
of the users. The existence of a communication network is central to the concept of smart
metering systems as it is a key feature which distinguishes smart meters from other meters
merely equipped with standalone features.

Advantages of smart meters

i) Smart Meters provide customers with near real-time information on energy use.
ii) Smart meters also help enable better management of energy use, save money, and
reduce emissions.
iii) Bring an end to estimated billing – consumers are only billed for their actual energy
use, helping them to better manage their budget.
iv) Smart meters help with energy consumption measurement and enables us to
monitor our billings. [9]

1.5: SCOPE OF WORK

This project is designed to measure changes in electricity consumption readings over time,
this helps with the calculation of energy usage (KWh). However, voltage is kept at a constant
220v. This is because the NodeMCU has only one analog pin and as such cannot easily be
connected to both a current and voltage sensor.

This project also allows users to monitor their energy consumption via the accompanying
mobile application. Users can set reminders which include but is not limited to “reminders
notifying users to switch off the light before going to bed”. Users are also sent E-mail
messages which notifies them when their average power consumption exceeds the limit that
has been set by them in the mobile application to help ensure power conservation and
budgeting of electricity billing. The load connected to the smart meter is also put off once
17
excess power consumption is sensed. This is however limited as users do not have the
flexibility to remotely switch on or put off their appliances remotely.

18
CHAPTER TWO
LITERATURE REVIEW

2.1: BACKGROUND OVERVIEW

On the development of this project, a few reviews were carried out. These reviews were
carried out to give a better insight and understanding regarding the development and working
of the system. Different sources like journals, books, internet sources and previous projects
provide concrete references and understanding for the study. This project is focused on the
design and implementation of an energy smart meter. The reviews carried out pinpoints smart
metering, Internet of Things, micro controllers as well as sampling techniques.

2.2: AUTOMATIC METER READING

Currently, numerous systems of Automatic Meter Reading (AMR) are implemented using
Bluetooth, General Packet Radio Access (GPRS) and Global System for Mobile
communication. Utilizing GSM technology remote sharing of information of energy
consumption to consumers is possible. But there can be chances of missing SMS thus result
in decreasing the reliability and efficiency of the system. GPRS is difficult to implement for
long distance two-way communication between utility and consumers.

Here, we begin by looking at a couple of projects and papers on electricity smart meters.
Milanpreet Kaur et al in their paper titled “Implementation of Smart Metering based on
Internet of Things” describes the monitoring of energy consumption with Arduino Uno board
and Ethernet using IoT (Internet of Things) concept. This proposed design eliminates human
inclusion in the conservation of electricity. The consumer can receive the information about
consumption of energy by using IP address on their devices. The web client code is uploaded
for checking the client information such as location, content, connection, and disconnection
to the web server. This proposed system gives reliable and accurate information regarding

19
electrical energy management system (EMS) through Internet of things (IoT) [6]. Here, it is
observed that an Arduino Uno microcontroller is used.

Also, AMR is enabled by using ZigBee and GSM module in which ZigBee is interfaced with
energy meter to collect data and GSM is used for transmitting message/SMS to the utility.
Here, the user does not have the liberty to easily view historical power consumption data, and
information that could have been sent across can be lost due to network failure.

In another paper titled “An IOT based smart metering development for energy management
system” by S. G. Priyadharshini et al where they examined the design of an IOT based
platform for remote monitoring of the metering infrastructure in the real time. The data
visualization is carried out in a webpage and the data packet loss is investigated in the remote
monitoring of the parameters [9]. Here the authors proposed system that allows alertness to
be set for consumption levels above and below “user set trigger levels” and to forecast future
energy use. To measure bidirectional flow of energy to enable customers

participate in energy management and to perform occupancy detection algorithm to


automatically on/off the appliances when not in use. To categorize the loads into levels and
perform load shedding in peak hours and hence loads to effective energy management and to
allow the system operator to control the appliances

remotely by accessing through IOT in case of peak load shaving and power quality issues.
This work did not however go beyond the proposal phase and failed to examine in-depth how
blocks could be put together to build a truly smart electricity meter.

2.3: CURRENT MEASUREMENT:

Measurement of analog signals (in this case current) is essential in a system such as this.
Several papers have made use of different approaches in the measurement of current signals
from AC and/or DC sources.

20
The current sensing technology used plays a vital role in the accuracy and sensitivity of the
current measurement. Here, the current sensor made use of has the ability to measure both
AC and DC current and measure current of up to 30Amps.

2.3.1: ANALOG TO DIGITAL CONVERSION:

An analog to digital converter (ADC) as its name indicates is an electronic device which
converts continuous time-varying analogue signals into discrete-time digital signals so that
they can easily be read by the digital devices. It has many applications in electronics projects.
ADC converts the physical quantities of a real-world phenomenon into a digital language
which is used in control systems, data computing, data transmission, and information
processing. The figure below shows the input/ output relationship of an ADC.

Figure 2: Input and output definitions of an Analog to Digital converter


Usually, transducers are also used to convert the input analog variables in the form of currents
or voltages. Basically, the digital numbers used here are binary i,e ‘0’ and ‘1’. The ‘0’
indicates the ‘off’ state and ‘1’ represents the ‘on’ state. Hence all the analog values are
converted into digital binary values by an ADC. For example, if we must install an alarm in
our house or at some facility, whose function is to set off in case of fire or overheating. Our
whole alarm system will be electronic but the temperature sensor will give analog values at
the output after sensing the temperature. Therefore, to convert the varying values of
temperature in digital or discrete values, we have to use an analog to digital converter.

21
A/D Conversion Process and How ADC works?

Mainly there are two steps for the analog to digital conversion:

1. S/H: Sampling and holding

2. Q/E: Quantizing and Encoding

The ADC process is shown in figure below:

Figure 3: ADC Process


2.3.2: SAMPLING AND HOLDING
An analog signal continuously changes with time, in order to measure the signal we have to
keep it steady for a short duration so that it can be sampled. We could measure the signal
repeatedly and very fast, and then find out the right time scale. or we could measure the signal
at different timings and then average it. Or preferably we can hold the signal for a specific

22
duration and then digitize the signal and sample the value. This is done by a sample and hold
circuit. For, at least the time required for digitization, it keeps the value stable. Figure shows
the circuit for sampling and holding of a signal.

Figure 4: Sampling and Holding Circuit

We keep the switch normally open, and when we want to find a measurement, we close the
switch momentarily.

2.3.3: QUANTIZING AND ENCODING


On the output of (S/H), a certain is voltage level present. We assign a numerical value to it.
The nearest value, in correspondence with the amplitude of sampling and holding signal, is
searched. And this value cannot be just any value, it should be from a limited set of possible
values. It depends on the range of the quantizer and the range in given in a power of 2 i,e
2n (28 = 256, 210=1024 etc).

After identifying the closest value, a numerical value is assigned to it and it is encoded in the
form of a binary number. The binary encoded numbers generated by quantizer are represented
by ‘n’ bits. The resolution of an ADC can also be denoted by ‘n’ bit.The figure shows the
whole conversion process:

23
Sampling, Holding and Quantizing

The values achieved after the quantization and encoding process cannot be said to be
thoroughly accurate. These are only the approximations of the real-world values. The
accuracy of the quantizer highly depends on the resolution of the qunatizer, greater the
resolution, more accurate the values will be. The ADC resolution is limited by a number of
constraints, out of which, time is a major issue. If the set of possible values, from which the
closest value is to be searched, is greater, then it will surely take more time. But to accelerate
this process, more techniques have been developed.

2.4: NODE MCU:

The Node MCU microcontroller plays a paramount role when it comes to communication
between devices over the internet. In a paper by D. V. N.Ananth et al titled “Smart Electricity
Billing Using Node-MCU” [10], They designed a project where the user receives his or her
billing periodically and is automatically cutoff in a case where the credit that is available is
finished. This project however improves on this by not only alerting consumers when their
available number of unit is about to finish but also helping them to automatically top-up their
credit unit.

In another paper by Win Adiyansyah Indra et al titled “GSM-Based Smart Energy Meter with
Arduino Uno” [11]. Users were able to monitor their current power consumption with the
help of SMS alerts. This was made possible by the use if an Arduino Microcontroller and a
GSM module. However, this is not efficient and makes it difficult for users to still be able to
monitor their power consumption should they leave the country or visit an area where their
local service operator does not operate.

24
Here, the smart meter being designed comes along with a mobile application that allows the
user to monitor her power consumption real time from anywhere in the world. This is also
cost effective and updates in real time when compared against an SMS based system.

25
CHAPTER THREE
MATERIALS/METHODOLOGY

3.1: MATERIALS
List of materials that were used

- LCD Display
- Veroboard
- I2C
- ESP 8266 (Node MCU)
- Buzzer
- LED
- Connecting Wires
- Battery (Power Bank)
- Switches
- Current Sensor
- Lamp holder
- Bulb
- Box for Packaging
- Smartphone (Mobile Application)
- Current Sensor

Software Package:
- Easy EDA
- Arduino IDE
- Flutter
- Golang

26
3.2: BLOCK DIAGRAM:

Figure 5: Block Diagram of the Smart Meter System

LCD Display:

The Liquid Crystal library allows you to control LCD displays that are compatible with the
Hitachi HD44780 driver. There are many of them out there, and you can usually tell them by
the 16-pin interface.

27
The LCDs have a parallel interface, meaning that the microcontroller has to manipulate
several interface pins at once to control the display. The interface consists of the following
pins:

A register select (RS) pin that controls where in the LCD's memory you're writing data to.
You can select either the data register, which holds what goes on the screen, or an instruction
register, which is where the LCD's controller looks for instructions on what to do next.

A Read/Write (R/W) pin that selects reading mode or writing mode

An Enable pin that enables writing to the registers

8 data pins (D0 -D7). The states of these pins (high or low) are the bits that you're writing to
a register when you write, or the values you're reading when you read.

There's also a display contrast pin (Vo), power supply pins (+5V and Gnd) and LED
Backlight (Bklt+ and BKlt-) pins that you can use to power the LCD, control the display
contrast, and turn on and off the LED backlight, respectively.

The process of controlling the display involves putting the data that form the image of what
you want to display into the data registers, then putting instructions in the instruction register.
The Liquid Crystal Library simplifies this for you so you don't need to know the low-level
instructions.

28
Figure 6:LCD Display

Signal flow:

- Once the system is powered on, the ESP8266 NodeMCU creates a connection with the
router (here, my mobile device serves as the router).
- The current sensor receives current signal from the load and sends this to the
NodeMCU for sampling.

Vero Board:
Veroboard is a printed circuit board that’s designed with rows of copper tracks with holes
drilled in then for electronic components to be soldered to construct electronic circuits. The
hole and tracks are all spaced a tenth of an inch apart, so that the components attached to it
such as ICs, resistors etc. fit perfectly.

29
Figure 7: Vero Board

I2C:

This chip converts the I2C data from an Arduino into the parallel data required by the LCD
display. The board also comes with a small knob to make fine adjustments to the contrast of
the display. In addition, there is a jumper on the board that supplies power to the backlight.

30
Figure 8:I2C
Table 1: ESP 8266 Pin Out Descriptions

Pin Name Description


Category

Power Micro- Micro-USB: NodeMCU can be powered through the USB port
USB,
3.3V,
GND, 3.3V: Regulated 3.3V can be supplied to this pin to power the board

Vin

GND: Ground pins

Vin: External Power Supply

Control EN, The pin and the button resets the microcontroller
Pins RST

31
Analog A0 Used to measure analog voltage in the range of 0-3.3V
Pin

GPIO GPIO1 NodeMCU has 16 general purpose input-output pins on its board
Pins to
GPIO16

SPI Pins SD1, NodeMCU has four pins available for SPI communication.
CMD,
SD0,
CLK

UART TXD0, NodeMCU has two UART interfaces, UART0 (RXD0 & TXD0) and UART1 (RXD1
Pins RXD0, & TXD1). UART1 is used to upload the firmware/program.
TXD2,
RXD2

I2C Pins NodeMCU has I2C functionality support but due to the internal functionality

of these pins, you have to find which pin is I2C.

ESP 8266 (Node MCU):

NodeMCU is an open-source Lua based firmware and development board specially targeted
for IoT based Applications. It includes firmware that runs on the ESP8266 Wi-Fi SoC from
Espressif Systems, and hardware which is based on the ESP-12 module.

32
NodeMCU Development Board Pinout Configuration

NodeMCU ESP8266 Specifications & Features

1. Microcontroller: Tensilica 32-bit RISC CPU Xtensa LX106


2. Operating Voltage: 3.3V
3. Input Voltage: 7-12V
4. Digital I/O Pins (DIO): 16
5. Analog Input Pins (ADC): 1
6. UARTs: 1
7. SPIs: 1
8. I2Cs: 1
9. Flash Memory: 4 MB
10. SRAM: 64 KB
11. Clock Speed: 80 MHz

33
12. USB-TTL based on CP2102 is included onboard, Enabling Plug n Play
13. PCB Antenna

Current Sensor:

The ACS712 is a fully integrated, hall effect-based linear current sensor with 2.1kVRMS
voltage isolation and an integrated low-resistance current conductor. Technical terms aside,
it is simply put forth as a current sensor that uses its conductor to calculate and measure the
amount of current applied [10].

The features of ACS712 include:

• 80kHz bandwith
• 66 to 185 mV/A output sensitivity
• Low-noise analog signal path
• Device bandwith is set via the new FILTER pin
• mΩ internal conductor resistance
• Total output error of 1.5% at TA = 25°C
• Stable output offset voltage.
• Near zero magnetic hysteresis

Here’s how the ACS712 works:

• Current flows through the onboard hall sensor circuit in its IC

• The hall effect sensor detects the incoming current through its magnetic field
generation

• Once detected, the hall effect sensor generates a voltage proportional to its magnetic
field that’s then used to measure the amount of current

34
ACS712 Current Sensor Applications

The ACS712 IC being able to detect both AC/DC current, it can be used in a wider range of
applications apart from electrical appliances. Be it Arduino/other microcontroller usages, or
industrial, commercial, and communication applications.

Here are the common list of applications:

• Motor speed control in motor control circuits

• Electrical load detection and management

• Switched-mode power supplies (SMPS)

• Protection for over-current

Before the Micro controller is able to read and interpret the analog readings from the current
sensor, this analog reading has to undergo what is called Analog to Digital Conversion.
35
Buzzer:
A buzzer is a small yet efficient component to add sound features to our project/system. It is
very small and compact 2-pin structure hence can be easily used on breadboard, Perf Board
and even on PCBs which makes this a widely used component in most electronic
applications.

There are two types are buzzers that are commonly available. The one shown here is a
simple buzzer which when powered will make a Continuous Beep...sound, the other type is
called a readymade buzzer which will look bulkier than this and will produce a Beep. Beep.
Beep. Sound due to the internal oscillating circuit present inside it. But, the one shown here
is most widely used because it can be customised with help of other circuits to fit easily in
our application.

This buzzer can be used by simply powering it using a DC power supply ranging from 4V
to 9V. A simple 9V battery can also be used, but it is recommended to use a regulated +5V
or +6V DC supply. The buzzer is normally associated with a switching circuit to turn ON or
turn OFF the buzzer at required time and require interval.

Applications of Buzzer
• Alarming Circuits, where the user has to be alarmed about something
• Communication equipments
• Automobile electronics
• Portable equipment’s, due to its compact size

36
3.3: DETAILED DESIGN

Figure 9: A Detailed Design of the System

3.4: THE MOBILE APPLICATION:

Software is now an integral part of the world. Almost everything runs on software and the
world is becoming more interconnected than ever with the popularization of IoT(Internet of
Things) and increased capability for these devices to connect to the Internet. We have
leveraged some of these technologies to build our project.

The Smartvac project is split into two parts. One part is the Arduino hardware that collects
information on the energy used by the appliance. But most of the processing and data
aggregation happens at the software end. This offloads most of the complex processing
burden from Arduino so that it doesn’t require a larger, more expensive processor or
memory. The software consists of an application, an application programming interface and
a database. All of them are hosted and available on the internet.

37
3.4.1: OVERVIEW OF THE MOBILE APPLICATION

The three different parts can operate independently but are connected to create a good
experience. The app, written in the Flutter language, is the part that the user interfaces with.
It is designed to be visually appealing and easy to use. It displays the energy usage and
payment information in a simple format for the user to see. It serves as the front-end of the
product.

The Application Programming Interface(API) is the part that the Arduino sends its data to.
The API is the bridge of communication between the front-end, the Arduino hardware and
the database. It also authenticates various users access to the app and connects to third-
party applications that make payment for the energy meter possible. It is written in Golang

The database stores all the data - users, energy and payment information. It is secured and
access to it is limited as most of the data it holds is sensitive. Long term storage of the data
enables users to view their usage over various periods of time.

38
Figure 10: Block Diagram of Overall System Architecture

3.5: APPLICATION PROGRAMMING INTERFACE?

An Application Programming Interface is a set of programming code that enables data


transmission between one software product and another. It also contains the terms of this data
exchange.

39
Figure 11: How Application Programming Interface works.

Application programming interfaces consist of two components:

• Technical specification describing the data exchange options between solutions with
the specification done in the form of a request for processing and data delivery
protocols

• The software interface is written to the specification that represents it

The software that needs to access information (i.e., X hotel room rates for certain dates) or
functionality (i.e., a route from point A to point B on a map based on a user’s location) from
another software, calls its Application Programing Interface while specifying the
requirements of how data/functionality must be provided. The other software returns
data/functionality requested by the former application. [10]

And the interface by which these two applications communicate is what the Application
Programming Interface specifies.

The Red Hat specialists note that Application Programming Interfaces are sometimes
considered contracts, where documentation is an agreement between the parties: “If a party

40
first sends a remote request structured a particular way, this is how the second party’s software
will respond.” The Application Programming Interface (API) documentation is a manual for
developers that includes all necessary information on how to work with the Application
Programming Interface and use the services it provides.

When used in the context of web development, an API is typically defined as a set of
specifications, such as Hypertext Transfer Protocol (HTTP) request messages, along with a
definition of the structure of response messages, usually in an Extensible Markup Language
(XML) or JavaScript Object Notation (JSON) format. An example might be a shipping
company API that can be added to an eCommerce-focused website to facilitate ordering
shipping services and automatically include current shipping rates, without the site developer
having to enter the shipper's rate table into a web database. While "web API" historically has
been virtually synonymous with web service, the recent trend (so-called Web 2.0) has been
moving away from Simple Object Access Protocol (SOAP) based web services and service-
oriented architecture (SOA) towards more direct representational state transfer (REST) style
web resources and resource-oriented architecture (ROA). [11]

Overview of the Smartvac API

The Smartvac API collects data from various current sensors in JSON format and stores it in
a database. It can do calculations to convert the current/voltage data into a format more
understandable by users. Ideally, the data being received should have an identification
number to associate the data with different users. It also exposes endpoints so that the data
can be pulled by various dashboards to enable users to view usage data over time in the form
of graphs.

41
Lastly, the API automatically recharges the meter (through a payment API) if the user enables
this feature.

Stack/Languages used:

Language: Golang

Golang was the language of choice because Go is a great language for creating simple yet
efficient web servers and web services. It provides a built-in HTTP package that contains
utilities for quickly creating a web or file server.

The API is to be consumed by an app and possibly other platforms.

Endpoints

- [POST]/signup - Onboard users into the app

- [POST]/sign in - Login users

- [POST]/data - Receive data from various endpoints

- [GET]/data? Query- Dashboards hit this endpoint for data

- [POST]/user - Store user data

- [GET]/user/:id - Get user data

- [PUT]/user/:id - Update user data

- [POST]/pay/:id - Make payment for a particular user

- [GET]/history/id - get history of payment for a particular user


42
Steps to develop the API

The users need to be authenticated before they can access the app and other users should not
have access to other people’s data.

The admin user has access to everything and oversees the data.

First, a new Go project and module is created and a framework for making http servers in
Golang called Gin is added. The first http route that leads to the Welcome endpoint is created.

An init function is created to connect to database once the application programming interface
starts up. The database connection details are sensitive information and are gotten from
environment variables, so that even someone that has access to the code cannot connect to
the database. This increases the security of the database.

An ORM(Object Relational Mapping) called gorm is used to convert between incompatible


Go types and the schema in the database table. The ORM makes it easier to insert, retrieve,
update and delete data from the database. Once the database and the routes are set up, the next
stage is to define the various route.

While it would take up too much space to visit each of the routes and the method of
implementation, it is worthy to note that the sign in and sign up use one-way hashing to
encrypt passwords before it is stored in the database.

In the end, the web server is hosted on the free tier of Heroku and the free tier of Heroku
postgres is used. The correct configuration variables are set and the app can be accessed from
any where on the internet.

43
3.6: DATABASE

Formally, a "database" refers to a set of related data and the way it is organized. Access to
this data is usually provided by a "database management system" (DBMS) consisting of an
integrated set of computer software that allows users to interact with one or more databases
and provides access to all of the data contained in the database (although restrictions may
exist that limit access to particular data). The DBMS provides various functions that allow
entry, storage and retrieval of large quantities of information and provides ways to manage
how that information is organized.

Because of the close relationship between them, the term "database" is often used casually to
refer to both a database and the DBMS used to manipulate it.

Outside the world of professional information technology, the term database is often used to
refer to any collection of related data (such as a spreadsheet or a card index) as size and usage
requirements typically necessitate the use of a database management system. [12]

Existing DBMSs provide various functions that allow management of a database and its data
which can be classified into four main functional groups:

Data definition – Creation, modification and removal of definitions that define the
organization of the data.

Update – Insertion, modification, and deletion of the actual data.

44
Retrieval – Providing information in a form directly usable or for further processing by other
applications. The retrieved data may be made available in a form basically the same as it is
stored in the database or in a new form obtained by altering or combining existing data from
the database.

Administration – Registering and monitoring users, enforcing data security, monitoring


performance, maintaining data integrity, dealing with concurrency control, and recovering
information that has been corrupted by some event such as an unexpected system failure.

Both a database and its DBMS conform to the principles of a particular database model.
[13]"Database system" refers collectively to the database model, database management
system, and database.

Postgres, Tables and Schema


The relational database is used for storing data. The choice was PostgresSQL. PostgreSQL,
also known as Postgres, advertises itself as “the most advanced open-source relational
database in the world”. It was built to be feature-rich, extendable and standards-compliant. In
the past, Postgres performance was more balanced - reads were generally slower than
MySQL, but it could write large amounts of data more efficiently, and it handled concurrency
better.

The database consists of three tables - user, payment and readings. The tables and their
schema are listed below:

45
CHAPTER FOUR
RESULTS AND DISCUSSION

4.1 RESULTS

The results obtained from testing our project during the circuit design and analysis, the
coupling of the project and the testing of the project which spanned the beginning of the
project till the end of the project is explained below.

These testing’s includes hardware testing such as current sensor testing, Esp8266 testing,
load testing, LCD testing and buzzer and led testing (for indication and alarm) and software
testing such as

4.1.1 CURRENT SENSOR TESTING

After connecting the current sensor to the Node MCU, it was essential to ensure that the
values being displayed on the console of the Arduino is equivalent to the current value one
would get should she use a multimeter.

To perform this test and calibration, we made use of a known power rated bulb (60 watts)
and performed a basic analysis to help us finetune the calibration reading of our current
sensor.

Once this was done, we were assured that our readings gotten from the current sensor were
accurate and less prone to noise.

46
Figure 12: Current Sensor Testing

4.1.2: ESP 8266 TESTING:

This testing was performed to ensure that the Esp 8266 successfully connects to the router
(in this case my mobile hotspot) and sends out the required parameters to the server. To
ensure that a successful connection is established, we are expecting a code 200 HTTP
response. This code shows that there was indeed a successful connection.

Below is a list of HTTP response codes and their meaning.

200 OK - Standard response for successful HTTP requests. The actual response will depend
on the request method used. In a GET request, the response will contain an entity
corresponding to the requested resource. In a POST request, the response will contain an
entity describing or containing the result of the action.

201 Created The request has been fulfilled, resulting in the creation of a new resource.[9]

47
202 Accepted The request has been accepted for processing, but the processing has not
been completed. The request might or might not be eventually acted upon, and may be
disallowed when processing occurs.

203 Non-Authoritative Information (since HTTP/1.1): The server is a transforming


proxy (e.g. a Web accelerator) that received a 200 OK from its origin, but is returning a
modified version of the origin's response.

204 No Content: The server successfully processed the request and is not returning any
content.

205 Reset Content: The server successfully processed the request, asks that the requester
reset its document view, and is not returning any content.

206 Partial Content (RFC 7233): The server is delivering only part of the resource (byte
serving) due to a range header sent by the client. The range header is used by HTTP clients
to enable resuming of interrupted downloads or split a download into multiple simultaneous
streams.

207 Multi-Status (WebDAV; RFC 4918): The message body that follows is by default an
XML message and can contain a number of separate response codes, depending on how
many sub-requests were made.

208 Already Reported (WebDAV; RFC 5842): The members of a DAV binding have
already been enumerated in a preceding part of the (multistatus) response and are not being
included again.

226 IM Used (RFC 3229): The server has fulfilled a request for the resource, and the
response is a representation of the result of one or more instance-manipulations applied to
the current instance.

48
Figure 13:HTTP Response when a Connection was Successful.

4.1.3: LOAD TESTING:

This testing is done to ensure that the current sensor is connected properly to the load and
there is an absence of short circuit/ current leakage.
To perform this test, the smart meter is loaded and the lcd is monitored to ensure that the
reading being displayed on the lcd reacts to the change in load.
Below is a picture that shows the load test being carried out.

Figure 14: Load Testing

49
4.1.4 APP TESTING
The application was thoroughly tested to ensure that it met all the software requirements
and specifications while following the design closely. Firstly, all endpoints from the
Application Programming Interface was tested using a tool called Postman to ensure they
were working and also record the response returned by the server. Secondly, this tool also
served as a way to generate documentation for whoever is using the application to follow.

Here are the Authentication pages. These pages ensure that the users are correctly signed up
and also supply the correct password before giving access to the dashboard as it contains
information peculiar to each user

Figure 15: APP Authentication Testing


50
There are energy consumption pages that total the user’s energy users on an hourly, daily or
weekly basis and display it in a digestible manner.

Figure 16: Dashboard and Visualization Testing

Here are the pages for making payments. These pages tell the user how he is charged for the
units, allow him to input his card details and then makes a payment to the card company.

51
Figure 17: Electricity Payment Testing
All the pages were tested both manually and automatically by code

4.2: DISCUSSION

Testing and analysis carried out on the system helped indicate the performance of the
system. In the mobile application, users are being charged 20 Nigerian Naira per unit
electricity bought. Here, one (1) unit of electricity equals 1kw-h.

Energy wastage has become dominant in most developing countries despite the shortage of

52
power being generated. According to a paper by Oyedepo, Sunday Olayinka titled “Energy
Efficiency and Conservation Measures: Tools for Sustainable Energy Development in
Nigeria” [17] . In many major cities in Nigeria, indiscriminate use of electricity for different
purposes is common. These include putting on light to advertise goods in the day time,
switching on outdoor lighting during the day, building of industries in residential areas,
proliferation of private water boreholes, setting appliances on standby mode, simultaneous
use of multiple appliances in public buildings, leaving appliance on when not in use,
multiple use of inefficient heating equipment for cooking and heating water in the
residential and commercial buildings etc. All these practices encourage the wastage of
electricity and bring about inefficient utilization of energy.

Being able to help users monitor their trend in energy consumption through an intuitive
dashboard and visualization is what Smartvac offers. This goes a long way in making users
aware of their energy consumption and inculcate power saving habits.

4.3: ADVANTAGES/APPLICATIONS OF THE SYSTEM

The Advantages of SmartVac are as follows:

1) It provides her users with real time information on power consumption.


2) It helps users pay for their electricity bill at the comfort of their homes.
3) It allows for power management as it automatically turns off load and alarms the user
when power consumption exceeds.

4.4: LIMITATIONS/PROBLEMS OF THE SYSTEM

The various limitations to this system include the following:

i. The user does not have the ability to remotely turn off load at home; though she will be
notified in a case where power consumption exceeds set limit

53
ii. The user can only get a sense of total power consumption but not the power
consumption of individual electrical components.
iii. The systems reading is most accurate when the voltage is at 220v. A voltage supply
below 220v would introduce a bit of noise to the system.

54
CHAPTER FIVE

CONCLUSION AND RECOMMENDATIONS

5.1: CONCLUSION

The main objectives of this project is to prevent power wastage and optimize power
consumption. This project also provides users with the ease of making payments.
We assembled a smart meter which uses the aid of a current sensor that is capable of
measuring up to 30A and DC /AC current to measure changes in current signal. With the
aid of an ESP8266 Node MCU the analog current signal was able to be converted to a
digital signal and sent over the internet via the WIFI module.
This data is sent to a Heroku server via a GET request and processed by our mobile
application “Smartvac”. The mobile application allows users to view their daily power
consumption, notifies them when they are running short of units and helps users make
payment. With this, we were able to assemble a smart meter kit that utilizes the power of
Internet of Things in power measurement and monitoring.

5.2: RECOMMENDATIONS

Energy production and management has become very essential in our daily life. Today,
you can hardly think of any useful appliance that does not need electricity to function. It
has become even more important to enable those who consume this important, yet finite
resource (electricity) manage their consumption effectively. Most pre-paid meters installed
at homes are not smart and do a poor job at providing a user with comprehensive details of
power consumption.
Energy management can be done effectively with the use of Internet of Things and this is
what this project tapped into. Scale up of this project with help with energy management
and a more effective power distribution system

55
5.3 FUTURE TRENDS

This design of this system has the potential to change the face of energy consumption especially
in developing countries. This design can be made smarter by incorporating the power of
machine learning. Incorporating machine learning into this product would enable utility firms
easily shed load as it would be easier to predict energy consumption. Also, anomaly detection
algorithms can also be implemented to detect power theft in a power distribution system when
inconsistent readings are detected.

56
APPENDIX
ARDUINO PROGRAM

#include <ESP8266WiFi.h>

#include <ESP8266HTTPClient.h>

#include <WiFiClient.h>

#include <Filters.h> //This library does a massive work check it's .cpp file

#include <LiquidCrystal_I2C.h>

#define SAMPLES 1000 //Number of samples you want to take everytime you loop

#define ACS_Pin A0 //ACS712 data pin analong input

void(* resetFunc) (void) = 0;

float High_peak, Low_peak; //Variables to measure or calculate

float Amps_Peak_Peak, Amps_RMS;

// Construct an LCD object and pass it the

// I2C address, width (in characters) and

// height (in characters). Depending on the

// Actual device, the IC2 address may change.

LiquidCrystal_I2C lcd(0x27, 16, 2);

#define L_Pin D5

#define Buzz_Pin D6

#define Relay D7

float ACS_Value; //Here we keep the raw data values

float power; // instantaneous power

int i = 1;

float avr_power = 0;

float prev_power = 0;

float inst_energy = 0;

float avr_current = 0;

57
bool sent = false;

unsigned long printPeriod = 1000; // in milliseconds

// Track time in milliseconds since last reading

unsigned long previousMillis = 0;

const char* ssid = "chuka";

const char* password = "hellomama";

const int trigPin = 2; //D4

const int echoPin = 0; //D3

long duration;

int distance;

//Your Domain name with URL path or IP address with path

String serverName = "http://smartvac-api.herokuapp.com";

// the following variables are unsigned longs because the time, measured in

// milliseconds, will quickly become a bigger number than can be stored in an int.

unsigned long prev_mills = 0;

unsigned long lastTime = 0;

// Timer set to 10 minutes (600000)

//unsigned long timerDelay = 600000;

// Set timer to 5 seconds (3000)

unsigned long timerDelay = 60000;

void setup() {

Serial.begin( 9600 ); // Start the serial port

pinMode(ACS_Pin, INPUT); //Define the pin mode

58
pinMode(Relay, OUTPUT);

digitalWrite(Relay, LOW);

pinMode(L_Pin, OUTPUT);

pinMode(Buzz_Pin, OUTPUT);

WiFi.begin(ssid, password);

while (WiFi.status() != WL_CONNECTED) {

delay(500);

Serial.println(WiFi.localIP()

);

lcd.begin(16, 2);

lcd.init();

lcd.backlight(); // Turn on the backlight.

lcd.setCursor(4, 0);

lcd.print("SMART-VAC");

delay(5000);

lcd.clear();

// Turn on the backlight.

void loop() {

if (sent == true) {

sent = false;

while ( true ) {

59
if ((unsigned long)(millis() - previousMillis) >= printPeriod) { //every second we do the calculation

previousMillis = millis(); // update time

int cnt; //Counter

High_peak = 0; //We first assume that our high peak is equal to 0 and low peak is 1024, yes inverted

Low_peak = 1024;

for (cnt = 0 ; cnt < SAMPLES ; cnt++) //everytime a sample (module value) is taken it will go through
test

float ACS_Value = analogRead(ACS_Pin); //We read a single value from the module

if (ACS_Value > High_peak) //If that value is higher than the high peak (at first is 0)

High_peak = ACS_Value; //The high peak will change from 0 to that value found

if (ACS_Value < Low_peak) //If that value is lower than the low peak (at first is 1024)

Low_peak = ACS_Value; //The low peak will change from 1024 to that value found

} //We keep looping until we take all samples and at the end we will have the
high/low peaks values

Amps_Peak_Peak = High_peak - Low_peak; //Calculate the difference

Amps_RMS = Amps_Peak_Peak * 0.042; //Now we have the peak to peak value normally the formula
requires only multiplying times 0.3536

Amps_RMS = Amps_RMS * 0.62435; //but since the values will be very big you
should multiply by 0.06, you can first not use it,

if (Amps_RMS > 0.00 && Amps_RMS <= 0.19) {

Amps_RMS = 0.0; //do your calculations and compare them to real values measured by an Ammeter.
eg: 0.06=Real value/Measured value

Serial.print(Amps_RMS); //Here I show the RMS value and the peak to peak value, you can
print what you want and add the "A" symbol...

Serial.print("\t");
60
Serial.println(Amps_Peak_Peak);

delay(200);

power = Amps_RMS * 208;

if (power > 120)

digitalWrite(Buzz_Pin, HIGH);

digitalWrite(L_Pin, LOW);

delay(500);

digitalWrite(Relay, HIGH);

lcd.clear();

lcd.setCursor(2,0);

lcd.print("OVER LOAD RESET");

lcd.setCursor(0,1);

lcd.print("IN: ");

lcd.setCursor(5,1);

int j;

for (j = 5; j > 0; j--){

lcd.print(j);

delay(1000);}

resetFunc();

else {

digitalWrite(Buzz_Pin, LOW);

digitalWrite(Relay, LOW);

if (power < 120)

digitalWrite(L_Pin, HIGH);

61
}

else {

digitalWrite(L_Pin, LOW);

lcd.clear();

Serial.print( "\t Amps: " );

Serial.println( Amps_RMS );

Serial.print( "\t Power: " );

Serial.println( power );

if (i == 59) {

lcd.setCursor(0, 0);

lcd.print("AV PWR: ");

lcd.print(avr_power);

lcd.print("W");

lcd.setCursor(0, 1);

lcd.print("TOT ENGY: ");

lcd.print(inst_energy);

lcd.print("W");

delay(4000);

else {

lcd.setCursor(0, 0);

lcd.print("Current= ");

lcd.print(Amps_RMS);

lcd.print("A");

62
lcd.setCursor(0, 1);

lcd.print("Power= ");

lcd.print(power);

lcd.print("W");

if (i < 60) {

prev_power = prev_power + power;

i++;

if (i == 60) {

avr_power = (prev_power / 60);

avr_current = avr_power / 220;

inst_energy = ((prev_power / 1000) * ((millis() - prev_mills)) / 1000) / 3600;

prev_power = 0;

prev_mills = millis();

i = 1;

// Send a HTTP POST request depending on timerDelay

if ((millis() - lastTime) > timerDelay) {

sent = true;

//Check WiFi connection status

if (WiFi.status() == WL_CONNECTED) {

WiFiClient client;

HTTPClient http;

String serverPath = serverName + "/data?user_id=1&power=" + avr_power + "&current=" +


avr_current + "&total_power=" + inst_energy;

// Your Domain name with URL path or IP address with path


63
http.begin(client, serverPath.c_str());

// Send HTTP GET request

int httpResponseCode = http.GET();

if (httpResponseCode > 0) {

Serial.print("HTTP Response code: ");

Serial.println(httpResponseCode);

String payload = http.getString();

Serial.println(payload);

else {

Serial.print("Error code: ");

Serial.println(httpResponseCode);

// Free resources

http.end();

else {

Serial.println("WiFi Disconnected");

lastTime = millis();

delay(1000);

64
}

Reading table

• user_id (Serial, primary key)

• timestamp

• current

• total_power

• power

User Table

• id

• username

• email

• password

• min_unit

• total_unit

• used_unit

Payments Table

• date

• unit
65
• amount

• user_id

Mobile Application (Flutter)

Links:

This section contains links to the code in the Github Repository and hosted servers for the
API and database:

1) Smartvac API Github Repository:


https://github.com/SomtochiAma/smartvac-api

2) Smartvac API link:


https://smartvac-api.herokuapp.com/

3) Smartvac Mobile App Github Repository

66
4) Smartvac Mobile Apk [Download]

REFERENCES

[1] L. K. J. W. Y. A. J. N. Ekanayaka J, Smart metering and demand-side integration. In:


Smart grid technology and applications, Chichester: Wiley, 2012.

[2] K. K. Weranga, "Evolution of Electricity Meter, Smary Metering Design and


Applications," 2013.

[3] Wikipedia, "Smart Meter," Wikipedia, 30 05 2020. [Online]. Available:


https://en.wikipedia.org/wiki/Smart_meter. [Accessed 25 07 2021].

[4] A. S. A. O. A. a. A. A O Soyemi, "The Challenges of Estimated Billing on Electricity


Consumers in Nigeria," IOP Conference Series: Earth and Environmental Science, vol.
730, 2020.

[5] Y. Oke, "The challenge of estimated billing," Punch, 4 June 2018. [Online]. Available:
https://punchng.com/the-challenge-of-estimated-billing/. [Accessed 2 August 2020].

67
[6] M. H. &. E.-S. E. F. Albadi, "A summary of demand response in electricity market,"
Electric Power Systems Research, vol. 78, pp. 1989-1996, 2008.

[7] S. L. M. G. &. Y. W. Benqiang Yang, "Smart metering and systems for low-energy,"
Advances in Building Energy Research, pp. 1756-2201, 2017.

[8] D. L. M. A. a. A. K. Milanpreet Kaur, "Implementation of Smart Metering based on


Internet of Things," IOP Conference Series: Materials Science and Engineering, no.
331, 2018.

[9] C. S. J. P. R. S. G. Priyadharshini, "An IOT based smart metering development,"


International Journal of Electrical and Computer Engineering, vol. 9, pp. 3041- 3050,
2019.

[10] G. J. R. D. V. N.Ananth, "Smart Electricity Billing Using Node-MCU," IJSRSET , vol. 6,


no. 2, p. 2019, 2394.

[11] F. B. M. N. B. M. Y. S. A. C. A. Win Adiyansyah Indra, "GSM-Based Smart Energy Meter


with Arduino Uno," International Journal of Applied Engineering Research, vol. 13, no.
6, pp. 3948-3953, 2018.

[12] Shawn, "ACS712 Current Sensor: Features, How it works, Arduino Guide,"
SeedStudio, 2021. [Online]. Available:
https://www.seeedstudio.com/blog/2020/02/15/acs712-current-sensor-features-
how-it-works-arduino-guide/. [Accessed 2 August 2021].

[13] AltexSoft, "What is API: Definition, Specifications, Types, Documentation," AltexSoft,


15 June 2019. [Online]. Available:
https://www.altexsoft.com/blog/engineering/what-is-api-definition-types-
specifications-documentation. . [Accessed 19 March 2021].

[14] D. Garlan and M. Shaw, An Introduction to Software Architecture". Advances in


Software Engineering and Knowledge Engineering, Wiley, 2011.

[15] J. Ullman and J. Widom, A First Course in Database Systems, New York: Prentice-Hall,
1997.

[16] D. C. Tsitchizris and F. H. Lochovsky, Data Models, New-York: Prentice-Hall, 1982.

68
[17] S. Olayinka, "Energy Efficiency and Conservation Measures: Tools," International
Journal of Energy Engineering , vol. 3, no. 2, 2017.

[18] F. M. N. B. M. Y. S. A. C. A. Win Adiyansyah Indra, "GSM-Based Smart Energy Meter


with Arduino Uno," International Journal of Applied Engineering Research, vol. 13, no.
6, pp. 3948- 3953, 2018.

69

You might also like