Updated Smart Home Management System Using IOT Synopsis
Updated Smart Home Management System Using IOT Synopsis
On
SMART HOME MANAGEMENT SYSTEM USING IOT
Submitted By
1
DECLARATION
We declare that,
1. The work contained in this Project Report is original and has been done by us under the
guidance of my supervisor.
2. The work has not been submitted to any other University or Institute for the award of any
other degree or diploma.
3. We have followed the guidelines provided by the University in preparing the Report.
4. We have confirmed to the norms and guidelines in the Ethical Code of Conduct of the
University.
5. Whenever we used materials (data, theoretical analysis, figures, and texts) from other
sources we have given due credit to them by citing them in the text of the report and giving
their details in the references. Further, we have taken permission form the copyright owners
of the sources, whenever necessary.
2
CERTIFICATE
Certified that Pankaj Rawat (2001920310102), Prerna Bhardwaj (2001920310110),
Siddhartha Malik (2001920310156) have carried out the project report entitled "Smart
Home Energy Management System Using IOT" during the Academic session 2022-
23(ODD SEM), Bachelor of Technology in Electronics and Communication Engineering
from Dr A.P.J. Abdul Kalam Technical University (Formerly U.P.T.U), Lucknow. The
project embodies results of the work and studies applied by Student himself and so the
contents of the report don't form the premise for the award of the opposite degree to the
candidate or to anybody else.
Date:
3
ACKNOWLEDGEMENT
We would like to express our deepest gratitude to our HOD Dr. Satyendra Sharma, our
project coordinator Professor Dr. Shivesh Tripathi and our project guide Assistant Professor
Dr. Richa Tiwari for their patient guidance, enthusiastic encouragements and useful
critiques of this research work.
We would also like to thank our Electronics and Communications lab faculty to allow us to
perform various experiments and for guiding us along the way. Particularly we extend our
thanks to Dr. Shivesh Tripathi sir. This project would have been just some words on paper if
it were not for our Institution's competent and technological spirit.
We know that the culture of any institution stems from its leader, hence we would like to
thank our Director Dr. Manas Kumar Mishra for his gracious effort in ensuring quality in
higher education in our college.
G.L. Bajaj Institute of Technology and Management. This project has been a joint effort of
each and every member of the team.
Hence, we would like to thank each other for making this project a reality.
In the end, we thank God almighty for his blessings and him giving us this great opportunity
to learn and grow.
4
TABLE OF CONTENTS
TITLE PAGE
DECLARATION
CERTIFICATE
ACKNOWLEDGEMENT
ABSTRACT
TABLE OF CONTENT
LIST OF FIGURE
CHAPTER 1. INTRODUCTION
1.1 PROBLEM DEFINITION
REFERENCES
5
LIST OF FIGURES
6
ABSTRACT
The growing prevalence of consumer electronics and office equipment contributes
significantly to residential and commercial electricity consumption, accounting for 15 to 20
percent of the total energy usage. However, a substantial portion of this energy is wasted
when devices operate in low-power modes without being actively utilized. To address this
issue, our project introduces a "Smart Home Energy Monitoring and Management
System."The primary objective of this initiative is to design a comprehensive system
capable of tracking the energy consumption of every appliance within a household. Users
will have access to detailed energy consumption parameters for each device. Moreover,
these parameters will be transmitted to a central gateway where an intelligent algorithm
will orchestrate the management of all appliances based on user-defined preferences. The
user interface for this system is an Android Smartphone, enabling users to monitor
individual load energy parameters and serve as a control interface to set various
programmable parameters such as high/low cut-off voltage. A key feature of the system is
its ability to automatically turn off loads when they are not in active use, offering
substantial energy savings in both residential and commercial settings. Potential
applications include workstations, open office cubicles, home offices, and home
entertainment systems. This abstract encapsulates the core functionalities and benefits of
the Smart Home Energy Monitoring and Management System, showcasing its potential to
revolutionize energy efficiency in diverse environments.
In the envisioned system, users are empowered with access to detailed energy consumption
parameters for each individual device. These parameters are seamlessly transmitted to a
central gateway, forming the nerve centre of the operation. At this gateway, an intelligent
algorithm takes charge, orchestrating the management of all connected appliances based on
user-defined preferences. The system's user interface is ingeniously designed as an Android
Smartphone, serving not only as a monitoring tool but also as a dynamic control interface.
Users can leverage the Smartphone to monitor individual load energy parameters and
exercise control by setting various programmable parameters, including high/low cut-off
7
voltage, tailoring the system to their unique energy management needs. The seamless
integration of appliance-level monitoring, data transmission to the central gateway, and the
implementation of an intelligent algorithm is elucidated to underscore the technical
sophistication underpinning the system. By breaking down the intricacies of the system
architecture, users and stakeholders gain insight into the seamless orchestration of
components that collectively contribute to the system's transformative capabilities. Delving
into the user interface aspect reveals the user-friendly nature of the system. The Android
Smartphone interface not only facilitates real-time monitoring but also empowers users to
actively participate in the energy management process. The ability to set programmable
parameters, such as high/low cut-off voltage, adds a layer of customization, ensuring that
the system aligns precisely with individual preferences and requirements. This user-centric
design enhances the accessibility and usability of the system, making it an inclusive and
empowering solution for a diverse user base. The autonomous energy-saving capability is a
focal point in the exploration of the system's features. The mechanism through which the
system automatically powers off devices when not in use is dissected, emphasizing its
potential to yield significant energy savings .The abstract's discussion on potential
applications broadens the scope of the system's impact. Beyond its utility in residential
settings, the Smart Home Energy Monitoring and Management System finds relevance in
diverse environments, including workstations, open office cubicles, home offices, and
home entertainment systems.
8
CHAPTER-1
INTRODUCTION
In the wake of escalating electricity costs and global initiatives to combat climate change by
curbing overall electricity consumption, there has been a surging interest in the meticulous
analysis of power usage within households. The aim is to scrutinize the electricity
consumption of each individual appliance independently, enabling more precise evaluations
of their efficiency and the necessity for potential replacements. This nuanced approach not
only enhances our understanding of how appliances contribute to overall energy consumption
but also empowers users to make informed decisions aimed at reducing electricity usage and
associated costs.
The core premise of this endeavor lies in the recognition that a detailed examination of
individual appliance energy consumption can yield valuable insights. Traditionally,
electricity consumption within a household has been viewed in aggregate, offering a broad
overview of energy usage. However, this conventional approach lacks the granularity
required to identify specific energy-hungry culprits among the myriad of devices in a modern
home. By adopting a more granular approach and dissecting the energy consumption of each
appliance, households can gain a comprehensive understanding of their electricity usage
landscape.
The significance of this granular analysis becomes evident in the evaluation of appliance
efficiency and the need for replacement. Not all devices are created equal in terms of energy
efficiency, and older appliances may consume more power than their modern, energy-
efficient counterparts. By scrutinizing the energy consumption of each appliance, users can
pinpoint outdated or inefficient devices that contribute disproportionately to their electricity
bills. This information becomes a catalyst for informed decision-making, prompting users to
consider replacing energy-draining appliances with more energy-efficient alternatives,
thereby contributing to both cost savings and environmental sustainability.
9
Implementing such a detailed analysis of power consumption aligns seamlessly with the
broader goals of reducing electricity usage. As the world grapples with the impacts of climate
change, there is an increasing emphasis on individual and collective efforts to mitigate
environmental damage. Understanding the energy landscape within households allows for
targeted interventions, encouraging users to adopt energy-efficient practices that contribute to
a collective reduction in carbon footprint.
In practical terms, the journey toward reducing electricity consumption begins with the
deployment of smart energy monitoring systems. These systems, equipped with advanced
sensors and analytics, enable real-time tracking of energy usage at the appliance level. Users
can access detailed reports and visualizations, breaking down energy consumption patterns
and identifying outliers. This level of transparency empowers users to make informed
decisions, fostering a culture of energy-conscious living.
In the wake of escalating electricity costs and global initiatives to combat climate change by
curbing overall electricity consumption, There has been a surging interest in the meticulous
analysis of power usage within households. The aim is to scrutinize the electricity
consumption of each individual appliance independently, enabling more precise evaluations
of their efficiency and the necessity for potential replacements. This nuanced approach not
only enhances our understanding of how appliances contribute to overall energy consumption
but also empowers users to make informed decisions aimed at reducing electricity usage and
associated costs.
The core premise of this endeavor lies in the recognition that a detailed examination of
individual appliance energy consumption can yield valuable insights. Traditionally,
electricity consumption within a household has been viewed in aggregate, offering a broad
overview of energy usage. However, this conventional approach lacks the granularity
required to identify specific energy-hungry culprits among the myriad of devices in a modern
home. By adopting a more granular approach and dissecting the energy consumption of each
appliance, households can gain a comprehensive understanding of their electricity usage
landscape.
10
The significance of this granular analysis becomes evident in the evaluation of appliance
efficiency and the need for replacement. Not all devices are created equal in terms of energy
efficiency, and older appliances may consume more power than their modern, energy-
efficient counterparts. By scrutinizing the energy consumption of each appliance, users can
pinpoint outdated or inefficient devices that contribute disproportionately to their electricity
bills. This information becomes a catalyst for informed decision-making, prompting users to
consider replacing energy-draining appliances with more energy-efficient alternatives,
thereby contributing to both cost savings and environmental sustainability.
In practical terms, the journey toward reducing electricity consumption begins with the
deployment of smart energy monitoring systems. These systems, equipped with advanced
sensors and analytics, enable real-time tracking of energy usage at the appliance level. Users
can access detailed reports and visualizations, breaking down energy consumption patterns
and identifying outliers. This level of transparency empowers users to make informed
decisions, fostering a culture of energy-conscious living.
11
At the heart of this issue is the limited scope of information presented by these conventional
meters. Their focus on real-time usage and available credit, though essential, leaves a void in
understanding broader consumption trends. Users are left without the means to track and
analyze their electricity usage over specific periods, hindering their ability to make informed
decisions about energy conservation and expenditure. This gap in information becomes
especially pronounced in scenarios where users seek to implement targeted strategies for
reducing electricity consumption during certain periods, such as peak hours or high-tariff
times.
Furthermore, the inconvenient placement of these meters exacerbates the challenge. Placed in
locations that are often difficult to access or view regularly, these meters remain out of sight
and out of mind for users. The consequence is a lack of awareness and engagement with real-
time data, as users may find it impractical to check the meter frequently. This spatial
disconnect impedes users from developing a nuanced understanding of their electricity usage
patterns and hinders their ability to proactively manage consumption.
12
CHAPTER-2
A Smart Meter System is required which can analyze multiple appliances in a household
getting readings such as voltage, current, active power, apparent power, reactive power,
power factor and frequency. With the help of a wired / wireless connection, the device can
connect to a central gateway and the gathered information can be uploaded and processed by
the gateway management system. The data can then be displayed on the platform’s
graphical android-based user interface. The platform allows users to access the data from
any android enabled device. To reduce cost the system requires energy metering nodes that
can communicate with the gateway wirelessly or in wired way in such a way that only one
Wi-Fi access point is needed for a household containing many monitored appliances.
Furthermore it is required that the current information regarding the appliances can also be
viewed on a local display with a menu interface. The remote energy metering node will be
considered to be successful if the following criteria are met:
13
If time permits, the following additional features may be added so as to improve the project,
keeping in mind that omission of these features will not affect operation:
• To increase power efficiency of the device and to minimize power usage when appliance is
turned off
Initially, the use of this technology was applied to commercial and industrial customers due
to the need for more sophisticated rates and more granular billing data requirements. The
use of electronic meters came into service to the largest customers of the utility and over
time gradually expanded to all customer classes. This migration was made possible by
decreasing cost of the technology and advanced billing requirements for all customer
classes. The combination of the electronic meters with two-way communications
technology for information, monitor, and control is commonly referred to as Advanced
Metering infrastructure (AMI). Previous systems, which utilized one-way communications
to collect meter data, were referred to as AMR (Automated Meter Reading) Systems. AMI
has developed over time, from its roots as a metering reading substitute(AMR) to today’s
two-way communication and data system.
Although the Smart Meters are relatively new to the utility industry, they are treated with
the same due diligence and scrutiny associated with electronic meters and older
electromechanical counterparts. These meters have always met or exceeded national
standards such as American National Standards Institute (ANSI) C12.1 for meter accuracy
14
and design. In addition, equipment used to certify meter performance must be traceable to
the National Institute of Standards and Technologies (NIST), a federal agency that works
with industry to properly apply technology and measurements. Other standards in use for
the Smart Meter installations include National Electric Code (NEC) for home electrical
wiring, National Electrical Manufacturers Association (NEMA) and Underwriters
Laboratories (UL) for enclosures and devices, and National Electric Safety Code (NESC)
for utility wiring. Through the leadership of utility metering professionals and metering
manufacturers, the meticulous and deliberate development of these solid state electronic
measurement devices has resulted in meter products that have advanced functionality, are
stable and have tighter accuracy tolerances, and are more cost effective for advanced
features than the legacy electro mechanical technologies.
15
The energy node unit has the task of taking power measurements when requested and
sending them then to the gateway. It waits for a request from the gateway via UART (a
wired connection). When a request is received it reads the measurements from the EMIC
and then sends this information back to the gateway.
Gateway Unit
The gateway is responsible for collecting data and then sending it to the android application
interface. It also has a console access that can show all the relevant information along with a
small interface. The requests information from the energy node via wired communication.
The energy node then sends the information back to the gateway. The gateway then
forwards this information on to the android application interface. This process happens in
regular intervals which can be set in the menu interface. Because the gateway and the
energy nodes are separate a single system can comprise of many energy nodes. The
advantage of this is that the cost to monitor another additional appliance is low because only
the energy node needs to be purchased.
An android application is designed which is responsible for reading the gateway for each
energy node connected and is also responsible for setting various gateway configurations
and parameters like various thresholds, etc.
16
CHAPTER-3
Energy Node Design Introduction
The CS5490 from cirrus logic is used as the frontend for the energy measurement. From the
literature review it was clear that an easy way to measure power was to use an EMIC as no
further calculations are needed and nothing else needs to be taken into consideration. An
EMIC only needs to be set up and calibrated and then the registers can be read to get the
relevant information. There were a few EMICs under consideration such as the MCP3903
from microchip. It uses SPI communication with a total of 8 pins dedicated to communication
(SCK, SDO, SDI, CS, Reset and 3 data ready lines).
17
Fig.2. Block Diagram of Proposed Design
The energy node unit is responsible for reading the measurements of the EMIC and relaying
this information once requested from the gateway. The energy node unit is composed of three
main parts – the energy measurement IC itself, the sensing circuit and the isolation circuit.
The energy node was designed in such a way that it can be connected directly to the Base
Station with wires to operate as a standalone system.
3.2 Energy Measurement frontend (EMIC)
The CS5490 from cirrus logic is used as the frontend for the energy measurement. From the
literature review it was clear that an easy way to measure power was to use an EMIC as no
further calculations are needed and nothing else needs to be taken into consideration. An
EMIC only needs to be set up and calibrated and then the registers can be read to get the
relevant information. There were a few EMICs under consideration such as the MCP3903
from microchip. It uses SPI communication with a total of 8 pins dedicated to communication
(SCK, SDO, SDI, CS, Reset and 3 data ready lines). Most EMICs used SPI communication.
However the one logic chip that stood out was the CS5490 from CIRRUS LOGIC. It uses
UART for communication and seems to be more powerful than other EMICs. Some of the
features that this IC has are:
• On-chip Measurements/Calculations:
18
• Low Power Consumption: 13 mW
The CS5490 incorporates independent 4th order Delta-Sigma analog-to-digital converters for
both channel, reference circuitry, and the proven EXL signal processing core to provide
active, reactive, and apparent energy measurement. In addition, RMS and power factor
calculations are available. Calculations are output via a configurable energy pulse, or direct
UART serial access to on-chip registers. Instantaneous current, voltage, and power
measurements are also available over the serial port. The two-wire UART minimizes the cost
of isolation where required.
The CS5940 only requires 3 pins in total Rx,Tx and Reset. EMICs are generally connected to
mains to get the voltage readings and as such there is a need to isolate the IC from the
microprocessor communicating with it. Optocouplers were used in this project to establish an
isolated connection between the gateway (Beaglebone black) and the IC. The optocoupler can
isolate two circuits from each other as it transmits the data using light and it has a light
sensitive transistor all housed in a small package. Conveniently this also operates as a level
shifter as the Beaglebone black operates at 3.3V and some parts at 5V logic and the energy
metering IC only at 3.3V logic solving two problems with one device.
The EMIC does require some circuitry to do the measurements. For Voltage measurement a
voltage divider was used between the two lines and for current measurement a shunt resistor
was used. The IC can take a maximum of 250mV peak to peak on both the voltage
measurement and current measurement inputs so the CT or Shunt Resistor, and voltage
The CS5490 incorporates independent 4th order Delta-Sigma analog-to-digital converters for
both channel, reference circuitry, and the proven EXL signal processing core to provide
active, reactive, and apparent energy measurement. In addition, RMS and power factor
calculations are available. Calculations are output via a configurable energy pulse, or direct
UART serial access to on-chip registers. Instantaneous current, voltage, and power
measurements are also available over the serial port. The two-wire UART minimizes the cost
of isolation where required.
The CS5940 only requires 3 pins in total Rx,Tx and Reset. EMICs are generally connected to
mains to get the voltage readings and as such there is a need to isolate the IC from the
microprocessor communicating with it. Optocouplers were used in this project to establish an
isolated connection between the gateway (Beaglebone black) and the IC. The optocoupler can
isolate two circuits from each other as it transmits the data using light and it has a light
sensitive transistor all housed in a small package. Conveniently this also operates as a level
shifter as the Beaglebone black operates at 3.3V and some parts at 5V logic and the energy
metering IC only at 3.3V logic solving two problems with one device.
19
A configurable digital output provides energy pulses, zero-crossing, energy direction, or
interrupts functions. Interrupts can be generated for a variety of conditions including voltage
sag or swell, over current, and more. On-chip register integrity is assured via checksum and
write protection. The CS5490 is designed to interface to a variety of voltage and current
sensors, including shunt resistors, current transformers, and Rogowski coils.
The EMIC does require some circuitry to do the measurements. For Voltage measurement a
voltage divider was used between the two lines and for current measurement a shunt resistor
was used. The IC can take a maximum of 250mV peak to peak on both the voltage
measurement and current measurement inputs so the CT or Shunt Resistor, and voltage
dividers must be chosen in such a manner that the maximum values will never be reached
otherwise the IC can break dividers must be chosen in such a manner that the maximum
values will never be reached otherwise the IC can break.
A shunt resistor was chosen as it is more stable than a Hall Effect sensor and smaller than a
Current Transformer. The shunt resistor had to be in a range in that if maximum allowable
20
current is drawn from a device the voltage drop over the shunt resistor is less than 250mV
peak to peak as this is the EMICs max current voltage input.
R = 10 mΩ
So a shunt resistor that is smaller equal to 10mΩ will be used here. The EMIC has an
internal adjustable gain of 50x so that a smaller shunt resistor can be used which also has the
benefit of less power dissipation on the resistor.
For a line voltage, Vin = 260 Vrms, and R2 = 1K, R1 can be solved. See Equation below:
To give a 120% margin and to select common resistor values, R1 = 120% * 1.47M =
1.76Mohm resistor is selected. The voltage sense resistor (R2) must be referenced to the
same potential as the current sensor and CS5490 power supply (located either on the Line or
Neutral).
The microprocessor and relay circuit has a logic level of 3.3V and 5V whereas the EMIC
has a 3.3V logic level and as such a level shifter is needed. Furthermore the energy metering
IC is connected to the mains however it has to have the microprocessor chip isolated from
the mains because the noise from the mains can damage the microprocessor and especially
the reliability of the other components. So there is a need for a device that can do both
isolation and level shifting. Fortunately an optocoupler can do precisely this. A light source
in the optocoupler is switched on when a signal is transmitted to it. This light source
activates a transistor connecting both ends on the receiving side. The choice of optocoupler
was mainly due to availability and size. Another important factor was the rise and fall time
of transferring the signal across the optocoupler.
The EMIC is set up to have a default baud rate of 600. Because the baud rate is so low,
optocouplers can be in the microsecond range. The optocoupler for this project was the
21
MCT2E; it has rise and fall times of 3 and 4 us respectively and as such it is acceptable to
communicate reliably at a baud rate of 600. It was also chosen as it was easily available and
had a small package.
Energy meters are part of electricity distribution networks, which measure electricity
consumption. Usage of the energy meter in the electricity distribution network requires the
energy meters to be adaptable to various configurations. This depends on the part of the
22
distribution network and the type of end consumer for which the energy meters are installed.
These configurations include a wide range of voltage and current, across which the meter
should be functional, as per the specifications. The above requirements demand the metering
engine to be adaptable, so that the transducers converting the input signal are selectable,
depending on the specification, while still recording the actual values of the input line signal.
The meter design is comprised of many components, which may vary in their characteristics
due to the various factors across the meter design. The components that form part of the
circuitry include:
• Resistors
• Capacitors
• Inductors
result in offset addition, amplitude alteration and change in signal phase. Considering all the
above factors, the standard value calibration needs to be carried out to achieve meter output.
Calibration is the process where the line parameters are set to known values and the various
signal conditioning parameters such as gain, offset compensation, and phase compensation
factors are calculated.
Calibration is self-contained within the CS5490, and all calculations are performed by the
device and stored in internal registers. Compensations require that the MCU perform some of
the calculations and then store the results back into the CS5490 registers. Since the CS5490
does not have non-volatile memory (NVM), permanent storage of calibration and
compensation must be placed in the MCU NVM and re- loaded after any AFE reset
condition. In general, each calibration and compensation requires the following steps:
• 4. Execute calibration
23
• 7. Store the results in the AFE and NVM
The following procedure outlines the steps required to put the meter in normal operation
mode. Figure 2.3shows a simplified flow chart for the normal operation in the field.
3. Restore the VGAIN and IGAIN registers from the non-volatile memory.
6. If needed, restore the no load compensation to the POFF and QOFF registers from the
NVM.
13. Read IRMS, VRMS, and PAVG. Scale the IRMS, VRMS, and PAVG back into true
value by:
24
2. Full Calibration and Compensation Procedure (Performed Once)
The following procedure shows the steps required to perform calibration and compensation.
A flow chart showing the full calibration procedure is shown in Figure 2.4.
5. Connect the reference line voltage and load current to the meter with a phase angle of 60o
current lagging.
6. If the reference load current is not the full load, set the Scale register to a ratio of 0.6 x
223xreference load current ÷ full scale current. See Non-full-scale Gain Calibration if the
reference line voltage is lower than the maximum line voltage.
9. Read IRMS, VRMS, PAVG, and PF, and confirm the reference voltage and current signals
are correctly attached by verifying if the IRMS, VRMS, PAVG, and PF are in a reasonable
range.
13. If needed, perform phase compensation, AC offset calibration, and power offset
correction.
15. Verify measurement accuracy. Check the setup or fail the meter if the accuracy is not
within specifications.
16. Read VGAIN, IGAIN, IACOFF, POFF, QOFF, PC, and register checksum and save them
into flash/EEPROM.
25
17. Calibration completed.
3. System scaling
Hardware Scale: The CS5490 inputs are scaled using attenuation circuits that apply
maximum input amplitude of 176mVRMS or 35mVRMS, which is dependent on an AFE
gain setting of 10x gain or50 x gain, respectively.
AFE Scale: The AFE registers record input levels that are displayed as a ratio of the most
recent measurement to the maximum RMS voltage and RMS current. The maximum RMS
register value is generated using a 0.6 ratio. The register value is read as a 24-bit hexadecimal
number, which is proportioned to represent a 0.6VRMS full scale. At maximum voltage (0.6)
and maximum current (0.6) the maximum power is PMAX = VRMSMAX × IRMSMAX =
0.6 × 0.6 = 0.36.
MCU Scale: The MCU is required to read all registers and interpret the 24-bit hexadecimal
numbers based on full-load conditions. Knowing the maximum hardware scaling and the
most recent AFE register values in relation to the full-scale input, the MCU routines are able
to calculate the actual power measurements.
26
Fig.5. Gateway Design
The gateway is responsible for collecting data and then sending it to the android application
interface. It also has a console access that can show all the relevant information along with a
small interface. The requests information from the energy node via wired communication.
The energy node then sends the information back to the gateway. The gateway then forwards
this information on to the android application interface. This process happens in regular
intervals which can be set in the menu interface. Because the gateway and the energy nodes
are separate a single system can comprise of many energy nodes. The advantage of this is that
the cost to monitor another additional appliance is low because only the energy node needs to
be purchased.
The application for the gateway is designed completely using C language. The flowchart for
the application is shown in figure enclosed.The application starts with the initialization of the
GPIO pins of the Beaglebone black board using the “sys” file system. The directions of the
GPIO pins are then set to accommodate the functionality used on the pin. For example the
pins at which the relays were connected were chosen as outputs while the pins at which
switches were connected were chosen as inputs.
After the GPIO pins initialization, we open the two serial ports nodes which can be accessed
in the linux file system as “/dev/ttyOx” where x is the UART number. These two serial ports
are the ones at which our energy metering nodes are connected directly using UART. Thus
only after opening these ports, we would be able to access these ports. After then we read the
previous configurations of the serial ports and set a new one to match our EMIC capability.
After successful settings of the serial ports, we load the calibration constants onto our two
EMIC boards and thus initializing the two CS5490 EMICs ready for energy measurements.
After successful loading of the calibration constants, we set a signal handler for emergency
stopping the gateway server application. Here we do all wise deallocation of the resources
like server file descriptors, serial ports and all that we have used in our application.
As gateway is also responsible for storing the meter readings in a database, here we use sqlite
database for storing the reading from the meter in a structured format. After the initialization
of the signal handlers, we open / create the database files for corresponding meters with the
name “METERx” where x is the meter number. If the database file was not there initially, it
is created else it is opened. Now the tables for corresponding month and year are created /
opened with the format “month_year”. For a new month/year, the application automatically
creates the corresponding table in the database.
Now to implement parallelism in the gateway application, we implement three threads
running three different applicational functionalities. Here we initialize three threads. The first
one is the “timer thread” which is responsible for maintaining the reference time delay in the
program for periodic update of the database and user interface for the meter readings. Next
thread “switch polling thread” is responsible for continuous monitoring switches if they are
pressed or not, and thereby executing the corresponding load switching functionality. The
third thread “server thread” is responsible for creating, binding, listening and maintaining a
TCP/IP connection with the android client application for data updation and retrieval.
For the prototype demonstration, we have chosen Beaglebone black, a development board
from Texas Instruments as the gateway processor. It has been equipped with a minimum set
of features to allow the user to experience the power of the processor and is not intended as a
full development platform as many of the features and interfaces supplied by the processor
are not accessible from the BeagleBone Black via onboard support of some interfaces.
27
BeagleBone Black is not a complete product designed to do any particular function. It is a
foundation for experimentation and learning how to program the processor and to access the
peripherals by the creation of your own software and hardware. It also offers access to many
of the interfaces and allows for the use of add-on boards called capes, to add many different
combinations of features. A user may also develop their own board or add their own circuit.
Board features includes:
1. AM335x 1GHz ARM® Cortex-A8
2. 512MB DDR3 RAM
3. 4GB 8-bit eMMC on-board flash storage
4. 3D graphics accelerator
5. NEON floating-point accelerator
Connectivity:
1. USB client for power & communications
2. USB host
3. Ethernet
4. HDMI
5. 2x 46 pin header
Software Compatibility:
1. Debian
2. Android
3. Ubuntu
4. Cloud9 IDE
Introduction
This Application will be responsible for communication from gateway through Wi-Fi. First it
will ask for login and password so that unauthorized user won’t be able to use it. Then it will
send command for specific data as required by user and then it will display the data send by
gateway in different form .There are various Buttons for various types of data to be
28
displayed, on each click a specific command will be sent so that gateway will recognize that
which data to be sent to user from Database. Also there is provision for turning ON and OFF
the meters according to user needs from application. This meter is smart in the sense that we
can set a limit of energy consumption in the application the meter will send that limit to
gateway, gateway will keep track of energy consumption on reaching that limit it will
automatically turn OFF the appliances.
In the above picture we can see that Meter1 is enabled while Meter2 is not, thus we will be
able to use buttons of meter 1 only; Buttons related to meter 2 are disabled to prevent them
from accidental use. Also there are three buttons to send commands for retrieving current
usage data, data usage of previous weeks of current month and previous day data
consumption. There is also a switch for each meter to turn it ON and OFF, this will cause the
appliance to be turned ON/OFF according to our wish. The current usage will be shown on
the same screen and the data that will be shown is Power, Voltage, Current, and Energy. The
other commands will cause data to be displayed on different Activity in form of graphs. At
the bottom the text box is to set limit for monthly consumption, at button below that will
show the Energy consumption of previous month.
For showing data in form of graphs we have used Achartengine library Which we have to
copy in libs folder of project and we have to add its graphical activity in our mainfest file. We
have used Achartengine because it is free, lite and supports various types of graphs.
To send command and receive data we have used Stream Sockets, because in case of UDP
sockets there may be chance that data may be lost which will cause application to behave
abnormally. Data sending and receiving is a time consuming process so for each
communication a thread will be created, Communication will happen in its handler and
results will be published by its runnable in main thread. On close of each thread its socket
will also be closed. We have also used some background images, which needs to be copied
/bin/res/drawable-mdpi folder.
ANDROID WIDGETS USED-
1. TEXT BOXES - To display various messages.
2. EDIT BOXES – To take Input for user.
3. BUTTONS – To perform some action accordingly.
4. SWITCHES – To turn on and off appliances.
5. TOGGLE BUTTONS – To perform action on toggle on/toggle off.
6. RELATIVE LAYOUT – To arrange various widgets on screen.
7. LINEAR LAYOUT – To arrange various widgets on screen.
VARIOUS API & METHODS USED-
1. findViewById
2. onClick
3. onPause
4. onResume
5. onKeyDown
6. onCheckedChange
7. setOnClickListener
8. setOnCheckedChangeListener
9. startActivity
10. putExtra
11. getExtra
12. And many more
29
Mechanisms used
SOCKETS- Sockets are a method of IPC that allow data to be exchanged between
applications, either on the same host (computer) or on different hosts connected by a network.
Sockets exist in a communication domain, which determines:
1. The method of identifying a socket (i.e., the format of a socket “address”)
2. and the range of communication (i.e., either between applications on the same host or
between applications on different hosts connected via a network).
SOCKET TYPES-Are of two types
1. TCP Socket
2. UDP Socket
We have used TCP Socket due to-
TCP Sockets provide a reliable, bidirectional, byte-stream communication channel. By the
terms in this description, we mean the following: Reliable means that we are guaranteed that
either the transmitted data will arrive intact at the receiving application, exactly as it was
transmitted by the sender (assuming that neither the network link nor the receiver crashes), or
that we’ll receive notification of a probable failure in transmission.
Bidirectional means that data may be transmitted in either direction between two sockets.
Byte-stream means that, as with pipes, there is no concept of message boundaries.
THREADS- All the network related task should not be performed in main thread because
then our application will become irresponsive .Thus we should use
1. Asynchronous Task or
2. Threads
We have used here Threads, for each click to perform a network operation a thread will be
created which will be responsible for data transfer. Also for each thread we need to
implement a handler and a runnable method.
HANDLER- Handlers are used to schedule the actions in thread, in broad sense we can say
that it queues the list of actions to be performed. Or to enqueue an action to be performed on
a different thread.
RUNNABLE – These are executed at some point in the future, from a handler we directly
cannot our user interface for that we need runnables.
30
CHAPTER 4
FINAL IMPLEMENTATION
The connections of other parts of the circuit like switches, relays and metering node to the
gateway is shown in figure above.
The load switch1 is responsible for switching ON/OFF load1. A 5v relay is connected in
series of the mains with load1 so that when switch1 is pressed the gateway algorithm senses
the switch press and thus toggle the state of relay1 thus turning ON/OFF the relay. Similarly
load switch2 is responsible for switching ON/OFF load2. A 5v relay is connected in series of
the mains with load2 so that when switch2 is pressed the gateway algorithm senses the switch
press and thus toggle the state of relay2 thus turning ON/OFF the relay.
Two energy metering nodes as described in section 2.2 .The energy metering nodes receives
its isolated power and non-isolate power from the gateway itself. Because the EMIC works in
31
direct connection with the mains power sensing circuitry, so all of its pins are being exposed
to mains current. Thus to make it not harm the gateway circuitry, optoisolator based isolation
circuit is being provided and thus a safe IO connection is made to the gateway. Also the
power supply used to power the EMIC is isolated by utilizing the isolated DC/DC converter
from Texas Instruments.
Both the energy nodes named “METER1” for load1 and “METER2” for load2 are based on
UART and thus are connected to the UART4 and UART2 on the Beaglebone Black
respectively. Both the RXD and TXD pins are galvanically isolated from the mains and thus
the beaglebone circuit is well protected from any mains signal.
Both the meters as well as the load control circuited are powered from the 5v rail of the
beaglebone itself and the beaglebone receives its power from a 5v, 1A regulated DC supply.
The gateway is responsible for collecting data and then sending it to the android application
interface. It also has a console access that can show all the relevant information along with a
small interface. The requests information from the energy node via wired communication as
described above. The energy node then sends the information back to the gateway. The
gateway then forwards this information on to the android application interface. This process
happens in regular intervals which can be set in the menu interface. Because the gateway and
the energy nodes are separate a single system can comprise of many energy nodes. The
advantage of this is that the cost to monitor another additional appliance is low because only
the energy node needs to be purchased.
The CS5490 EMIC provides a two-wire, asynchronous, full-duplex UART port. The CS5490
UART operates in8-bit mode, which transmits a total of 10 bits per byte. Data is transmitted
and received LSB first, with one startbit, eight data bits, and one stop bit.
Fig.8 Flowchart
The baud rate is defined in the SerialCtrl register. Afterchip reset, the default baud rate is 600,
if MCLK is4.096MHz. The baud rate is based on the contents ofbits BR[15:0] in the
SerialCtrl register.
32
Upon power-up, the CS5490 requires an initial register configuration before executing power
measurements. One of the key configurations is adjusting the system scaling for the power
meter application. The key scaling constants are identified through calibration and
compensations performed at the power meter manufacturer. Afterthe configuration and
calibration constants are established, the calibration constants are downloaded during a
normal power-on reset. The application will start conversions and report power and input
performance over time. During power conversions and calculations, the analog inputs are
sampled at 512 kHz, decimated down to 4kHzhigh-rate conversion cycles. The high-rate
samples are averaged to produce a 1 second low-rate power accumulation measurement,
which is used to update registers and, when enabled, generate pulses that represent the power
results (N = 4000, MCLK = 4.096 MHz). The CS5480/84/90 performs signal conditioning
along the digital data path, which improves the accuracy of the power meter measurements.
Signal conditioning is provided in the high-rate path (gain, phase, and DC offset) and in the
lower rate path (no load current RMS offset, AC offset, active and reactive power offset).The
CS5484 full scale RMS register values are commonly reported as 0.6 when the inputs are at a
maximum level.
Now to fetch real time energy data from the energy nodes, the gateway has to follow a
sequence of steps which are described in the section below:
1. Reset the CS5490.
2. Restore configuration and control registers.
3. Restore the VGAIN and IGAIN registers from the non-volatile memory.
4. If needed, restore the offset registers from NVM.
5. If needed, restore the phase compensation registers from the NVM.
6. If needed, restore the no load compensation to the POFF and QOFF registers from the
NVM.
7. Send the single conversion command to the CS5490.
8. Confirm that the register checksum is valid, or return to step 1.
9. Send the continuous conversion command to the CS5490.
10. Enable and clear DRDY.
11. Poll DRDY.
12. If DRDY is set, clear DRDY.
13. Read IRMS, VRMS, and PAVG. Scale the IRMS, VRMS, and PAVG back into true
value by:
Amps = Full_Scale_Current * (IRMS /0.6)
Volts = Full_Scale_Voltage * (VRMS /0.6)
Watts = Full_Scale_Power * (PAVG /0.36)
33
CHAPTER 5
CONCLUSION AND FUTURE WORK
REFERENCES
1] H . Das and L.C. Saikia, "GSM enabled smart energy meter and
automation of home appliances" In the Proceedings of the International
Conference on Energy, Power and Environment: Towards Sustainable
Growth (ICEPE).
35
[5] H. Arasteh, et al., "'IOT-based smart cities: A survey", In the
Proceedings of the IEEE 16th International Conference on Environment
and Electrical Engineering (EEEIC), Florence, Italy.
[6] A Kumat, et al., "Location-Based Routing Protocols for Wireless Sensor Networks: A
Survey", Wireless Sensor Network, Vol. 9 (1), 2017
[7] C. Kaiwen, et al., "An intelligent home appliance control-based on WSN for smart
buildings", In the Proceedings of the IEEE International
Conference on Sustainable Energy Technologies (ICSET), Hanoi,
Vietnam.
[8] M. Zhao, et al. "A Cloud-Based Network Architecture for Big Data
Services" in the Procedings of 2nd International Conference on Big
Data Intelligence and Computing and Cyber Science and Technology.
36