Final Thesis Finished

50
Smart Residential Monitoring System By Daithi O’ Brien A project submitted in partial fulfilment of the requirements for the Degree of Bachelor of Engineering in Energy Systems Engineering Supervisor: Prof. Gerard Hurley Co-Supervisor: Dr. Edward Jones Department of Electrical Engineering College of Engineering and Informatics National University of Galway April, 2014

Transcript of Final Thesis Finished

Page 1: Final Thesis Finished

Smart Residential Monitoring System

By

Daithi O’ Brien

A project submitted in partial fulfilment of the requirements for the

Degree of Bachelor of Engineering in Energy Systems Engineering

Supervisor: Prof. Gerard Hurley

Co-Supervisor: Dr. Edward Jones

Department of Electrical Engineering

College of Engineering and Informatics

National University of Galway

April, 2014

Page 2: Final Thesis Finished

Smart Residential Monitoring System

Final Year Electrical Energy Systems Thesis 2014

Page 2

Declaration

The Smart Residential Monitoring System Project has been accepted as a Final Year Project

and completes the requirements for the

Degree of Bachelor of Engineering in Energy Systems Engineering

Project Supervisor:

_________________________________ ______________________ ___ / ___ / ____

(Name) (Signature) (Date)

Project Co- Supervisor:

_________________________________ ______________________ ___ / ___ / ____

(Name) (Signature) (Date)

I declare that this thesis is my original work except where stated

_________________________________ ______________________ ___ / ___ / ____

(Name) (Signature) (Date)

Department of Electrical Engineering

College of Engineering and Informatics

National University of Galway

Page 3: Final Thesis Finished

Smart Residential Monitoring System

Final Year Electrical Energy Systems Thesis 2014

Page 3

Abstract

Smart Grid is the upgrade of the existing electrical grid by modernising the monitoring, control and

communication systems to increase the efficiency of the electrical system. The goal of Smart Grid is

to effectively and efficiently generate, transmit and distribute electricity in the grid.

The Smart aspect of 'Smart Grid' is gaining information about consumer’s electrical usage behaviour

to make real time predictions on the amount of electrical generation needed at a certain time. This

information is important for making the grid as efficient as possible while in turn minimising cost in

generation.

The goal of this project is to make an electrical monitoring system that empowers the consumers to

have a contribution towards reducing and monitoring their own electrical usage. The system has a

smart element to it by enabling it to turn on and off certain loads within the model house based on the

total energy use within the house. This allows consumers to play a part in making the grid more

efficient by starting in their own home.

Page 4: Final Thesis Finished

Smart Residential Monitoring System

Final Year Electrical Energy Systems Thesis 2014

Page 4

Acknowledgements

I would like to take the opportunity to express my gratitude to my parents for giving me the

opportunity to further my education through encouragement and financial support. The

guidance of my FYP supervisor, Prof. Gerard Hurley, and co-supervisor, Dr. Edward Jones,

has kept me motivated to deliver a high quality project through their personal experiences and

knowledge. I am grateful to the University and lecturers for their educational support and

teaching that made me into the potential engineer I am today. My friends and relatives are

also involved in morale support throughout my University experience. Finally, I would like to

acknowledge the technical staff, Martin Burke and Myles Meehan for providing assistance

and in depth knowledge at any moment in the laboratory.

Daithi O’ Brien

Page 5: Final Thesis Finished

Smart Residential Monitoring System

Final Year Electrical Energy Systems Thesis 2014

Page 5

Table of Contents

Declaration ................................................................................................................................. 2

Abstract ...................................................................................................................................... 3

Acknowledgements .................................................................................................................... 4

Table of Figures ......................................................................................................................... 7

Structure of Thesis ..................................................................................................................... 8

Chapter 1: Introduction .............................................................................................................. 9

1.1 Smart Grid ........................................................................................................................ 9

1.1.1 What is Smart Grid? .................................................................................................. 9

1.1.2 Research Paper ........................................................................................................ 10

1.2 Project Introduction ........................................................................................................ 11

1.3 Required Knowledge ...................................................................................................... 11

1.3.1. Hardware ................................................................................................................ 12

1.3.2 Software ................................................................................................................... 12

Chapter 2: Background ............................................................................................................ 13

2.1 Initial Idea ...................................................................................................................... 13

Chapter 3: Methods .................................................................................................................. 14

3.1 Background Description on Components and Software ................................................ 14

3.1.1 Arduino Uno ............................................................................................................ 14

3.1.2 WiFi Shield .............................................................................................................. 16

3.1.3 ACS712 Low Current Sensor Breakout .................................................................. 18

3.1.4 LCD Display ............................................................................................................ 20

3.1.5 WiX ......................................................................................................................... 21

3.1.6 Xively ...................................................................................................................... 22

3.1.7 Layout of the House ................................................................................................ 23

Chapter 4: Description of Design ............................................................................................ 25

4.1 Basic Overview of the Project ........................................................................................ 25

4.2 Current Sensors to Arduino Uno .................................................................................... 26

4.3 Liquid Crystal Display to Arduino ................................................................................. 27

4.4 Layout of Relay switch and Dip switch ......................................................................... 29

4.5 Layout of LEDs .............................................................................................................. 30

4.6 WiFi Shield to Smart Phone ........................................................................................... 32

Page 6: Final Thesis Finished

Smart Residential Monitoring System

Final Year Electrical Energy Systems Thesis 2014

Page 6

4.7 Real time data sent to Xively ......................................................................................... 32

4.8 Overall finished Schematic ............................................................................................ 34

4.9 Full Breakdown of written Code .................................................................................... 35

4.10 Important parts of the Code .......................................................................................... 36

Chapter 5: Energy Audit .......................................................................................................... 38

Chapter 6: Discussion .............................................................................................................. 39

6.1 Future Work ................................................................................................................... 39

6.2 Encountered Problems.................................................................................................... 42

Chapter 7: Conclusion.............................................................................................................. 43

7.1 Overview ........................................................................................................................ 43

7.2 Project Specifications ..................................................................................................... 44

7.3 Achievements ................................................................................................................. 45

References ................................................................................................................................ 46

Appendix .................................................................................................................................. 48

Page 7: Final Thesis Finished

Smart Residential Monitoring System

Final Year Electrical Energy Systems Thesis 2014

Page 7

Table of Figures

FIGURE 1 ARDUINO LOGO [13] ................................................................................................. 12

FIGURE 2 ARDUINO UNO [14] ................................................................................................... 14

FIGURE 3 ARDUINO WIFI SHIELD [15] ...................................................................................... 16

FIGURE 4 ACS712 LOW CURRENT SENSOR BREAKOUT [16] .................................................... 18

FIGURE 5 16 X 2 LCD SCREEN [17]........................................................................................... 20

FIGURE 6 SCREENSHOT OF MY PROJECT WEBSITE .................................................................... 21

FIGURE 7 GRAPHICAL ILLUSTRATION OF A XIVELY REAL TIME FEED ........................................ 22

FIGURE 8 2D FLOOR DESIGN OF THE MODEL HOUSE .................................................................. 23

FIGURE 9 RENDERED 3D DRAWING OF THE MODEL HOUSE ........................................................ 24

FIGURE 10 ACTUAL MODEL HOUSE ........................................................................................... 24

FIGURE 11 BASIC OVERVIEW OF THE PROJECT ......................................................................... 25

FIGURE 12 LAYOUT OF ONE CURRENT SENSOR ........................................................................ 26

FIGURE 13 OVERALL LAYOUT OF FIVE CURRENT SENSORS ....................................................... 27

FIGURE 14 LAYOUT OF LCD TO ARDUINO UNO ........................................................................ 28

FIGURE 15 ACTUAL IMPLEMENTATION OF THE LCD TO ARDUINO UNO ..................................... 28

FIGURE 16 LAYOUT OF RELAY SWITCH AND DIP SWITCH .......................................................... 29

FIGURE 17 ACTUAL IMPLEMENTATION OF THE RELAY AND DIP SWITCH .................................. 29

FIGURE 18 LAYOUT OF LED CIRCUITS ..................................................................................... 31

FIGURE 19 ACTUAL LEDS REPRESENTING THE SCALED DOWN LOADS ...................................... 31

FIGURE 20 ARDUINO CODE TO CONNECT TO THE HOTSPOT ....................................................... 32

FIGURE 21 APPARENT POWER USAGE OVER 5 MINUTES ............................................................ 33

FIGURE 22 APPARENT POWER USAGE OVER 30 MINUTES .......................................................... 33

FIGURE 23 COMPLETE MONITORING CONTROL BOARD ............................................................ 44

Page 8: Final Thesis Finished

Smart Residential Monitoring System

Final Year Electrical Energy Systems Thesis 2014

Page 8

Structure of Thesis

Chapter 1: Introduction: Gives a general overview about the Final Year Project. Gives

examples of hardware and software knowledge required for the

project.

Chapter 2: Background: The initial idea will be discussed in this section. It will talk

about the different ideas that could have happened by the end

of the project.

Chapter 3: Methods: This section goes through each major component by explaining

the background, its use within the project and why it was

chosen in the project.

Chapter 4: Description: Each major circuit will be explained and visual aid will also be

provided of the actual circuit layout.

Chapter 5: Discussion: The future work and problems encountered in the project are

discussed. This will give an overview of future ideas planned if

the project is decided to be taken to the next level and a short

discussion on the problems encountered will also be done.

Chapter 6: Conclusion: Finally the last section will include recommendations to avoid

certain problems or how to approach them differently and also

how successful the project was in terms of functionality and

milestones achieved.

Page 9: Final Thesis Finished

Smart Residential Monitoring System

Final Year Electrical Energy Systems Thesis 2014

Page 9

Chapter 1: Introduction

1.1 Smart Grid

1.1.1 What is Smart Grid?

Smart grid is the modernisation of the existing electrical grid based on digital

technology that can supply electricity to a consumer by two-way communication. Two- way

communication allows the system to monitor usage patterns of consumers in order to

intelligently communicate, control and analyse the generation of electricity. This leads to

greater efficiencies, lower costs and decreased emissions by not generating more electricity

than is needed. [1]

Smart grid has become extremely topical due to its potential to combat the on-going

energy crisis and global warming. Governments are looking to upgrade the current electrical

grids in preparation for the potential rolling out of smart metres. [1]

Heavy loads within in a house can be automated by attaching a smart device. In order

to permit consumers and smart automated devices to react and rapidly adapt to changes in the

grid, such as renewable generation, these smart devices would assist the grid by transferring

real time data over secure home networks. [1]

Smart grid is a very proficient system for renewable sources such as wind. In this

example we look at wind power and ways the grid can adapt. Wind energy has unreliable

generating times due to weather. There might be high wind generation in times of low

demand on the system and low wind generation in times of high electrical demand. The smart

aspect of the automated devices is turning on and off during these times of fluctuations in

wind generation by quickly adapting to consumer needs.

A contemporary fully upgraded smart grid system should have the abilities to do the

following: mend itself to increase the efficiency of the distribution of electricity, give an

incentive for consumers to make a difference and adapting to fluctuations in renewable

generation. Key features of smart grid is advising users to temporarily reduce electrical usage

due to heavy loads on the system and guiding them to use certain loads during low cost

periods. [1]

Ireland would be a perfect example of a country ready to implement a smart grid

system and smart automation of homes. Wind generated 18% of the country’s electricity in

2013 (provisional figure from Eirgrid) [2] and smart grid would efficiently distribute the

power by means of automated devices and electrical storage. Innovation and funding is

necessary to make it possible.

Page 10: Final Thesis Finished

Smart Residential Monitoring System

Final Year Electrical Energy Systems Thesis 2014

Page 10

1.1.2 Research Paper

Research was needed to understand the challenges that faced my project in the real world and

about smart grids with cloud computing in general. This section involves reviewing a paper

on Smart grid with cloud computing as part of my research for my final year project.

Summary of the Paper:

This paper was written in response to the increased CO2 emissions produced by

electrical generation. According to the authors’ sources [3], almost half of emissions

produced are from the production of electricity. This paper examines the possibility of using

smart grid and cloud computing to combat this problem. The authors also believe that

improved management of energy generation, transmission and supply can lead the way for

the integration of smart grid with the traditional power grid. Smart Grid is now being

considered due to utility companies being forced to change from conventional electrical grid

because of increased costs of traditional fossil fuels, such as oil, and the customer’s/public’s

concern of climate change. The technological advances in the cloud computing is also

making smart grid a reality by allowing the management of constant flow of data from

producer to customer and being able to store this data.

Smart Grid is a fascinating idea as presented in this paper in a descriptive and

interesting manner, but as with all great ideas, Smart Grid comes with its own difficulties in

reality. These difficulties are discussed in length from security issues to the transport and

storage of customer data. [3] Reading this paper makes one realise that the time for change

from traditional methods of fossil fuel electrical production, transmission and distribution

must happen sooner rather than later. Therefore I have orientated my project around changing

the residential sector, from traditional manual methods of control to smart automated

methods, which in itself is a feature of smart grid.

Page 11: Final Thesis Finished

Smart Residential Monitoring System

Final Year Electrical Energy Systems Thesis 2014

Page 11

1.2 Project Introduction

The intention of this project is to innovate and simulate/demo a model house that uses smart

controlling to reduce the electrical consumption of a consumer in real time by monitoring the

usage of heavy loads within a household. The main objective is to research and implement a

micro controller monitoring system capable of delivering the goal of the project.

There were four main elements to this project. Firstly, a model house was constructed to

represent scaled down version of a real house. Secondly, LEDs with a high wattage were

used to represent a 1:10 scale of heavy electrical loads within a house. Thirdly, an arduino

with a WiFi shield was used to retrieve the real time apparent power consumption of a model

house from the current sensors and then send this information to a Xively server. Fourthly, it

was necessary to get this information and represent it graphically on a laptop and smart

phone.

1.3 Required Knowledge

The final year project requires the utilization of knowledge previously learned from prior

projects, such as hardware and to learn new aspects, such as coding. The knowledge varied

from hardware to software as both were equally as important in completing this project.

The following fields that were focused on in this project are; arduino coding skills, internet

interface design, troubleshooting, model designing, calibrating current sensors and finally

internet connection between the arduino and the Xively real time feed.

Page 12: Final Thesis Finished

Smart Residential Monitoring System

Final Year Electrical Energy Systems Thesis 2014

Page 12

1.3.1. Hardware

The hardware needed in this project was an arduino microcontroller with a WiFi shield

attached to it. The arduino would read in and interpret the information being sent by the

current sensors. The arduino would send this real time information to an online server using

the WiFi shield. The wooden model house would also be part of the hardware aspect of the

project.

1.3.2 Software

The arduino has an open-source programming environment that makes it easy to write and

upload code to the I/O board. [4] An I/O board is a single board module that has multiple

inputs and outputs but no built-in operating system. An arduino sketch pad programme is

necessary to begin writing code and is downloadable from the arduino website. The sketch

pad and the arduino programme are written and developed using Java. Once the Java

operated sketch pad is downloaded from the arduino website and the code, based on functions

of C/C++, is written then it is possible to upload it to the arduino board. For this project, the

‘arduino-1.0.4’ sketch pad version was downloaded for a Windows operated laptop.

Figure 1 Arduino Logo [13]

Page 13: Final Thesis Finished

Smart Residential Monitoring System

Final Year Electrical Energy Systems Thesis 2014

Page 13

Chapter 2: Background

2.1 Initial Idea

The inital project was to look at monitoring different aspects of residential usage. This was

looking at both electricity and water. As the project progressed, the project changed from just

monitoring electricity and water usage to implementing a ‘smart’ feature to only the electrical

usage. This sequentially lead to a title change to ‘Smart Residential Monitoring System’.

The inital plan was to design an phone application to display the real time data but the

website and server service ‘Xively’ was found. This gave extra time to complete the project

and have a functioning model for the demonstration day.

The goal of enabling householders to reduce electrical uasge and costs was taken into

consideration throughout the entire poroject. Each ‘smart’ automated decison making feature

of this project was completed with this goal in mind.

The final element of the project that was included in the intial design was battery stroage. The

plan was to investigate the type of batteries capable of storing electrical power. As mentioned

later in this project, the radiators and immersion turn on/off based on the electrical usage

within the household, but battery charging was also meant to be a feature. A decision was

made not to include battery storage in the final design due to time restrictions of the project.

The following thesis shows the design route and process taken in this project.

Page 14: Final Thesis Finished

Smart Residential Monitoring System

Final Year Electrical Energy Systems Thesis 2014

Page 14

Chapter 3: Methods

3.1 Background Description on Components and Software

3.1.1 Arduino Uno

Background:

The arduino uno is a single-board microcontroller developed by Arduino. In order to make

difficult design and applications far more usable, the arduino uno is an open sourced

hardware component. It comprises of a 32-bit Atmel ARM chip and an Atmel 8-bit AVR

microcontroller. [4] The hardware interface consists of 14 digital I/O pins, 6 analog input

pins, reset button to restart the running of the code and a USB connection used to power the

arduino and transfer code from the laptop. The software section of the arduino is as

applicable and approachable as the hardware. The arduino runs on open-source software

called an Integrated Development Environment (IDE) written in Java and it is free to

download. [4] Code written is called a ‘sketch’ and these sketches are written in C or C++.

[4] The ‘sketch’ is uploaded to the arduino using the USB cable connected to the laptop.

When a component like the arduino uses different computing languages, it is referred to as a

Cross-platform operating system.

Figure 2 Arduino Uno [14]

Page 15: Final Thesis Finished

Smart Residential Monitoring System

Final Year Electrical Energy Systems Thesis 2014

Page 15

Use within the project

The arduino was used as the main component within the project. It was the hub of the entire

project as the sensing, display and communicating components were all controlled by the

arduino.

Why use the arduino uno

As discussed, the Arduino uno has a cross-platform and open-sourced software which enables

it to run on several operating systems including Windows, Linux and Macintosh. The arduino

is not limited on the operating system the user uses on his/her laptop like most other

microcontrollers. [5]

The component has an extremely attractive and inexpensive price tag that works for a student

budget.

The arduino is very versatile and different ‘shields’ can be attached to the arduino enabling to

perform additional actions, such as a WiFi, Bluetooth and others. During the initial design

phase this was very important as the shields were capable of doing many different actions

which in turn broadened the potential uses.

The arduino is easy to begin programming with as a beginner. It took two weeks to learn the

coding aspect of the arduino. In the later stages of the project, as it became more complex, the

code was also capable of becoming more complex. The flexibility between basic and

advanced coding extends the possibilities of further applications with the arduino in this

project. [5]

Page 16: Final Thesis Finished

Smart Residential Monitoring System

Final Year Electrical Energy Systems Thesis 2014

Page 16

3.1.2 WiFi Shield

Background:

The Arduino WiFi shield is an attachment to the Arduino which gave the component the

capability of connecting to the internet wirelessly. On the hardware side, the shield contains

an 802.11 wireless specification, an on-board micro-SD card, 14 digital pins, 6 analog pins, 4

informational LEDs and a Micro-USB connection. The WiFi shield can send real time

information onto the network but the addition of the on-board micro-SD card slot can also

store information before sending it over the network. The arduino can only store limited

amount information on the flash memory before it is deleted but the Micro-SD enables the

user to look at stored information over a longer period of time based on the storage capacity

of the SD card. The Micro-USB connection is not used for powering or programming the

arduino and WiFi shield, instead it is used for updating the software on the shield which may

be necessary depending on the issue of the shield. [6] There are a 4 informational LEDs,

yellow means that there is a connection in pin 9, green means the WiFi is connected a

network, red means the shield is incapable of connecting to a network and there is an error

and finally blue shows there is data is being sent over the network from the arduino. [6]

The basic code to enable the WiFi shield to connect to the internet was readily available

online. The code was then altered to fit the intended project. The code was simple to modify

for the chosen network connection.

Figure 3 Arduino WiFi Shield [15]

Page 17: Final Thesis Finished

Smart Residential Monitoring System

Final Year Electrical Energy Systems Thesis 2014

Page 17

Use within the project

The WiFi shield was invaluable for making this project a ‘smart monitoring system’. The

monitoring system was not confined to viewing the information in a home. Instead real time

information could be viewed anywhere with internet access. This gave the project a modern

edge to it for an ever increasing technology-based world. The arduino read in real time data

and used the WiFi attachment to upload this data to Xively.

Why use the WiFi Shield

The WiFi shield did not interfere with the performance of the arduino. Even with an

additional component attachment to the arduino and extra functions, both worked without any

issue.

Having the shield on the arduino does not reduce the capabilities of the original Uno. All

digital and analog pins are still usable and this was important as the Liquid Crystal Display

and current sensors still needed to be connected to these pins.

The additional informational LEDs are useful to know if the code is not working or the shield

is running into difficulties. There is no need to look at the laptop code to realise that

something is wrong.

It is not necessary to have an individual USB connection going into the shield as it is

powered by the arduino uno. This reduced the need for two USB ports being used on the

laptop and additional cables in the making of the project.

The SD card slot gave the option to store information on the shield as well as sending real

time information online. Even though it was not taken advantage of in this project, it is an

option for future work to store information and graph a long term usage pattern rather than

only in real time as it is done in this project.

Page 18: Final Thesis Finished

Smart Residential Monitoring System

Final Year Electrical Energy Systems Thesis 2014

Page 18

3.1.3 ACS712 Low Current Sensor Breakout

Background:

The ACS712 current sensor is a mini board that can read current in an AC and DC circuit. It

is capable of reading current up to 5 amps. The sensor is based on Hall Effect sensing. A

small chip called the AC712 has a copper conduction path that is positioned close to the

surface. [7] When current runs through the AC712 chip it creates a magnetic field which is

sensed by the added Hall IC and converted into proportional voltage. [7] The Hall IC splits

the 5V input connection of 5 volts into -2.5 volts and +2.5 volts. When current is applied, the

ACS712 chip makes the voltage disproportional and the current is calculated from the

deflection in voltage. The IP+ and IP- are connections for cables from the power source to

the LEDs. The Vref is used to calibrate the proportionality of the input voltage 5V. This

should be preferably in the centre to divide the 5 volts as +2.5 volts and -2.5 volts. There is

also an opamp gain in this circuit to increase the sensitivity of the current measurements.

There is a 5 volts and ground connection to the arduino. The V0 port is connected to the

analog pins in the arduino so that the voltage deflection can be detected.

Figure 4 ACS712 Low Current Sensor Breakout [16]

Page 19: Final Thesis Finished

Smart Residential Monitoring System

Final Year Electrical Energy Systems Thesis 2014

Page 19

Use within the project

The current sensor was used to detect the current within the system. There were five current

sensors in the system to read the major loads within the house. Each sensor was assigned at

least two loads within the house, e.g. a fridge and a freezer. The read in current was needed

to calculate the apparent power within the model house. All five current sensors were

calibrated to work together and send information to the arduino. The accuracy required from

the sensors was crucial as too much noise would have made it very difficult to set high and

low thresholds in the code. The thresholds were needed to turn on and off loads based on the

applied current.

Why use the ACS712 Low Current Sensors

The apparent power usage for each load in the model house, needed to be calculated by

getting the real time current usage and multiplying it by the apparent voltage of 230 volts.

This particular sensor is extremely sensitive when calibrated correctly. The data sheet [8]

shows its sensitivity as 185mV/A. The sensitivity was an issue with this project as the LEDs

were dealing with milliamps so the low current sensors were a perfect fit to this project once

calibrated to the required sensitivity.

The sensors were relatively cheap to buy so there was no issue purchasing five current

sensors to increase the sensitivity of the system in general. The sensitivity of the system was

achieved by allocating two loads per sensor, hence the requirement of five current sensors.

The arduino and the sensor were compatible with one another both with hardware and

software. There was a requirement of three connections between the sensor and the arduino.

The code involved figuring out a formula which calculated current as an output.

Page 20: Final Thesis Finished

Smart Residential Monitoring System

Final Year Electrical Energy Systems Thesis 2014

Page 20

3.1.4 LCD Display

Background:

This is a 16 characters wide by 2 row sized Liquid Crystal Display with black text and a

green background. It has sixteen pins in total attached to the LCD, eleven of which are I/O

pins and the other five pins are voltage supply and ground. The eleven pins are connected to

either the digital or ground pins on the arduino. The remaining other five pins are connected

to the ground and the 5 volt supply of the microcontroller. There is an option of having a

backlight on with this component but in this project there was no particular use for it. The

LCD screen is compatible with the arduino and uses the same code to produce characters on

the screen.

Figure 5 16 x 2 LCD Screen [17]

Use within the project

The LCD screen was used to display real time information of the apparent power that was

running in the model system on the first line of the screen. The second line of the screen

showed if the radiators and immersion were on/off at that particular time based on the

apparent power usage in the model house. It was a useful component to display quick relative

information to the user rather than connecting a laptop to the arduino to see the same

information.

Page 21: Final Thesis Finished

Smart Residential Monitoring System

Final Year Electrical Energy Systems Thesis 2014

Page 21

3.1.5 WiX

Background:

WiX is a free website development platform which enables the user to produce a website

page online. The website has HTML5 capabilities, hosts your website on the web and has

many readymade templates for the user to avail of. [9] HTML 5 is a hyper text markup

language for websites. The company prides itself on being a very secure host for web pages

created through its web developing platform. WiX also provides an opportunity to produce a

webpage for both desktop viewing and also mobile viewing.

Figure 6 Screenshot of my Project Website

Link to the Project Website: http://dotzer105.wix.com/srms

Use within the project

WiX was used to give an overview of the project to other people interested in smart

monitoring. Figure 6 shows the home page of the website. Here there are links to the NUIG

homepage, NUIG engineering page, the project supervisor and co-supervisor. Along the tab,

there are additional pages in the website that show details of each major component used,

videos and the code along with it. There is a Xively feed which shows real time information

from the model house. Finally there is a ‘Let’s Talk’ feature that allows web visitors e-mail

the web page owner with anything related to the project.

Page 22: Final Thesis Finished

Smart Residential Monitoring System

Final Year Electrical Energy Systems Thesis 2014

Page 22

3.1.6 Xively

Background:

Xively is a public cloud service which enables a user to connect devices to it. [10]It is a free

service and requires an account to be setup. Once the account is created, the user is given an

‘API key’ and a ‘feed key’. An ‘API’ stands for ‘application programming interface’. [11]

The general overview of an API is that it enables different applications to talk to one another.

But the API Key enables the devices to interact with each other without giving out the

account password. [11] In this project the two devices being, the arduino and the Xively

server. The ‘feed key’ is a 32 bit unique feed url key for a registered account.[12] In this

project the feed key is written into the code of the arduino to send information from the

servers to a particular registered account, which is my Xively account. The account can now

retrieve the information stored on the Xively servers as it has the API key and the feed key.

The information is then illustrated, as shown below in figure 7, in graphs over a period of

time.

Figure 7 Graphical illustration of a Xively real time feed

Use within the project

In the case of this project, apparent power is being read in by the arduino and with the WiFi

shield, the data is sent to the Xively servers, which is the ‘Xively public cloud’.[10]The

information is extracted from the servers and graphically displayed showing the time, date

and apparent power.

Page 23: Final Thesis Finished

Smart Residential Monitoring System

Final Year Electrical Energy Systems Thesis 2014

Page 23

3.1.7 Layout of the House

The model house was built out of timber and was designed from an online application called

Floor Planner. Floor Planner is a free application that allows a user to design a house in 2D,

as shown below in figure 8, with easy to use software. Once the rooms are all measured,

designed and completed, there is an option to do a 3D rendering of the 2D plan shown below

in figure 9.

This particular design consisted of a kitchen, two bathrooms, two bedrooms, sitting room, hot

press and a utility room.

Figure 8 2D floor design of the model house

Kitchen

Sitting Room

Master Bedroom

Utility Room

Hotpress Bedroom Bathroom

Bathroom

Page 24: Final Thesis Finished

Smart Residential Monitoring System

Final Year Electrical Energy Systems Thesis 2014

Page 24

Figure 9 Rendered 3D drawing of the model house

Figure 9 and 10 are a design and actual build of the model house. The loads in the model

house are as follows;

Kitchen: Fridge, Oven, Radiator, Dishwasher

Utility Room: Washing Machine, Clothes Dryer

Bathrooms: Radiator

Hot press: Immersion

Sitting Room: Radiator

Bedroom: Radiator

Figure 10 Actual model house

Page 25: Final Thesis Finished

Smart Residential Monitoring System

Final Year Electrical Energy Systems Thesis 2014

Page 25

Chapter 4: Description of Design

4.1 Basic Overview of the Project

Figure 11 Basic Overview of the Project

Figure 11 shows a brief statement of each major step in the project. Firstly the current from

the LEDs are read in by current sensors and the arduino uno gathers this information. The

real time data is sent to Xively through the WiFi shield on a connected network. As the data

is being sent over the network, similar information is displayed on the LCD screen. The

screen displays the apparent power in the system and the status of whether the radiators and

immersion are on/off. On Xively the data from the arduino is illustrated on graphs.

Each circuit was created and designed using software called Fritzing. Similar to the arduino

hardware and software, Fritzing is an open-sourced circuit design program. The program has

many pre-loaded components, such as the arduino, copper strip boards, etc. This was

excellent software to assist in the description of the project.

•Reads current from LEDs which are the different loads

of a house.

•Reads the current from the sensors.

•Puts the real time data on Xively through WiFi shield

•Shows information on LCD screen.

•Visually shows real time

data in graphs.

•The graph shows apparent power within the model

house

Page 26: Final Thesis Finished

Smart Residential Monitoring System

Final Year Electrical Energy Systems Thesis 2014

Page 26

These diagrams are visual aids for any persons interested in using any components applied in

this project. Every connection in this project is illustrated below either through Fritzing

circuit design or by a picture of the actual connection.

4.2 Current Sensors to Arduino Uno

Current

Sensor

Pins Goes to

V0 Analog Pin in the Arduino

5V 5 volt pin in the Arduino

GND GND in the Arduino

IP+ Power Supply

IP- Dip or Relay Switch

Table 1 Pin layout of Current Sensors to Arduino Uno

Table 1 shows the pins on the current sensors and its connections. The V0 pin is represented

as a brown wire, 5V and GND are shown as a red and black wire respectively. The V0, 5V

and GND are all connect to the arduino uno. The IP+ is a yellow wire connected to the power

supply. The set voltage and current was applied through this connection. The IP- is a blue

connection to the relay and dip switch. The layout of a single current sensor is shown in

figure 12, followed by the layout of all five sensors relative to the arduino uno in figure 13.

Figure 12 Layout of One Current Sensor

Page 27: Final Thesis Finished

Smart Residential Monitoring System

Final Year Electrical Energy Systems Thesis 2014

Page 27

Figure 13 Overall Layout of five current sensors

4.3 Liquid Crystal Display to Arduino

The following table 2 is the LCD pin destinations to the arduino uno

LCD

Pins Goes to

1 GND in the Arduino

2 5 volt pin in the Arduino

3 Middle of 10k Potentiometer

4 Digital pin 8 in Arduino

5 GND in the Arduino

6 Digital pin 9 in Arduino

7 GND in the Arduino

8 GND in the Arduino

9 GND in the Arduino

10 GND in the Arduino

11 Digital pin 5 in Arduino

12 Digital pin 4 in Arduino

13 Digital pin 3 in Arduino

14 Digital pin 2 in Arduino

15 5 volt pin in the Arduino

16 GND in the Arduino

Table 2 Pin layout of the LCD to Arduino Uno

Page 28: Final Thesis Finished

Smart Residential Monitoring System

Final Year Electrical Energy Systems Thesis 2014

Page 28

In figure 14, it provides a connection overview of the LCD to arduino in a visual manner. The

ground is shown as black wires, 5 volts are red wires and the green wires represent the

connection to the digital pins of the arduino. The 10k potentiometer is used to regulate the

voltage going to the LCD screen. It provides protection to prevent excess voltage or current

damaging the LCD. Figure 15 provides a photo of the finished connections from the LCD to

the arduino uno.

Figure 14 Layout of LCD to Arduino Uno

Figure 15 Actual implementation of the LCD to arduino uno

Page 29: Final Thesis Finished

Smart Residential Monitoring System

Final Year Electrical Energy Systems Thesis 2014

Page 29

4.4 Layout of Relay switch and Dip switch

The relay switch is connected to two current sensors and the dip switch is either connected to

the relay or the other three sensors. The dip switch is a basic on/off switch that can manually

turn/off the loads within the model house. The sensor has two outputs and inputs. There is

also a connection to the 5 volt and digital pin 6. When the 5volts is applied to the relay

switch, it is allows the current to flow from the current sensors to the dip switch. When the

relay allows current to flow, it is considered to be in a LOW state. When current is blocked

by the relay switch, it is in a HIGH state and there is no 5 volts flowing in the relay. The

LOW and HIGH state is controlled by the arduino uno and is written in the code.

Figure 16 Layout of Relay switch and Dip switch

Figure 17 Actual implementation of the Relay and Dip Switch

Page 30: Final Thesis Finished

Smart Residential Monitoring System

Final Year Electrical Energy Systems Thesis 2014

Page 30

4.5 Layout of LEDs

Each LED had a power rating of 0.5 watts. The voltage rating of the LEDs are 3.65 volts with

a current rating of 0.2 amps. Ohms law was used to calculate the required resistor for the

circuit.

Even though a resistor of 18.25 was calculated, a 47 resistor was chosen to increase the

protection of LEDs because of the cost to replace them and was recommended to choose a

resistor of this size by the lab technicians. The bigger resistor did not impede on the

effectiveness of the LEDs.

Table 3 shows the breakdown of the loads modelled in this project. The actual power rating

of the appliances is divided by 10. The figure is then divided by the power rating of the LEDs

which is 0.5 watts. Quantity of LEDs column is the required amount to model the power

ratings of the appliances.

Actual Power Rating

(W) Ratio

Quantity of

LEDs

Total Power Rating of LEDS

(W)

Immersion 3000 10:01 6 3

Dishwasher 1500 10:01 3 1.5

Clothes Dryer 4500 10:01 9 4.5

Washing Machine 500 10:01 1 0.5

Oven 2500 10:01 5 2.5

Fridge 500 10:01 1 0.5

Radiator 500 10:01 1 0.5

Table 3 Breakdown of actual appliances ratioed to LED

Page 31: Final Thesis Finished

Smart Residential Monitoring System

Final Year Electrical Energy Systems Thesis 2014

Page 31

When the quantity of LEDs is calculated for each load, they are soldered onto a copper strip

board. As shown in figure 18, the LEDs are soldered in parallel with the red wire powering

the circuit and the black wire going to ground. Figure 19 shows the actual layout of the

soldered circuits connected to the current sensors.

Figure 18 Layout of LED Circuits

Figure 19 Actual LEDs representing the scaled down loads

Page 32: Final Thesis Finished

Smart Residential Monitoring System

Final Year Electrical Energy Systems Thesis 2014

Page 32

4.6 WiFi Shield to Smart Phone

The WiFi shield was connected to the phone using arduino code to access the open network

hotspot. The hotspot was created by going into the setting of the phone and enabling internet

sharing. The password was then disabled for the WiFi shield to connect. When the connection

was established between the two devices, data was transferred from the arduino uno to

Xively. The model house was moved very frequently for demonstrations during the open day

and around rooms in the university, therefore the portability of the smart phone as an internet

hotspot was very important. The full code for connecting the WiFi shield is shown below in

the appendix section but figure 20 shows the arduino connecting to the hotspot named

‘Daithi’.

Figure 20 Arduino code to connect to the Hotspot

4.7 Real time data sent to Xively

This was a key feature in this project, as one of the milestones required in this project was an

internet interface to display real time data. After the connection between the WiFi shield and

the hotspot was established, the arduino began sending all the read in and calculated data to a

Xively server using the account API key. The information was stored on the servers until the

Feed key retrieved the information from the server and onto a web page. The Web page

illustrated data on graphs as shown in figures 21 and 22. The Xively functions are explained

above in the methods section of this report.

Page 33: Final Thesis Finished

Smart Residential Monitoring System

Final Year Electrical Energy Systems Thesis 2014

Page 33

Figure 21 Apparent Power Usage over 5 minutes

In both figure 21 and 22, real time information is graphed with the value of apparent power

on the y-axis and time across the x-axis. When the cursor is hovered over parts of the graph it

shows the exact apparent power at that moment, along with a time it was registered at, as

shown in figure 22.

Figure 22 Apparent Power Usage over 30 minutes

Page 34: Final Thesis Finished

Smart Residential Monitoring System

Final Year Electrical Energy Systems Thesis 2014

Page 34

4.8 Overall finished Schematic

Page 35: Final Thesis Finished

Smart Residential Monitoring System

Final Year Electrical Energy Systems Thesis 2014

Page 35

4.9 Full Breakdown of written Code

Program is uploaded

and ready

Open required

libraries

Define and set

variables

Connect to the Network using WiFi

Shield

Link the arduino to

Xively server

Read in Current and multiply by apparent voltage of 230 Volts

Is the Apparent

Power over

210 V.A

YES NO

Turn off Radiators and Immersion

Turn on Radiators and Immersion

Display on LCD Screen and send real time information to

Xively

Page 36: Final Thesis Finished

Smart Residential Monitoring System

Final Year Electrical Energy Systems Thesis 2014

Page 36

4.10 Important parts of the Code

The above code shows the calculation of the current by the arduino uno. The anologRead

function reads in the data from the current sensors. The formula is as follows to convert the

data from the sensors to current;

(((((((2494 - readings[index]) * 5 / 1024 / 0.04 - 0.04) / 20) * 100) * 230) / 1000) ;

The reading [index] is the raw data read in by the arduino uno when there is NO applied

current. This raw data value is 2494; this is subtracted to bring the value with no current

passed through the sensors as 0. The reading [index] value is then multiplied by a formula

that took two weeks to compile through trial and error, *5 / 1024 / 0.04 - 0.04) / 20. The

figure produced from the formula so far is the amps running through the model. Multiplying

the milliamps by 100 converts the modelled milliamps to amps as if the real appliances are

being monitored. This is then multiplied by 230 volts for apparent power.

Page 37: Final Thesis Finished

Smart Residential Monitoring System

Final Year Electrical Energy Systems Thesis 2014

Page 37

The above code shows the two ‘if’ statements that control the turning on/off of the modelled

loads in the house. The code is commented but to reiterate what is above, if the apparent

power was lower than 210 VA, the radiators and immersion would turn on. If it was above

230 VA the radiators would turn off. The on/off function was controlled by changing the

status of the relay switch to HIGH or LOW. The ‘lcd.print’ function displayed all of the

information on the LCD screen.

Page 38: Final Thesis Finished

Smart Residential Monitoring System

Final Year Electrical Energy Systems Thesis 2014

Page 38

Chapter 5: Energy Audit

Quantity Energy

Rating

Total

Wattage

Hours a

day

Days per

Week

kWh

Per Day

kWh per

Week

Sitting Room

Radiator 1 500

Watts 500 3 4 1.5 6

Bathrooms 2

Radiator 1 500

Watts 500 3 4 1.5 6

Hot press

Immersion 1 3000

Watts 3000 4 4 12 48

Bedrooms 2

Radiator 2 500

Watts 1000 3 4 3 12

Utility Room 1

Washing

Machine 1

500

Watts 500 1.5 2 0.75 1.5

Clothes Dryer 1 4500

Watts 4500 1.2 2 5.4 10.8

Kitchen 1

Dishwasher 1 1500

Watts 1500 1 4 1.5 6

Fridge/freezer 1 500

Watts 500 8 7 4 28

Radiator 1 500

Watts 500 3 4 1.5 6

Oven 1 2500

Watts 2500 1.5 7 3.75 26.25

Total 34.9 150.55

The above table shows an Energy Audit of the model house based on the loads modelled and

the hours they would typical be turned on and used for during a week.

Page 39: Final Thesis Finished

Smart Residential Monitoring System

Final Year Electrical Energy Systems Thesis 2014

Page 39

Chapter 6: Discussion

6.1 Future Work

Actual House

The completion and success of this project on a model scale has encouraged future work on

an actual house. Over the coming months, I will implement similar control and monitoring of

loads in my home. The future work mentioned below will also be put into practice in the

future once the current modelled system performed in this final year project is installed. Once

installed, other controls, calibrations, software, hardware and settings can be added to make a

commercially viable product.

Central Hub System

The current project is monitoring a model home with an arduino. Realistically an arduino will

not suffice to accommodate the large volume of data processing required of a real house.

Instead a component such as the Intel Galileo or the Raspberry Pi would act as a central hub

system with arduinos acting as sensor modules for computing different measurements

throughout the house. The arduinos will communicate with the central hub system which will

be far more powerful to communicate with all of the sensors, display information to the user

and also regulate and manage the settings mentioned below.

Immersion

At the moment the immersion will only turn on/off depending on the power consumption in

the house. In reality, the immersion will not turn on/off depending on power consumption

because during certain times in day and night the immersion will turn on due to low usage.

This will be uneconomical and a waste of resources. Therefore there would be a thermostat

placed in the water tank to calculate the temperature of the water. Once the temperature goes

above a threshold of 60 degrees, the immersion will not turn off. If the water tank goes below

30 degrees, when the usage is low, the immersion will turn on. It is an additional threshold

and constraint to make the system more viable in an actual house rather than a model.

Page 40: Final Thesis Finished

Smart Residential Monitoring System

Final Year Electrical Energy Systems Thesis 2014

Page 40

Radiators

Similar to the immersion, the radiators need further constraints and thresholds. At the

moment the radiators are on the same system as the immersion, turning on/off during low

usage times. This will make living conditions uncomfortable as the heating will be on most of

the time. For future work, this could be fixed by placing thermometers into each room and

gathering temperature readings in the house. The temperature in each room can control the

radiators. In this case, the radiators will only turn on if the room goes below 15 degrees and

turn off when it goes above 22 degrees.

Manual Control

This feature will allow the user to set the thresholds and conditions within their home. An

input box would appear on a touch screen monitor, allowing the user to set the temperature

for each room and the boiler. The user can calibrate the house to his/her liking based on their

personal preferences. This is particularly useful for when the house is vacant for a few days

and it is not necessary to have rooms as warm as 22 degrees, instead the user can set the

temperatures in the room lower until they are back. This will in turn save money and

eliminate the waste of energy.

Location Based Control

Predictive control enables the monitoring system to determine when certain loads should be

turned on/off in the house by knowing the location of the residents. If the user is late arriving

home from work, the monitoring system can locate the user via smart phone or car GPS and

decide to turn on/off certain applications within in the house. For example, as discussed

above, the manual control system can decrease energy usage in the house by lowering

temperature thresholds for the radiators. However, if the system could also monitor the

location of the occupant and make a decision based on the distance from the house, it could

possibly be programmed to turn on radiators or other loads within the house.

Page 41: Final Thesis Finished

Smart Residential Monitoring System

Final Year Electrical Energy Systems Thesis 2014

Page 41

Predictive Control

This is an extra automated control similar to the location based idea. The monitoring system

can memorise the actions of the user, for example arriving late home every Tuesday, the

system will automate itself to turn on/off loads in the house in a predictive manner. It is also

useful for taking in weather forecasts and informing the user to set the temperatures of the

rooms higher or lower depending on the forecast. Predictive control can be used by energy

companies to learn human behaviour to optimise energy generation and distribution. A

subsidy or discount could be offered to the user from the energy company in exchange for

behavioural patterns.

Remote Access

Remote access would allow the system to be calibrated and changed outside of the house.

The manual control only enabled the user to adjust the setting with an input box on a

monitoring screen, as mentioned above. This future work would permit the householder to

remotely view and access real time power usage and temperatures within the house via

mobile or tablet app. The manual settings can be changed remotely also based on the user’s

interpretation of the real time data. Remotely controlling ones home could be an attractive

feature for those that work and travel a great deal.

Water Monitoring

Water monitoring will be a major concern for the future as water charges will begin to roll

out in the near future. Therefore managing water usage will be an issue for residents. It will

be impractical for the occupant to go outside and open up a manhole cover to look at their

water meter. Instead an automated water meter with communication with the monitoring

system could send continuous real time usage information for the user to view his/her water

consumption. This solution would be far more practical than the current method of looking in

a manhole.

Page 42: Final Thesis Finished

Smart Residential Monitoring System

Final Year Electrical Energy Systems Thesis 2014

Page 42

6.2 Encountered Problems

Current Sensors

The current sensors were the biggest problem in the project overall. It was very difficult to

calibrate them to a sufficient sensitivity to deal with the milliamp readings from the LEDs

and also to stabilise the current readings. The current sensors’ readings were jumping from

-30% to +30% of the actual current running through. This was far too inaccurate and needed

two to three weeks of calibration to stabilise the readings to -1% to +1%. This was resolved

by adjusting the code on the arduino. The gain on the ACS712 current senor board was

adjusted to remove the insensitivity of the sensors.

WiFi Shield

The WiFi shield was a problem to use within the university. The requirements to log into the

WiFi in the university were the name of the network, student ID and password. The WiFi

shield can only access WiFi hotspots that only have the name of the network and password.

This would ideally work in a house as the name of the WiFi and the password is the only

necessity. This problem was solved by using a smart phone as an open network hotspot. The

shield connected to the open network hotspot provided by the smart phone without any

difficulty.

LCD Screen

The LCD screen was somewhat difficult to code. The basic code was manageable as it was

readily available online. However, when changing the code to fit the requirements of

displaying real time information within the model, it became difficult. This was overcome by

perseverance and learning the background code to LCDs.

Page 43: Final Thesis Finished

Smart Residential Monitoring System

Final Year Electrical Energy Systems Thesis 2014

Page 43

Chapter 7: Conclusion

7.1 Overview

I have given an introduction to smart grid and referred to a research paper about smart grid

with cloud computing. This gave me background to my idea for doing an energy monitoring

system within a residential home and displaying real time information online using cloud

computing.

This is followed by describing my up to date completed project idea and some background on

the initial idea of the project. This gives a good overview of the progression of the project and

shows what was achievable from the initial idea to the current idea based on research and

construction time.

The methods section lists the software and hardware required to complete this project. A brief

background description on the composition of each component is discussed. This is followed

by the use of the component and why it was used for this project.

The description of design section goes through the steps of designing and building the circuits

created. It shows Fritzing drawings and pictures of completed soldered circuits as a visual aid

for other persons attempting to build a similar project. A description of each major step is

provided ranging from connecting current sensors to the arduino right up to a completed

schematic of the project.

The applications for future proofing the project have been outlined above in the future work

section. There are many different ways to approach improvements for this project. Usage

monitoring and smart control is a relatively untapped opportunity in the residential sector.

This project is aimed to improving the current behavioural issues that go with waste energy

by making people aware of the savings financially and environmentally.

Page 44: Final Thesis Finished

Smart Residential Monitoring System

Final Year Electrical Energy Systems Thesis 2014

Page 44

7.2 Project Specifications

Goal 1: General overview of smart grids contexts

Communication protocols

Goal 2: Design an example system

Monitoring networks and tariffs

Goal 3: Basic operating system

Internet Interface

System decision making

Goal 4: Hardware Implementation with samples

Goal 5: Fully operating system with decision making

The drawn up project specification sheet at the start of the semester was adhered to closely.

All of the milestones were completed in the project. The objective of the project was to have

a fully operational hardware model system capable of communicating real time information

online with an integrated ‘smart’ element. The final result was indeed a fully operational

system for the bench demonstration.

Figure 23 Complete Monitoring Control Board

Page 45: Final Thesis Finished

Smart Residential Monitoring System

Final Year Electrical Energy Systems Thesis 2014

Page 45

7.3 Achievements

This project has been a massive success in achieving a new set of skills and a new idea with a

different approach. The following personal skills were achieved with this project;

Using tools to complete the project such as soldering components on copper strip

boards, has enhanced my hardware skills.

Improved organisational skills by ordering components in time and completing

deadlines.

Improved knowledge of C/C++ due to coding the arduino.

Better understanding of smart grid and all its limitations and potential.

Renewed knowledge of writing a technical report

The model house is an achievement in its own right and was very successful in illustrating

that it is indeed capable of ‘smart metering’ and decision making based on constraints set by

the user. It has shown that it is possible to take this final year project to the next level with

funding. The basic operating and communicating protocols between hardware, software and

the internet interface is completed. This is a crucial stepping stone in furthering research into

this area.

For further information on the software or hardware on any aspects of the project, visit my

website to watch videos of the model working at;

http://dotzer105.wix.com/srms

Page 46: Final Thesis Finished

Smart Residential Monitoring System

Final Year Electrical Energy Systems Thesis 2014

Page 46

References

Text

[1] Jansson, C. (2014) ‘Smart Grid’ [online], available: Techopedia:

http://www.techopedia.com/definition/692/smart-grid [accessed 8th April 2014].

[2] IWEA (2014) ‘Wind Statistics’, Wind Energy Statistics [online], available: The Irish

Wind Energy Association: http://www.iwea.com/_windenergy_onshore [accessed 6th

April 2014].

[3] Markovic, D.S., Zivkovic, D., Branovic, I., Popovic, R., Cvekovic, D. (2013) ‘Smart

Power Grid and Cloud Computing’, Renewable and Sustainable Energy Reviews, 24,

available: http://www.sciencedirect.com/science/article/pii/S136403211300227X

[accessed 18th November 2013].

[4] Wikipedia (2014) ‘Arduino’, available: http://en.wikipedia.org/wiki/Arduino

[accessed 10th April 2014].

[5] Arduino (2014) ‘Why Arduino?’, [online], available:

http://arduino.cc/en/Guide/Introduction [accessed 8th April 2014].

[6] Arduino (2014) ‘Arduino WiFi Shield’, [online], available:

http://arduino.cc/en/Main/ArduinoWiFiShield [accessed 3rd

April 2014].

[7] Allegro (2014) ‘ACS712: Fully Integrated, Hall-Effect-Based Linear Current Sensor

IC with 2.1 kVRMS Voltage Isolation and a Low-Resistance Current Conductor’,

[online], available: http://www.allegromicro.com/en/Products/Current-Sensor-

ICs/Zero-To-Fifty-Amp-Integrated-Conductor-Sensor-ICs/ACS712.aspx [accessed

10th March 2014].

[8] Allegro MicroSystems, Inc. (2007) ‘Fully Integrated, Hall Effect-Based Linear

Current Sensor with 2.1 kVRMS Voltage Isolation and a Low-Resistance Current

Conductor’, [online], available:

https://www.sparkfun.com/datasheets/BreakoutBoards/0712.pdf [accessed 25th

February 2014].

Page 47: Final Thesis Finished

Smart Residential Monitoring System

Final Year Electrical Energy Systems Thesis 2014

Page 47

[9] WiX (2014) ‘About Us’, [online], available: http://www.wix.com/about/us [accessed

19th March 2014].

[10] Xively (2014) ‘Xively is the Public Cloud specifically built for the Internet of Things’, [online],

available: https://xively.com/whats_xively/ [accessed 3rd March 2014].

[11] Mailchimp (2014) ‘Support’, [online], available:

http://kb.mailchimp.com/article/where-can-i-find-my-api-key/#API [accessed

1st April 2014].

[12] Wordpress (2014) ‘Plugin Directory’, [online], available:

http://wordpress.org/plugins/feed-key/ [accessed 1st April 2014].

Images

[13] imgarcade (2014) ‘Arduino Logo’, [online image], available:

http://imgarcade.com/1/arduino-logo/ [accessed 9th

April 2014].

[14] Liquidware Corp. (2014) ‘Arduino Uno’, [online image], available:

http://www.liquidware.com/shop/show/ARD-UNO/Arduino+Uno [accessed 9th

April

2014].

[15] Gotronic (2010) ‘Module Arduino WiFi Shield’, [online image], available:

http://www.gotronic.fr/art-module-arduino-wifi-shield-18744.htm [accessed 11th

April 2014].

[16] astanadigital (2014) ‘LOW CURRENT SENSOR BREAKOUT ACS712’, [online

image], available: http://www.astanadigital.com/current/118-low-current-sensor-

breakout-acs712-.html [accessed 10th April 2014].

[17] Riecktron (2014) ‘LCD 16x2 Character - Black on Green’, [online image], available:

https://www.riecktron.co.za/en/product/108 [accessed 8th April 2014]

Page 48: Final Thesis Finished

Smart Residential Monitoring System

Final Year Electrical Energy Systems Thesis 2014

Page 48

Appendix

Full Arduino Code:

#include <SPI.h> //SPI Library

#include <WiFi.h> // Arduino Wifi Library

#include <HttpClient.h> //Xively Server Library

#include <Xively.h> //Xively Library

#include <LiquidCrystal.h> //Liquid Crystal Library

const int numReadings = 30;

float readings[numReadings]; // the readings from the analog input

int index = 0; // the index of the current reading

float total = 0; // the running total

float average = 0; // the average

float currentValue = 0; // the set value

#define RELAY4 6 //relay switch attached to digital pin 6

char ssid[] = "Daithi"; // your network SSID (name)

int status = WL_IDLE_STATUS; //wifi status

// Your Xively key to let you upload data

char xivelyKey[] = "rxEjJQH7gJHJoJWbNfc1FNyzCZ0wAl63FiA2HdkhvBJHUP8G";

// Define the strings for our datastream IDs

char sensorId[] = "Apparent_Power_VA";

XivelyDatastream datastreams[] = {

XivelyDatastream(sensorId, strlen(sensorId), DATASTREAM_FLOAT),

};

// Finally, wrap the datastreams into a feed

XivelyFeed feed(307581958, datastreams, 1 /* number of datastreams */);

WiFiClient client;

XivelyClient xivelyclient(client);

void printWifiStatus() {

IPAddress ip = WiFi.localIP();

long rssi = WiFi.RSSI();

}

Page 49: Final Thesis Finished

Smart Residential Monitoring System

Final Year Electrical Energy Systems Thesis 2014

Page 49

LiquidCrystal lcd(8, 9, 5, 4, 3, 2); // initialize the library with the numbers of the interface pins

void setup() {

lcd.begin(16,2); // columns, rows. size of display

lcd.clear(); // clear the screen

pinMode(RELAY4, OUTPUT);//initialise relay4 (pin6) to open and close relay switch

Serial.begin(9600);

for (int thisReading = 0; thisReading < numReadings; thisReading++)

readings[thisReading] = 0;

while ( status != WL_CONNECTED) {

Serial.println(ssid);

status = WiFi.begin(ssid);

}

Serial.println("Connected to wifi"); //print ln when wifi is connected

printWifiStatus();

}

void loop()

{

total = total - readings[index];

readings[index] = analogRead(1) + analogRead(2) + analogRead(3) + analogRead(4) +

analogRead(5); //Raw data reading from current sensors

readings[index] = (((((((2494 - readings[index]) * 5 / 1024 / 0.04 - 0.04) / 20) * 100) * 230) / 1000));

//Data processing:2494-raw data from analog,5-5v; the first 0.04-0.04V/A(sensitivity); the second

0.04-offset val;

total = total + readings[index];

index = index + 1;

//Smoothing algorithm (http://www.arduino.cc/en/Tutorial/Smoothing)

if (index >= numReadings)

index = 0;

average = total / numReadings; //Smoothing algorithm

(http://www.arduino.cc/en/Tutorial/Smoothing)

currentValue = average;

//

lcd.setCursor(16,1); // set the cursor outside the display count

lcd.print(" "); // print empty character

delay(600); //delay

Page 50: Final Thesis Finished

Smart Residential Monitoring System

Final Year Electrical Energy Systems Thesis 2014

Page 50

if (currentValue < 210) //if the calculated VA is below 210 then turns ON Relays 4

{

digitalWrite(RELAY4,LOW); // output a low and close the relay switch

lcd.setCursor(1,1); // set the cursor at 1st col and 2nd row

lcd.print("Rads & Hot on!"); // print that the rads and immersion is on

}

if (currentValue > 230)//if the calculated VA is above 230 then turns OFF Relays 4

{

digitalWrite(RELAY4,HIGH); // output a high and open the relay switch

lcd.setCursor(1,1); // set the cursor at 1st col and 2nd row

lcd.print("Rads & Hot off");// print that the rads and immersion is off

}

datastreams[0].setFloat(currentValue); // set the VA data as a data stream to xively

if (currentValue > 0) //if current power is greater than 0

{

datastreams[0].setFloat(currentValue); // send the information to xively from current sensors

lcd.setCursor(1,0); //On the first line on LCD Screen

lcd.print ("App Pwr: "); // print App Pwr on LCD Screen

lcd.print(currentValue); //print VA next to App Power on LCD Screen

}

if (currentValue < 0)//if current power is less than 0

{

datastreams[0].setFloat(0); // send the information to xively as just 0

lcd.setCursor(1,0); //On the first line on LCD Screen

lcd.print ("App Pwr: "); // print App Pwr on LCD Screen

lcd.print(0.00);//print VA next to App Power on LCD Screen

}

int ret = xivelyclient.put(feed, xivelyKey); //telling xively to retrieve the data from the server sent by

the arduino

}