Professional Documents
Culture Documents
ON
SUBMITTED BY
ONYEKWERE SOMTOCHI
AMAUCHE
20151013083(ECE OPTION)
SUBMITTED TO
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
Seminar Supervisor
3
ACKNOWLEDGEMENTS
Special thanks to our supervisor, Engr.Ubbaonu Chinonso F.N for his expert idea
and encouragement throughout this study.
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.
6
LIST OF SYMBOLS AND ABBREVIATIONS
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
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.
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].
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].
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].
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.
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.
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.
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.
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]
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
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.
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
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.
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.
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.
21
A/D Conversion Process and How ADC works?
Mainly there are two steps for the analog to digital conversion:
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.
We keep the switch normally open, and when we want to find a measurement, we close the
switch momentarily.
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.
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:
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.
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
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
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
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
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].
• 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
• 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.
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
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
39
Figure 11: How Application Programming Interface works.
• 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 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]
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.
Endpoints
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.
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.
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.
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.
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
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
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.
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.
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.
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.
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
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.
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
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 L_Pin D5
#define Buzz_Pin D6
#define Relay D7
int i = 1;
float avr_power = 0;
float prev_power = 0;
float inst_energy = 0;
float avr_current = 0;
57
bool sent = false;
long duration;
int distance;
// 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.
void setup() {
58
pinMode(Relay, OUTPUT);
digitalWrite(Relay, LOW);
pinMode(L_Pin, OUTPUT);
pinMode(Buzz_Pin, OUTPUT);
WiFi.begin(ssid, password);
delay(500);
Serial.println(WiFi.localIP()
);
lcd.begin(16, 2);
lcd.init();
lcd.setCursor(4, 0);
lcd.print("SMART-VAC");
delay(5000);
lcd.clear();
void loop() {
if (sent == true) {
sent = false;
while ( true ) {
59
if ((unsigned long)(millis() - previousMillis) >= printPeriod) { //every second we do the calculation
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_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,
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);
digitalWrite(Buzz_Pin, HIGH);
digitalWrite(L_Pin, LOW);
delay(500);
digitalWrite(Relay, HIGH);
lcd.clear();
lcd.setCursor(2,0);
lcd.setCursor(0,1);
lcd.print("IN: ");
lcd.setCursor(5,1);
int j;
lcd.print(j);
delay(1000);}
resetFunc();
else {
digitalWrite(Buzz_Pin, LOW);
digitalWrite(Relay, LOW);
digitalWrite(L_Pin, HIGH);
61
}
else {
digitalWrite(L_Pin, LOW);
lcd.clear();
Serial.println( Amps_RMS );
Serial.println( power );
if (i == 59) {
lcd.setCursor(0, 0);
lcd.print(avr_power);
lcd.print("W");
lcd.setCursor(0, 1);
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) {
i++;
if (i == 60) {
prev_power = 0;
prev_mills = millis();
i = 1;
sent = true;
if (WiFi.status() == WL_CONNECTED) {
WiFiClient client;
HTTPClient http;
if (httpResponseCode > 0) {
Serial.println(httpResponseCode);
Serial.println(payload);
else {
Serial.println(httpResponseCode);
// Free resources
http.end();
else {
Serial.println("WiFi Disconnected");
lastTime = millis();
delay(1000);
64
}
Reading table
• timestamp
• current
• total_power
• power
User Table
• id
• username
• password
• min_unit
• total_unit
• used_unit
Payments Table
• date
• unit
65
• amount
• user_id
Links:
This section contains links to the code in the Github Repository and hosted servers for the
API and database:
66
4) Smartvac Mobile Apk [Download]
REFERENCES
[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.
[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].
[15] J. Ullman and J. Widom, A First Course in Database Systems, New York: Prentice-Hall,
1997.
68
[17] S. Olayinka, "Energy Efficiency and Conservation Measures: Tools," International
Journal of Energy Engineering , vol. 3, no. 2, 2017.
69