You are on page 1of 74

Design of a Smart Power Monitoring & Management System

By

Khaled Haddad, Leen Lababidi & Rand AL Mdanat

Supervised by

Dr. Ayman Faza

Submitted in partial fulfillment of the requirements for the degree of

BACHELOR OF SCIENCE
in

Electrical Power and Energy Department

at

PRINCESS SUMAYA UNIVERSITY FOR TECHNOLOGY

Amman, Jordan

First Semester 2016/2017


This is to certify that I have examined

This copy of an engineering documentation by

Khaled Haddad, Leen Lababidi & Rand AL Mdanat

And have found that it is complete and satisfactory in all respect,


And that any and all revisions required by the final Examining Committee have been made

Dr .Ayman Faza

II
Acknowledgments

Acknowledgments

Our humble gratitude and deep regards are expressed towards everyone who supported us
during this journey, to our families and friends, whom we dedicate this document to. A profound
sense of gratitude goes to our supervisor Dr. Ayman Faza for his guidance, mentorship and
motivation.

A much obliged thank you goes to Eng. Saddam Ratrout and to Eng. Mahmoud Al-Fares for
their valuable information and continuous assistance during all parts of developing the project.

Extended thanks to our colleague Maram Tuffaha for her great insights and useful directions
that assisted in emerging and developing the project.

A strong appreciation is passed to our faculty, Princess Sumaya University for Technology for its
role in building our personalities, and to the department of Electrical Engineering and all of our
professors for our academic knowledge.

Last but not least, vast gratitude to Almighty God for enlightening our minds and continuous
protection to make this project see the light.

III
Abstract

Abstract

This project introduces a smart home model, software and hardware driven, for monitoring
and managing the home appliances. It aims to optimize the energy usage in addition to minimizing
wasted energy. The system consists of models representing the power consumption of some of the
most commonly used household appliances (HAs), sensors to track the real-time behavior of the
HAs, a software controlled switching scheme, and a unique energy management algorithm that
controls (turns on/off) the appliances based on their preset priorities and a maximum allowed
power consumption. The system operates in real time, has a fast response time, and keeps the
power consumption of the house below 4kW at all times.

Since the domestic sector in Jordan accounts for nearly 43% of electric energy use [1] ,
optimizing energy usage and providing flexible high level energy control solutions represent a
social vision in that sector. This design significantly reduces the amount of power consumption,
eliminates wasted energy, reduces the electricity bills and if used on a wide level, prevents blackouts.

IV
Table of Contents

Table of Contents
1 Introduction .............................................................................................................................................. 1

1.1 The need of a smart home power monitoring and management system ................................ 1

1.2 Design requirements and realistic constraints ............................................................................. 2

1.2.1 Design requirements: .................................................................................................................. 2

1.2.2 Realistic constraints: .................................................................................................................... 3

1.3 Work deviation:................................................................................................................................ 4

1.4 Design achieved: .............................................................................................................................. 5

1.5 Document organization: ................................................................................................................. 7

2 Background and Literature Review ....................................................................................................... 8

2.1 Literature review: ............................................................................................................................. 8

2.1.1 Contribution to previous work................................................................................................10

2.2 Background of technologies used ...............................................................................................11

3 Design ......................................................................................................................................................14

3.1 Design requirements: ....................................................................................................................14

3.2 Analysis of design requirements and realistic constraints:.......................................................14

3.2.1 Analysis of design requirements: .............................................................................................14

3.2.2 Analysis of realistic constraints:...............................................................................................15

3.3 Different design approaches ........................................................................................................17

3.3.1 System simulation model..........................................................................................................17

3.3.2 Software and hardware driven system model: .......................................................................18

3.4 Developed design: .........................................................................................................................24

3.4.1 Chosen appliances .....................................................................................................................26

3.4.2 Hardware design: .......................................................................................................................28

3.4.3 Software design ..........................................................................................................................37

V
Table of Contents

3.5 Meeting Design Requirements and Realistic Constraints: .......................................................42

3.5.1 Design Requirements: ...............................................................................................................42

3.5.2 Realistic Constraints: .................................................................................................................42

4 Results......................................................................................................................................................45

4.1 Prototype setup ..............................................................................................................................45

4.2 Experiment setup ..........................................................................................................................45

4.3 Experiment results discussion .....................................................................................................47

4.4 Validation of requirements and constraints ...............................................................................52

4.4.1 Design Requirements: ...............................................................................................................52

4.4.2 Realistic constraints: ..................................................................................................................52

5 Conclusion and Future Work...............................................................................................................55

6 References ...............................................................................................................................................56

7 Appendices..............................................................................................................................................58

7.1 Appendix A ....................................................................................................................................58

7.2 Appendix B:....................................................................................................................................66

VI
List of Figures

List of Figures
Figure ‎1.1: General system procedure ........................................................................................................... 2
Figure ‎1.2: General flowchart of the system control algorithm ................................................................ 6
Figure ‎2.1: Arduino mega controller ...........................................................................................................12
Figure ‎2.2 : ACS712, 5A module .................................................................................................................12
Figure ‎2.3 : 8-Channel relay module ............................................................................................................13
Figure ‎3.1: Design criteria .............................................................................................................................17
Figure ‎3.2: Brief description .........................................................................................................................24
Figure ‎3.3: Design procedure .......................................................................................................................25
Figure ‎3.4: Single HA connection schematic .............................................................................................33
Figure ‎3.5: Final design schematic ...............................................................................................................36
Figure ‎3.6 : Current sensor calibration equation graph for 0.2<x<0.6 ..................................................38
Figure ‎3.7 : Current sensor calibration equation graph for 0.6<x<2 .....................................................39
Figure ‎3.8 : Current sensor calibration for x>2 .........................................................................................39
Figure ‎3.9: Flow chart of the system ...........................................................................................................41
Figure ‎4.1: The final smart system results ..................................................................................................47
Figure ‎4.2: Serial port readings .....................................................................................................................48
Figure ‎4.3: Time taken to turn off ...............................................................................................................52
Figure ‎7.1: Final design of the system .........................................................................................................66

VII
List of Tables

List of Tables
Table ‎1.1: The division of labor among the team members ...................................................................... 4
Table ‎2.1: Arduino specification [27] ..........................................................................................................11
Table ‎3.1: Design requirments .....................................................................................................................14
Table ‎3.2 : HA's classification ......................................................................................................................20
Table ‎3.3: Modeling calculation results .......................................................................................................22
Table ‎3.4: Chosen appliances, their type and the consumed power [11] ...............................................27
Table ‎3.5 : Summary for all modeling calculations....................................................................................32
Table ‎3.6: 8-Channel relay module specifications .....................................................................................34
Table ‎3.7: Current sensor calibration data ..................................................................................................37
Table ‎4.1: The scope of experimenting the smart power monitorng and management system .........46
Table ‎4.2: Power measuring system experimenting ..................................................................................48
Table ‎4.3: Smart power monitoring and management system experimenting ......................................49

VIII
Introduction

1 Introduction
1.1 The need of a smart home power monitoring and management system

Day by day, electrical energy is getting more essential as a life need for humans. Energy is also
becoming an important infrastructure for a country's economy growth and stability. But the amount
of power demand in many countries is much greater than the supplied amount. Electrical energy can
be obtained by burning fossil fuels, or by renewable energy systems (i.e. wind energy, solar energy...)
Most of the electrical energy, especially in our region, is currently obtained from burning fossil fuels.
These resources are not renewable as their consumption rate is a much higher than their
regeneration rate so the world might be out of them relatively soon. Furthermore, these fuels are
non-environmentally friendly and burning them in these huge quantities produce massive amounts
of gases causing pollution, ozone layer depletion, acid rain and climate changes.

Nowadays, the consumption of electrical energy has significantly increased. A major cause of this is
due to the increase in the electrical appliances consumption profile in modern residences. This case
could be depicted by considering a couple of neighborhood houses connected to the same
distribution transformer, and each of them is consuming excessive power compared to their normal
consumption profile. As a result, the distribution transformer can potentially become overloaded. In
general, this phenomena leads to the increase in the risk of blackouts, this obliges utility companies
to generate enough energy to assure electrical service continuity and stability. Generating more
electrical power means burning more fossil fuels, leading to fewer resources for the future
generations and more environmental damages. Organizations and governments worldwide are
calling for preserving the planet, and since the engineering profession has a reaching impact on
societies and environments, it is a professional responsibility and a duty to find smart solutions to
avoid any harm to the environment and the climate in a clever way that satisfies human needs as
well.

From this perspective, the idea of a smart home monitoring and management system prospered. In
this project, a design of a smart system is proposed, which will have the ability of controlling power
consumption of home appliances and keeping the consumed power below a certain limit. Since the
domestic and residential high power consumption contributes to a big share of the total power
consumption, reducing and controlling houses' power consumptions will directly link to saving and

1
Introduction

improving the environment. In addition, from a consumer point of view, major electricity bills
financial savings are possible.

The proposed system will constantly monitor the power consumption of all the HAs in real time
with a fast response time. It will turn off and on some of the appliances in order not to exceed the
desired maximum limit of the consumed power. The system will not disturb the user's daily life as
the HAs switching and control will be according to preset user priorities.

1.2 Design requirements and realistic constraints

For the purpose of this problem, there are some requirements to be achieved. As shown in Figure
1.1.

Control

Analyze

Sense

Figure ‎1.1: General system procedure

1.2.1 Design requirements:

 The system design should be able to monitor the power consumption of all house appliances in
real time, and to turn on and off some or all of the appliances.
 Power requirement: The system must keep the power consumption of the house below a
certain level.
 Real time requirements: In order for the system to function properly and achieve its desired
goal, the response time in case of power increase must be very fast.

2
Introduction

1.2.2 Realistic constraints:

 Economic: The budget for this project should not exceed 200JDs, and this fund was provided
by the Electrical Engineering department of Princess Sumaya University for Technology.

 Environmental: Single phase induction motors will be used to represent some of the home
appliances, and these motors cause high disturbing noises.

 Ethical:
A. Power consumption patterns of individual appliances can easily be determined from the
nameplates of the appliances, but some important electrical parameters such as the current and
the power factor could not be found as such information is kept confidential by manufacturing
companies.
B. Power consumption patterns and values of individual houses are private information of the
customer; such information should be kept confidential.
C. Codes and algorithms used for connectivity purposes of sensors and basic devices in the design
should be referenced, and the credit go to the author as stated in legal legislation polices.

 Safety: 220 Volts 50 Hertz voltage is being used to operate the HAs, and high currents passing
through the loads are being dealt with in the measuring and control processes. Also the wiring in
the system is complex and the electrical insulation in components is not secure so the work
contained a high probability of danger. Other safety hazards were expected with the progress of
the design.

 Manufacturability:
A. The complexity of wiring, due to the presence of many wires and two voltage-different systems.
B. The hall effect: current sensor, explained in section 2.2, the current has low sensitivity as it was
found that it cannot read small currents under 100mA.
C. The hall effect current sensor can be affected by any flux from other devices around it, which
may cause errors, signal noise and hence incorrect or inaccurate readings.

3
Introduction

1.3 Work deviation:

Table 1.1 summaries the division of labor among the team members:

Table ‎1.1: The division of labor among the team members

TASK Team Members

Extensive general research Khaled, Leen & Rand


Home appliances selection Khaled, Leen & Rand

Appliances electrical parameters determinations Khaled, Leen & Rand


Appliances priorities ranking determinations Leen & Rand

Appliances models design Khaled, Leen & Rand

Appliances design calculations Rand


Design of current sensors hardware circuitry Khaled & Rand

Design of current sensors software algorithm Leen

Currents sensors calibration Khaled


Design of the 8-channel relay hardware circuitry Khaled

Design of the theoretical control algorithm Rand

Design of the software control algorithm Khaled, Leen & Rand

Design of the system timer software function Khaled & Leen


Current sensor , 8-channel relay and models testing Khaled, Leen & Rand

Single appliance circuit hardware testing Khaled & Leen

Circuit Construction and Assembly Khaled & Rand


Overall hardware circuit test Khaled, Leen & Rand

Overall software system testing Khaled, Leen & Rand


Design of the final system layout Leen & Rand

Literature review and background Leen

Documentation Khaled, Leen & Rand

4
Introduction

1.4 Design achieved:


The aim of this project is to design a system that monitors the power consumption of all the HAs in
real time, and is capable of turning ON/OFF some or all of the appliances to keep the power
consumption in the house below a certain level. The system must operate in real time, must have a
fast response time, and must keep the power consumption below certain levels at all times.

In order to monitor power consumption, an ACS712 current sensor [8] was used to measure and
sense the currents for the home appliances. The hall effect current sensor can sense the flux
produced by the current passing through it, and converts it to millivolts output signal, this analog
signal is input to the analog pin in the Arduino controller board module which converts it into a
digital signal, and this signal will be interpreted by the code to find the current value. After
measuring the current, the electrical power consumption can be easily found as the entire home
appliances are connected to a 220 V rms and their power factors are already predetermined. The
ON/OFF switching process is achieved by using an eight-channel relay module which consists of
eight relays in a single model, circuitry to protect the relays are embedded within the module. Each
relay is responsible for controlling a single appliance. The designed system has two voltage level
circuits; An AC 220 Volts, 50 Hertz circuit to run the HAs, and a 5 volts DC circuit used to operate
the controller, the sensors and the relay module. The relay connects between the two systems as
each relay module is connected to both circuits, and according to an order from the controller, the
relay can easily turn OFF or ON a possible large appliance current.

HAs are divided into three different categories: inductive resistive loads, pure resistive loads and
electronic loads. Most of the inductive resistive loads consist of single phase induction motors so
small induction motors were used to represent this type of HAs. Resistive loads were represented by
a small water heater, bulbs or power resistors. Electronic loads were represented by a rectifier bridge
which contains four diodes.

Seven household appliances were chosen, they were chosen to have different priority levels,
different types and various power consumptions. The seven appliances are: bulbs, a dishwasher, an
iron, an air conditioner, a television, a fridge and a vacuum cleaner. It should be noted that the fridge
is supposed to have the highest priority level as it should not turn off at all times as turning it off will
damage the food contained in it and it might become inedible.

5
Introduction

The system is designed to calculate all the power consumed from the appliances and compare it
with the maximum allowed power level. If that specified level is exceeded, the system will start to
turn off the appliances with the lowest priority level until the optimum power level is achieved. If
any of the high level priority appliances was turned off, the appliance with the highest priority
among the low priorities will turn on as long as the maximum power consumed is not exceeded. The
same logic is applied on all HA. The designed system should be fast enough to read the power
consumed every 0.04 seconds. Figure 1.2 shows a simplified flow chart of the system's control
algorithm explained above.

Figure ‎1.2: General flowchart of the system control algorithm

6
Introduction

1.5 Document organization:


The rest of the document discusses the system design and results in details. The next chapter
presents a review of related literature, and presents some papers which are related to the project.
Chapter three contains the details of the system, the design approaches, requirements and realistic
constraints. Chapter 4 presents the final results of the system and presents a comparison with the
expected results. Chapter 5 which is the final chapter consists of the conclusion of the project, and
future thoughts and developments regarding the design.

7
Background and Literature Review

2 Background and Literature Review


2.1 Literature review:

This section discusses five papers from literature concerning previous journals, conferences and
thesis similar to the proposed design. For each paper, specific relevant parts were studied and a small
resultant conclusion was written accordingly.

The proposed home energy management system (HEMS) design in [2] aims to keep the total power
consumption of different HAs below a certain limit, providing the user more flexibility to operate
the HAs based on a priority algorithm which considers a different priority level for each HA. The
system consists of smart electric sensors (SESs) that determine the power consumption and a smart
power provisioning controller (PPC). The function of the PPC is to collect ON/OFF status from
each HA and instantaneous consuming power from SES. Then using priorities, PPC computes the
suggested power level for each HA and send a smart power management (SPM) message to each
HA to behave according to the suggested power level.

One of the main drawbacks regarding this HEMS scheme is that the lower priority HAs are fed
power in an unsatisfying manner, which does not represent the real life HAs at any status or
behavior. Furthermore, HAs introduced in this scheme have different response speeds, so a power
level overshoot occurs in the system.

In [3], the proposed HEMS framework incorporates the priority of appliances with the energy
optimization problem according to price-based programs. This incorporation showed the
importance of typical price-based programs as incorporating the priority algorithm in this scheme
results in facilitating the customer life along with a noticed drop in the electricity bills. In this
scheme, HAs are divided into two categories: controllable and uncontrollable, and the controllable
HAs are subdivided into ON/OFF controlled and regulating appliances.

Categorizing the HAs leads to a more realistic approach and a satisfying framework. However, there
was a mathematical constraint regarding the electrical profile modeling of the controllable
appliances.

8
Background and Literature Review

The HAs priority algorithm scheme in [4] was used as a tool to regulate the electricity demand peak
for HAs in order not to exceed a predefined power consumption limit. Modern real life HAs models
were used in the scheme and classified to low priority HAs or high priority HAs. This classification
was made according to their electricity demand time functions.

In this scheme, the high priority appliances are supplied power whenever they need and are never
paused. On the other side, the operation of the low priority appliances is postponed in certain cases
in which the high priority appliances must be satisfied electrically, the low priority appliances are put
in the pause list and their operation is resumed later when available. Two proposals with maximum
power limits 750 W and 1000 W were simulated. In the lower consumption limit, the low priority
appliances had a higher incremental delay time than their normal electrical profile in comparison
with the higher consumption limits.

In [5], a modeling framework was constructed based on low-level electrical characteristics of devices.
It provided an accurate load energy modeling. The loads were classified according to their physical
constructions as follows: resistive models, inductive models, capacitive models, resistive and
inductive models, non-linear models and composite models (complex models). Another
classification in this thesis is presented where the loads are classified according to their time
behavior, the devices were classified into ON/OFF load models, which capture many simple loads
(i.e. light bulbs and other low resistive loads with mechanical switches), ON/OFF growth/decay
models, stable min-max models, random range models and compound models which include cyclic
loads and composite loads.

Since different HAs have distinguished electric profiles and components, modeling them by single
general and simple ON/OFF load models would be neither realistic nor professional, and would
lead to insufficient and limited accuracy designs. Therefore, the classifications provided by [5] lead
to a very flexible, realistic and satisfying framework.

In most studies, the power consumption of HAs is considered to be constant at its rated power
without any variations during its operation. The main reason behind ignoring the load profiles and
this assuming stable power consumption is the lack of knowledge about detailed electrical behaviors
and characteristics of HAs, which is due to the lack of publicly available data. Therefore for the
HEMS system design criteria in [6], adequate and realistic HA energy models for two households are

9
Background and Literature Review

presented. The load profiles are presented in one second resolution and their raw data in one second
and one minute resolutions.

The approach in [6] aims to bridge the gap of data unavailability, and to give an insight of how each
home appliance consumes power. The accurate results and analysis provide a representative realistic
framework resulting in better understanding of the control process.

2.1.1 Contribution to previous work

The smart power monitoring and management system proposed overcomes the limitations and
insufficiency of previous designs by providing a realistic HEMS scheme with the following
distinctive properties:

 The system is continuously functioning at all times to achieve the required targets.
 The chosen HAs used in the scheme represent real life loads; in terms of nature, load profiles
and usage popularity.
 The maximum allowed power corresponds to the average house power consumption in the
region.
 The HAs priorities are set in a distinctive manner; having seven priority levels; each appliance
has its own rank which is set according to the general electrical behavior of end-consumers and
the electrical profile of each appliance.
 The current sensors used to measure power consumption are calibrated precisely to provide real
data with minimized error and noise.
 The control algorithm is very effective and intelligent, and its interface with the control switches
is efficient.

Hence, this scheme is considered as a very effective and realistic framework for power consumption
reduction and control. It is very applicable in real life as it provides the optimal power usage of HAs
satisfying their energy needs in addition to saving huge amounts of power, reducing electricity bills
and preventing outages.

10
Background and Literature Review

2.2 Background of technologies used

 Arduino platform

Arduino is an open-source electronic platform based on easy-to-use hardware and software [7]. The
Arduino boards, enhanced with built-in microcontrollers, are used in thousands of projects as the
main control unit, therefore contributing to the innovation and development of several beneficial,
systems. Arduino offers an easy and flexible platform for beginners with no background in
programming; it also offers a distinctive platform for advanced users to integrate their skills,
inventing problem solving designs. In general, Arduino can serve different fields and users with
diverse backgrounds. Arduino is considered a low cost board, a cross platform and a simple
programming environment. Table 2.1 displays the basic specifications of the Arduino Mega.

Table ‎2.1: Arduino specification [27]

Microcontroller ATmega1280

Operating Voltage 5V

Input Voltage (recommended) 7-12V

Input Voltage (limits) 6-20V

Digital I/O Pins 54 (of which 15 provide PWM output)

Analog Input Pins 16

DC Current per I/O Pin 40 mA

DC Current for 3.3V Pin 50 mA

Flash Memory 128 KB of which 4 KB used by bootloader

SRAM 8 KB

EEPROM 4 KB

Clock Speed 16 MHz

11
Background and Literature Review

Figure ‎2.1: Arduino mega controller

 ACS712 current sensor

The Allegro™ ACS712 current sensor provides economical and precise solutions for AC or DC
current sensing in several fields [8]. The device provides an easy implementation by the user. Typical
applications include motor control, load detection and management, switch mode power supplies,
and overcurrent fault protection. It is not intended for automotive applications [8]. The device
consists of a precise, low-offset, linear hall circuit with a copper conduction path located near the
surface of the die. Applied current flowing through this copper conduction path generates a
magnetic field which the Hall IC converts into a proportional voltage. ACS712 comes with several
ratings 5A, 20A and 30A. In the proposed system design, seven calibrated 5A, ACS712 are used to
measure AC currents for seven HA to provide the power consumption record for each appliance.
The current sensor gives an output voltage in millivolts (mV) proportional to the instantaneous
current amount passing through it, so the current value could be read instantaneously and the root
mean square (rms) value could be calculated as well by the controlling platform.

Figure ‎2.2 : ACS712, 5A module

12
Background and Literature Review

 8 – Channel relay module

The 8-channel relay could be controlled in an easy approach by plenty of microcontrollers’


platforms including the Arduino microcontroller. This relay provides an economic, flexible and
effective solution for controlling various electrical appliances and different devices in several
applications especially in smart house applications. In this design, the 8-channel relay module is
programmed to control the ON/OFF status for seven home appliances according to the proposed
priority algorithm scheme.

Figure ‎2.3 : 8-Channel relay module

 Realistic load models

Single phase systems are widely used in residential domains in comparison with three phase systems
as it provides convenient power consuming and economical solution for homes. In the proposed
design, several devices were used to model the HAs in order to drive a realistic framework:
induction motors of several ratings and types, power resistors, full wave rectifier and light bulbs.
Single phase induction motors [9] are characterized with their simple construction, low cost,
reliability and easy maintenance unit. Power resistors are characterized with their high wattage
capability therefore they were used conveniently to model the resistive and resistive-inductive HAs
in the system.

 Liquid crystal display (LCD)

LCDs are able to display arbitrary images (as in a general-purpose computer display) or fixed images
with low information content. A 20x2 LCD was used as a user interface.

13
Design

3 Design
3.1 Design requirements:

Table 3.1 shows the design requirements and their corresponding targets.

Table ‎3.1: Design requirments

Design Requirement Target

The system design should be able to monitor Seven home appliances were chosen to control
the power consumption of all house appliances them, and they were set in order from the
in real time; turning ON/OFF some or all of highest priority to the lowest.
the appliances.

Power requirement: The system must keep the The power consumption of the house must be
power consumption of the house below a kept below 4kW at all times.
certain level.

Real time requirements: In order for the system The response time in case of power increase
to function properly and achieve its desired must be less than 2 power cycles (0.04) seconds
goal, the response time in case of power for a 50Hz system)
increase must be very fast.

3.2 Analysis of design requirements and realistic constraints:

3.2.1 Analysis of design requirements:

This project must meet two objectives which are:

 Power requirement: The system must keep the power consumption of the house below 4kW at
all times.

14
Design

 Real time requirements: In order for the system to function properly and achieve its desired
goal, the response time in case of power increase above specified limit must be less than two
power cycles (0.04 seconds for a 50Hz system).

To meet the first requirement, a current sensor is integrated with the controller to measure the
current running through every HA. The current reading is then used to calculate its power
consumed. Then the total power consumed by the system will be calculated and compared to the
maximum allowable power consumption value. The system, using a smart algorithm coded design,
will start to turn off some appliances with low priority if the system's maximum allowed power is
exceeded. The switching process was achieved by using relay which opens the circuit when the
controller gives it a signal to turn off the appliance.

3.2.2 Analysis of realistic constraints:

 Economic: The budget for this project should not exceed 200JDs, and this fund was provided
by the Electrical Engineering department of Princess Sumaya University for Technology.
In the resistive inductive (RL) design approach, this approach will be explained in section 3.3,
the power resistors which can handle high currents had very expensive prices as each resistor's
cost can reach up to 500JDs.To meet the economic constrain, this approach was cancelled and
the HAs modeling was done using several single phase induction motors, light bulbs, and some
power resistors provided freely by the university. This alternative modeling approach was within
the project's budget.
A single eight-channel relay module was used instead of seven individual relays, as the price of
the 8-channel relay module is much less than the price of the seven single relay combined.
 Environmental: Single phase induction motors will be used to represent some of the home
appliances, and these motors cause high disturbing noises. Designing and testing the project was
done in the university laboratories, where an atmosphere of silence and no disturbances should
be provided for students.
 Ethical: General power consumption patterns of individual appliances can be determined from
the nameplates of the appliances, but some important electrical parameters such as the current
and the power factor could not be found as such information is kept confidential by
manufacturing companies. Incomplete information caused some problems and complications in
finding a way for HA modeling and representation; some calculations were practically

15
Design

impossible, which made the modeling process less accurate. Furthermore, the values and
patterns of individual domestic power consumptions should be kept confidential and not shared
with any other party as the user of the system may not want to share such information.

 Safety:
A. Working with single phase 50Hz 220V voltage sources, and measuring relatively high currents
passing through the loads formed a safety process throughout all the steps of the design.
B. Wiring complexity caused possibilities of short circuits or electrocutions.
C. Some of the devices used were poorly insulated for such amounts of current passing through
them.
D. A water heater used to represent an iron; such devices heated up to extremely high temperatures
in few seconds and can cause serious injuries such as burns whether from heater itself or the hot
water.
E. Motors were used to model some HAs, dealing with motors vibrating and moving strongly is
unsafe as it could cause injuries by direct contact, or their movement could affect any other
component in the design.
F. Fans were used to model some HAs; the fan blades could cause cuts if touched while operating.

 Manufacturability:

A. Due to the presence of several appliances and each is connected to many devices, and due to the
presence of a 220 V AC circuit and a 5V DC circuit where all the circuits are integrated with the
appliances and the controller, the complexity of the wiring was very high.
B. The hall effect current sensor has low sensitivity as it was found that it cannot read small
currents under 100mA. This contributes in major role in the final design.
C. The hall effect current sensor can be affected by any flux from other devices around it. Since
many devices are present and they all are connected near each other, errors, signal noise and
hence incorrect or inaccurate readings may develop.
D. The running time of the design depends on: the speed of the internal oscillator in the controller
which cannot be changed, the length and complexity of the operation code, and the relay's delay
time after it receives its control signal
E. Low power factors of some induction motors as they are running at no load.

16
Design

3.3 Different design approaches

To design a smart power monitoring and management system diverse design scopes could be
implemented. Based on precise design criteria, an excellent and preferable approach would be
chosen to present the oriented design framework required and to provide an accurate expected
results and conclusions. The design criteria considers several decision-maker factors: the nature of
the project, the availability of different types of components used, the requirements of the achieved
design, the harmony of integration between system components ( modeling, sensing, controlling and
switching), the design constraints and how were they handled . Figure 3.1 illustrates the design
criteria facets.

Figure ‎3.1: Design criteria


Following are several system possible frameworks and design approaches:

3.3.1 System simulation model

In the simulation design approach, several design simulation software’s are possible, MATLAB
(Simulink) is proposed as an excellent option for the simulation as it is a powerful and accurate
simulation tool that offers wide variety of libraries and functions. The main building blocks for the
project are HAs, smart current sensing units, programmable switches and a central control unit; all
these building blocks are to be modeled adequately by MATLAB tools to establish the whole model.

17
Design

However, this approach is far from being realistic; because the real life behavior of appliances,
sensors and switches, and their connections complexity in real life could not be possibly modeled by
the software. Using this approach, the design requirements could be met yet this will not be realistic
due to manufacturability issues of real life devices that cannot be realistically modeled by simulation.
So the result would not provide a reliable base for real life applicability.

3.3.2 Software and hardware driven system model:

Another approach is the software and hardware model. Using real building blocks for the system
design offers a realistic, practical and effective framework. Furthermore, this approach establishes a
way for implementing the system in every home as the results obtained captures a clear image for
the system applicability.

Different hardware and software technologies could be used for building the proposed system. In
this design, several software and hardware models and technologies were possible to build the
system's architecture which is composed of four basic units, the main control unit, the current
sensing unit, the programmable switches unit and HAs modeling method.

 Control unit approaches

Two main controllers were proposed: the PIC microcontroller and the Arduino controller. Both
controllers are known for their smooth operation. Many types of each individual one are available,
each with a specific capacity, ports and other specific features. Codes for both controllers can be
written in the C++ programming language. Each device has its own advantages and disadvantages,
and a certain level of flexibility. Therefore choosing the suitable one depends on the design itself.

To achieve the design’s time requirement, a very precise controller has to be used. By experimenting,
the Arduino controller proved to be faster and more reliable in performing the monitoring and
control algorithm; it is faster in operation with less compiling errors and failures. Furthermore, the
wiring in the Arduino is less complex than the wiring in the PIC microcontroller. So PIC
microcontroller was not chosen in the final design.

 Current sensing approaches

In order to measure the instantaneous current consumed by the HAs, two possible current sensing
modules were available: the LTS6-NP current sensor modules, which have a current transformer

18
Design

embedded within it. This sensor has several modules according to their different current ratings, one
of its modules measures up to 6 Amperes, and the ACS712 current sensor modules, which has hall
effect-Based linear current Sensor IC with 2.1 kVrms isolation and a low-resistance current
conductor. This sensor has several modules according to their different current ratings as well, one
of its modules measure up to 5 Amperes.

Each of these sensors has its own distinctive properties, and a specific way to measure the current.
Hence the sensor-controller integration process is different for both of them. The chosen sensor
and module is dependent on the nature of the design. The cost of one LTS6-NP current sensor
module is 15 JDs, but the cost of the ACS712 current sensor module is 5 JDs. Since seven currents
sensors are needed, 70 JDs from the 200JDs budget is saved by choosing the ACS712 module.
Moreover, the connection of the ACS712 module is much less complex than the LTS6-NP module.
As a result, the ACS712 current sensing module was chosen for the final design.

 Programmable switches approaches

Different modules of the switch consist of the same basic relay repeated a certain number of times.
All relays in a module are identical and can handle relatively high voltage and currents compared to
the domestic level. The switching process could be achieved by using two-channel relay modules or
eight-channel relay modules. Different numbers of relays per module are available as well. The
module should be chosen according to the number of HAs required in the design, the required
wiring, the position of the relay in the design, and the budget, as they have a significant difference in
their prices.

The 8-channel Relay module was purchased instead of 7 single channel relay modules to decrease
the cost of total relays needed; as one channel relay cost 6 JDs, so a total of seven would cost 42
JDs, but the 8-channel relay module costs 16 JDs only, so 26 JDs were saved.

 HA’s modeling approaches

Modeling the HAs is very essential part of the design, as providing a realistic load increases the
system applicability in real life and provides a real-life based approach. Several methods are
proposed to model different HAs:

19
Design

A. Light emitting diodes (LEDs)

In this approach, every device is modeled with an LED. This design stresses on the HAs' control
rather than modeling them in a realistic manner. Simply, if the LED representing a certain device is
on, the device is assumed to be functioning and consuming a certain amount of power, and vice
versa. The system will calculate the total power consumption and control the load according a
certain criteria. This approach could be made more realistic by using some time functions to
represent to power consumption variation of certain devices with time; power consumptions
profiles data is available in previous research papers.

In this approach, meeting the design management requirement could be met but the monitoring
requirement could not be achieved as no current sensing is used as all the LEDs are connected to 5
volts DC circuit and only used to represent the ON/OFF state of the appliances.

B. Resistors(R), inductors(L) and LEDs

In this approach, power resistors, inductors or combination of both is used to model the HAs. For
this purpose, the HAs are classified into 3 main categories shown in Table 3.2:

Table ‎3.2 : HA's classification

Model class Modeling elements

Resistive – heating appliance R (resistive model)

RL+ Reverse diodes (a resistive-inductive model


Motor embedded appliance
protected by using a reverse diode)

Electronic appliance Digital rectifier + R (nonlinear model)

In this approach LEDs are used as an indicator to deliver the HA's state to the user; whether each
device (the corresponding LED) is on or off.

Several electrical data for different appliances were collected from different sources and final
estimations for the resistors and inductors values for each appliance were calculated. The
calculations were made for operating the device on 55Vrms AC voltage along with having a unified

20
Design

assumption for the power factor for each class. An example of how the values representing the
fridge were calculated is shown below:

Data: P=800W, PF (assumed) =0.95


Required: The impedance value Z
Solution:
I= = = 3.82775 A

Z= = = R+ jwL =54.601 + j17.9465 Ω


Therefore:
R=54.601 Ω
L=17.9465 Ω
Scaling all the electrical data from 220Vrms to 55Vrms was done to decrease risk and to provide a
safe platform area and eliminate hazards. Taking 110Vrms output signal from a voltage regulator as
input to a rated 220/110V transformer (ratio 2:1) provides an output voltage of 55V.
It should be noted that several electrical data for certain appliances is not available to the user as it is
kept confidential by the manufacturing companies. Data used for calculations was obtained from
four different sources:

 A previous project about load shifting by PSUT students [10].


 Real machines ratings from various nameplates of different HAs. (Courtesy to Carrefour market)
 Several previous research papers and data about different types of motors.
 Measured real life appliances by ammeters and wattmeter.
Note: Values of currents measured in real life did not provide any reasonable results, this is due
to the fact that currents measured were external currents passing through the whole appliances,
and since the internal circuitry of the appliances is not known, it was practically impossible to
find the exact parameters. As a result, the values obtained were omitted and not taken into
consideration.

Table 3.3 summarizes the final estimations for the modeling elements for diverse home appliances
based on the different data sources, unavailable results are pointed out as well. Main concerns
regarding this modeling approach is that the appliances will be represented in unrealistic and
irrelevant manner leading to inaccurate results.

21
Design

Table ‎3.3: Modeling calculation results

Previous Research
Pervious load shifting Real machines rating
papers
project [10] ( Courtesy to Carrefour
&
market )
Data about motors types

Load R (Ω) L (mH) R (Ω) L(mH) R (Ω) L(mH)

Washing
69.02 9.83 198 30.5 24.905 105.7
Machine

Refrigerator 60.17 14.88 250 364.65 24.905 105.7

Air Conditioner 24.103 4.857 38.26 28.29 24.905 105.7

No useful No useful
Blender (Food
161.24 22.97 data data 58.149 246.79
processor)
available available

No
Purely No useful No useful No motors
motors in
Light bulb 968 resistive data data in device
device
load available available structure
structure

No
Purely No useful No useful No motors
motors in
Iron 48.4 resistive data data in device
device
load available available structure
structure

No
Digital No useful No useful No motors
motors in
604.54 electronic data data in device
TV device
load available available structure
structure

22
Design

C. Resistors and LED

This approach is very similar to the previous one, but instead of using RL load to represent
inductive loads and their power factor, all loads are modeled as pure R load and the power factor is
compensated in the code. Another reason to eliminate the inductors was to eliminate the safety
hazard of inductor discharging the stored current.

Approaches 'B' and 'C' have the following disadvantages:

 The uncertainty of the calculated values.


 The inability of current sensors to sense currents lower than 0.1A in using 55 volts system.
 55 volts system cannot be used, 220 volts system has to be used.
 Power resisters provided by the university cannot tolerate the current passing through when
connected to 220 volts.
 The high cost associated with the power resistors tolerating 220 volts (one power resistor
can reach up to 500 JDs; one resistor exceeds 200 JDs budget).
 The unavailability of various modeling elements in the dedicated values.
 The difficulty of manufacturing power inductors for 220 volts with specific values.
 Safety hazard of using handmade inductors under high currents.
 Loads are not representative to nature and behavior of real life HAs, especially in the current
sensing and monitoring part.

Thus, a new approach has to be done to find the ultimate representation of the devices in a way that
is efficient, representative and overcoming all the economic and manufacturability limits.

D. Resistors, digital rectifier and induction motors.

This modeling approach takes all the advantages of the previous approaches and eliminates all the
disadvantages. This is the chosen approach for the final design and it will be further explained in the
next section.

23
Design

3.4 Developed design:

Figure ‎3.2: Brief description

The system was designed taking in consideration all the previous choices of the design approaches
by choosing the best and the most realistic design that best meets the design approaches and realistic
constraints. In this section the design procedure will be described in detail.

The system is designed to measure the current flowing, by the current sensor, in each HA then the
data will be sent to the Arduino controller to calculate the power consumed by each HA. After that,
the controller will send a signal to the relay to turn off or on some of the appliances in order not to
exceed the predefined maximum power limit. Figure 3.2 illustrates a brief description of the idea of
the project.

24
Design

It is noted in Figure 3.2 that the system runs indefinitely and in a closed loop, the system is always
operating in real time. The sensing and control processes are continuous as long as the switch to
turn on the system is on. The displayed HAs represent the ones chosen to model the house.

In this section, the full software and hardware designs will be thoroughly explained. And the
modeling approach “D.” will be fully explained. Figure 3.3 gives some information about how the
work had been divided to design the system.

Consumed Power

Chosen Appliances

Priority Distribution
Design Procedure

Modeling The Design

Hardeware Design

Electrical Circuit Design

Software Design Code Design

Figure ‎3.3: Design procedure

25
Design

3.4.1 Chosen appliances

First of all, in order to go through the modeling process of every individual device, it is a must to
understand and to have a brief background about different types of domestic loads. A typical home
consists of dozens of electrical loads that vary in the amount of consumed power. However, these
loads can be distributed in three main categories according to their nature; resistive loads, inductive
loads and electronic loads. The first two categories are linear electrical loads, and the third category
consists of non-linear loads.

Resistive loads are domestic loads that their main function is to convert electrical energy to thermal
energy, the voltage and the current in these loads are in phase all the time and hence they have a
unity power factor. Cloth iron, water heater, bulbs, toasters, and coffee makers are good examples
for domestic resistive loads.

Inductive loads are loads that contain a coil of wires to produce a magnetic field. In normally used
HAs there are no pure inductive loads, but electrical motors are considered to be inductive loads.
The main function of these loads is to convert electrical energy to kinetic energy. The current in
these types of loads always lags the applied voltage, so they have a lagging power factor. Motors
domestically used in various appliances are usually single phase induction motors, these motors
often have capacitors to aid them when they starts to rotate. At the beginning of their operation, an
inrush current higher in magnitude than normal operating current flows in them. After a certain
while, usually in seconds, this current goes back to normal values. Examples of such devices are
vacuum cleaners, washing machines, blenders and air conditioners.

Electronic loads are the non-liner loads in the house. In non-linear loads, the relationship between
the applied voltage and current is not linear, and this non-linearity causes some harmonics which
cause higher power losses and a lower power factor. Television, radio, computers and DVD are
good examples for electronic loads.

From these variations, the loads were chosen to cover all types of HAs explained above. Seven
appliances were chosen to model the house; two of them are resistive loads, four of them are
inductive loads and the last one is electronic.

The chosen HAs are shown in the table below, it should be noted that all the domestic appliances in
Jordan operate at 220 volts and 50 hertz.

26
Design

Table ‎3.4: Chosen appliances, their type and the consumed power [11]

Consumed
Type of Load Resistive Load Inductive Load Electronic loads
power /Watts

Iron X 1000

TV X 150

Dish washer X 1500

Vacuum Cleaner-
X 2000
High power
600
6 Bulbs X
(100 watts/each)

Air Conditioner X 1000

Fridge X 500

Total 2 4 1 6720

The appliances were distributed in different levels of priority according to their importance from the
user’s perspective. In this design, the chosen HAs were arranged from the highest in priority to the
lowest from the students working on this project point of view. The fridge has the highest priority as
it contains food, and if the power went off the food will be inedible and hazardous. So it has to be
ensured that the fridge will stay on all the time. The second HA in priority is lighting in room of six
bulbs as that it can be more important especially at night.

For the middle three priorities among the iron, TV and vacuum cleaner; the iron is chosen to have a
higher priority as it has to operate immediately when required. The TV is chosen for the next
priority it is a luxury but yet it has to be working at a specific time. And the next one is the vacuum
cleaner as its operation is important but can be postponed.

27
Design

The last two appliances were air conditioner, as in Jordan air conditioners are not very essential
given that Jordan has a moderate climate. Then the dishwasher occupies the last priority as its
operation can be shifted when the level of the maximum consumed power is not exceeded.

The priority from the highest to the lowest:

1- Fridge.
2- Bulbs.
3- Iron.
4- TV.
5- Vacuum Cleaner.
6- Air conditioner.
7- Dish washer.

3.4.2 Hardware design:

 Modeling the design:

As mentioned before, there is a need to understand the types of the loads in order to model the
hardware. From this point, smaller devices were chosen to be representative of the original devices.
The modeling of each HA and the corresponding calculations are listed below.

For previously explained modeling proposes, devices chosen to represent HAs withdrawn relatively
small currents and power values. So in order to achieve the required power value, a specific scale has
to be multiplied to achive the real consumed power.

1- Fridge :
To model the fridge, a small fan was used to represent the motor inside the fridge; the fan was
also connected in parallel with three power resistors connected in series, each 200Ω giving a total
of 600Ω. This connection was made as a simple equivalent circuit representing a complex circuit
inside the fridge. The electrical ratings of the small fan were measured by a digital meter. The
ratings are:
 Power consumed = 27.3 W
 Current = 0.26 A
 Power factor = 0.47 lagging

28
Design

 Voltage = 220 V

The fan connected in parallel with 600 Ω consumes total current of 0.366 A

Calculations:

Itotal=I600 Ω + Ifan = 0.55+0.26<-cos-1(0.47) =0.539<-25.17 A

PF=cos (27.17) = 0.905 lagging

Power = Vrms *Irms* PF= 220*0.539*0.905=107.315 W

Since the represented fridge power is 500 watts, and the modeled device consists of a fan and
three power resistors consumes 107.315 watts. A factor of 4.659 has to be multiplied to the
calculated power in code in order to achieve the desired value as 500/107.315= 4.659.

2- 6 Bulbs:
Modeling the bulbs was a simpler process because a normal domestic 100W bulb was used to
represent the 6 bulbs in a room. The electrical ratings of a single bulb:
 Power consumed = 100 W
 Current =0.454 A
 Power factor = 1
 Voltage = 220 V
Calculations:

Since the represented group of bulbs power is 600 watts, and the 100 watts bulb consumes 100
watts, a factor of 6 has to be multiplied to the calculated power in code in order to achieve the
desired value, as 600/100=6.

3- Iron:
A small water heater was chosen to represent the iron as it is a resistive load of the same
electrical and mechanical properties. The electrical ratings of the used heater:
 Power consumed = 809 W
 Current = 3.68 A
 Power factor = 1
 Voltage = 220 V

29
Design

Calculations:

Since the represented iron power is 1000 watts, and the used water heater consumes 809.6 watts,
a factor of 1.235 has to be multiplied to the calculated power in code in order to achieve the
desired value, as 1000/809.6=1.235.

4- TV:
The TV is an electronic load, so it was modeled by an electronic device. A full wave rectifier
bridge of 4 diodes was used to represent the electronic part in the load, the rectifier was
connected with a resistive load from the DC side, and the load is a 100 Watts bulb to indicate
whether the TV is on or off. The electrical ratings were measured by the digital meter, the
ratings were:
 Power consumed = 89.54 W
 Current = 0.407 A
 Power factor = 1
 Voltage = 220 V
Calculations:

Since the represented TV power is 150 watts, and the modeled device which consists of a bridge
and a 100 watts bulb consumes 89.54 watts, a factor of 1.68 has to be multiplied by the
calculated power in code in order to achieve the desired value, as 150/89.54=1.68.

5- Vacuum Cleaner:
A small blender was used to represent the induction motor of the vacuum. It was chosen
because it has different speed ratings from the vacuum cleaner. The electrical ratings were
measured by the digital meter for all speed ratings. The ratings were:
1. Higher speed:
 Power consumed = 174 W
 Current = 0.805 A
 Power factor = 0.98 lagging
 Voltage = 220 V
2. Lower speed:
 Power consumed = 111
 Current = 0.59 A

30
Design

 Power factor = 0.85 lagging


 Voltage = 220 V

When this motor was connected with the current sensor to measure its current, the sensor could
not recognize the difference in currents between the two speed levels, and it read a value
between the two readings which was almost 0.7 A, so an average value for the power factor was
taken (0.85 + 0.98)/2= 0.915

Calculations:

Power=Vrms *Irms* PF= 0.915*220*0.7=140.91 watts

Since the represented vacuum cleaner power is 2000 watts, and the blender consumes a power
around 170.91, a factor of 14.19 has to be multiplied to the calculated power in code in order to
achieve the desired value, as 2000/140.91=14.19.

6- Air conditioner :
A small fan was used to represent the induction motor of the air conditioner, all the motor
parameters were measured by the digital meter, and the parameters were:
 Power consumed = 30.8 W
 Current = 0.28 A
 Power factor = 0.49 lagging
 Voltage = 220 V

Since the represented air conditioner power is 1000 watts, and the fan consumes 30.184, a factor
of 3.13 has to be multiplied to the calculated power in code in order to achieve the desired value,
as 1000/30.184=3.13.

7- Dish Washer:
Water pump motor was used to represent the dishwasher, it was chosen because it has similar
electrical and mechanical properties. Its measured parameters are:
 Power consumed = 128 W
 Current = 1.71 A
 Power factor = 0.34 lagging
 Voltage = 220 V

31
Design

Since the represented dish washer power is 1500 watts, and the water pump consumes 127.9, a
factor of 11.73 has to be multiplied to the calculated power in code in order to achieve the
desired value, as 1500/127.9=11.73.

Table 3.5 summarize all the chosen devices to model the real HAs, also it tabulates the electrical
parameters of the chosen appliances such as currents, power factor, consumed power. The last
column of the table contains the multiplied factor for each device.

Table ‎3.5 : Summary for all modeling calculations

Model current Model Power Multiplied


Load Modeled load Model PF
( A) (W) Factor
Fan parallel to
Fridge 0.539 0.905 107.315 4.659
600 Ω resistor

6 Bulbs 1 Bulb 0.454 1 100 6

Iron Water heater 3.68 1 795 1.257

Full wave
TV Rectifier + 0.407 1 89.54 1.68
100W bulb

Vacuum Blender 0.7 0.92 140.91 14.19

AC Fan 0.28 0.49 30.6 33.13

Dish washer Water pump 1.71 0.34 129 11.73

It should be noted that some of the motors used had a very low power factor, this happens as these
motors are operating at no load. So the power factor will remain low until there is a load connected.
The factors were multiplied in the code at the end to reach the desired power level and the problem
of the low power factor was solved.

32
Design

 Electrical circuit design:


The design contains two integrated circuits; the first one operates on 220Vrms and it energies all the
chosen HAs, and the second one is 5V DC circuit which operates all the sensors, the relays and the
Arduino. The components of the electrical design will be discussed separately in this section. The
current sensor and the relays form the interface and the integration between the two voltage circuits.
Figure 3.4 illustrates the schematic diagram of the circuit connection of a single appliance, followed
by the explanation of every component.

Figure ‎3.4: Single HA connection schematic

 Current Sensor:
The ACS712 current sensor measures currents up to 5 A. Seven current sensors were used, one
for each appliance. The sensor has a sensitivity of 185 mV/A; that is for every ampere rise of
current, the output voltage given rises by 185mV. This sensor has a noise equals to 21 mV. And
since the sensitivity is 185 mV/A, using ratio and proportion:

33
Design

1 amp  185mV
X  21 mV  so X equals approximately 100mA.
This means that the sensor does not have the ability to sense any current below 100mA.

The sensor is connected to the rest of the circuit by two sides. One side is connected to the 220
Vrms AC circuit in series through two holes. The voltage drop across the sensor is negligible so
no voltage is lost across it. The other side has 3 pins: VCC, ground and output. The VCC and
the ground are used to operate the sensor and are common for all the sensors and taken from
the Arduino’s 5V DC and ground respectively. The third output pin gives the DC voltage (in
mV) and is connected to the Arduino’s input pins. See Figure 2.2

 Relays:
The chosen 8-channel relay module has two sides as well. One side is connected to the 220Vrms
AC circuit. Each one of the eight relays has three ports: a common port in the middle, a
normally opened port and a normally closed port. The HAs in our design is connected to the
normally closed ports so as not to block the operation of the HAs before controlling them.

The other side is connected to 5V DC circuit. This side has ten pins; a VCC and a ground. The
VCC and the ground are used to operate the module and are common with all the sensors as
well. The rest of the pins are input to the relay, when a digital high (5V DC) signal acts upon a
pin, the corresponding normally closed port becomes opened and vice versa. The 7 HAs are
connected in the same order of their decreasing priorities from relay 1 to relay 7. Table 3.6
explains the 8-channel relay module specifications.

Table ‎3.6: 8-Channel relay module specifications

Switch /control circuit

Input voltage : 5VDC Control signal from controller

External circuit ratings

10A/ 250VAC 10A/ 125VAC

10A /30VDC 10A /28VDC

34
Design

 Arduino, LCD display, switch:


The VCC (5V DC) and the ground for all the components are taken from the Arduino and the
Arduino gets the power supply from a serial cable connected to a laptop. Analog pins 0-6 are
configured as input and connected to the current sensors output pins in the same priority order.
Digital pins 3-9 are configured as output and connected to the relay pins inputs in the same
priority order. Digital pins 48-53 are connected to the LCD display which shows some data to
the user. Digital port 13 is configured as input and a master switch is connected to it, the switch
is connected to the same 5V DC and a pull down resistor. The code is designed such that the
system doesn’t operate unless the switch is on.

 HAs connection
Each HA is connected to the 220Vrms 50Hz power supply, and is connected in series to a
switch, the current sensor and they relay high voltage sides. The other sides of the current sensor
and relay are connected to the Arduino as explained before.

The seven HAs are connected in parallel to the same 220Vrms 50Hz power supply. So the same
connection shown in figure 3.4 is repeated 7 times but with different ports to every HA’s relay and
current sensor. This connection in addition to the master switch and LCD display is shown in the
final schematic Figure 3.5.

35
Design

Figure ‎3.5: Final design schematic

36
Design

3.4.3 Software design

 Note: The line numbers written are the numbers of the lines in the attached code in Appendix
A.
 Declarations and definitions (line 1 – line 54)

All the required coding objects are declared and defined once at the beginning of the code.

 Current sensing (line 79- line101)

The ACS712 current sensor gives an output analog voltage proportional to the amount of the
sinusoidal current passing through it. The code takes several samples of the output voltage,
converts it to a digital value. The duration between consecutive samples should be longer than the
analog to digital conversion time. From each reading, the relative digital zero is subtracted. Then
the rms reading is calculated by squaring the instantaneous readings followed by taking the mean
value followed by taking the square root.

The values obtained still contain some error, the first error is a linear noise offset and it is treated
by subtracting the offset from each value. The second type of error is non-linear and calibration
equations were needed to treat this error. Values of load currents were measured using an ammeter
of high accuracy and by using the current sensor, tables were filled and graphs were plotted as
shown below.

Table ‎3.7: Current sensor calibration data

Current Sensor /A Ammeter Current/A


(X-axis) (Y-axis)
0.17 0.108
0.2 0.147
0.25 0.183
0.3 0.22
0.36 0.275
0.49 0.367
0.75 0.55

37
Design

0.97 0.733
1.13 0.825
1.21 0.88
1.27 0.917
1.52 1.1
2.32 1.65
3.15 2.2
4.57 3.3
5.12 3.82
5.8 4.4

Using the measured values above, the ammeter reading vs. the sensor reading graphs were plotted
and the best fit curves were drawn using Microsoft Excel. The best fit equations were found. For
the equations to be as accurate as possible, the values were divided into three groups, each with a
specific polynomial calibration equation as explained in the equations and figures from Figure 3.6
to Figure 3.8.

 For x <0.2: { y=0}


 For 0.2< x<0.6: { y= -700.4x6 + 1821x5 - 1890 x4 + 999 x3 - 283.1x2 + 41.56x - 2.347}
 For 0.6< x<2: { y= -0.004x5+ 0.064x4 - 0.37x3 + 0.965x2 - 0.462x + 0.554}
 For x>2: { y = -0.061x3 + 0.871x2 - 3.189x + 5.511}

Figure ‎3.6 : Current sensor calibration equation graph for 0.2<x<0.6

38
Design

Figure ‎3.7 : Current sensor calibration equation graph for 0.6<x<2

Figure ‎3.8 : Current sensor calibration for x>2

 Power calculations ( line 61-line76 & line142-line153)

The calibrated values of measured currents are stored in an array of decreasing priority order. An
array of powers of the same order is calculated using the saved currents' array, the calculated scales
to model the HAs (Section 3.4.2), and the previously measured power factors (Section 3.4.3). All
the values of the scales and power factors are sorted in similar arrays. Assuming a constant voltage
value of 220Vrms, the power of each HA was calculated in the code using the formula:

Power= 220* Current*Power factor* Scale

39
Design

 Control (line99-line173)

Since all the power values are available, the devices that are switched ON by the user are saved in
an array. At the beginning of the control function, the devices whose relays are open-circuited are
also saved in vector arrays (all the relays at the first run are normally closed), and vectors are arrays
of expandable sizes during the program run.

Using while loops and if statements, the values of powers are subtracted from the maximum
allowed power value in decreasing order of priorities until the maximum allowed limit is consumed,
then all devices that cause the limit to be exceeded are turned OFF.

Next, the off-devices are tested. For a device of a certain priority order, the next device in priority is
assumed to be OFF, then the higher priority device is turned ON temporarily, a delay of 200mSec
is applied to avoid inrush currents, and the power is calculated. If it is possible to be kept ON
without exceeding the maximum allowed power, the device will be kept ON, otherwise it will be
turned OFF again. All saved devices will be tested in decreasing priority order.

The control algorithm is designed and its code is written in way that it could be easily adjusted to
any maximum power value and to any number of HAs. The code is very efficient and as short as
possible to ensure smooth operation in minimal time.

 Time Measurement (line58-line60 &line102-line104 & line119-line121 & line175-line197)

The time taken to run the code was measured by the ready function "Millis" that measures the time
as accurate as milliseconds. The function was implemented in several places to determine the
running time. Another manually-written function was used in order to edit the measured time and
display it on the serial print screen.

 Run (line55-line78)

As for all embedded systems, the system's running process consists of indefinite loops. In the loop
function here, the system calls the current sensing function, measures currents of all the HAs, then
it calls the control function that determines which HAs should be turned OFF/ON. Some values
are displayed on the LCD display during the process. This cycle is repeated indefinitely as long as
the switch to control the system is turned on.

40
Design

 Flow Chart
Figure 3.9 shows the flow chart describing the full steps of the system operation in all off its parts
explained above.

Figure ‎3.9: Flow chart of the system

41
Design

3.5 Meeting Design Requirements and Realistic Constraints:

3.5.1 Design Requirements:

 Power Requirement: In the designed control algorithm, as the current is measured and the
power of each HA is calculated, the ON/OFF state of all HAs is determined such that the
maximum power consumption never exceeds 4 kW at all real times considering the priorities
and importance of the HAs.
 Time Requirement: Two main factors determine the operation time of the control algorithm:
the frequency of the Arduino controller which determines the speed of running the code, and
delays added in the code for mechanical purposes. The control time is required not to exceed
0.04 seconds.

3.5.2 Realistic Constraints:

 Economic Constraints: The developed approach was chosen because it best met the
economic constraints, as the department of electrical engineering in Princess Sumaya University
for Technology gives a fund of 200 JDs, The project was designed in a manner not to exceed
this limit, and if it was exceeded, it would be by a reasonable amount.
Also the 8-channel Relay module was purchased instead of 7 single channel relay modules to
decrease the cost of total relays needed; as one channel relay cost 6 JDs, so a total of seven
would cost 42 JDs, but the 8-channel relay module costs 16 JDs only, so 26 JDs were saved.

 Environmental constraints: So as not to disturb other colleagues working in the same place,
the noises produced by the induction motors must be reduced by inserting the motors inside
wooden boxes, this proposed solution is to minimize the sound pollution and provide a calm
working environment.

 Ethical constraints:
A. As for the constraint regarding the confidentiality of electrical parameters of electrical devices,
it was solved by using the power ratings only, and measuring the currents and the power factors
of chosen loads to model the HAs. In addition, in order to reach the required power

42
Design

consumptions, the modeled load measured power was multiplied by a factor to obtain the
desired values of explained in the previous chapter.
B. As domestic power consumption patterns and values should be kept confidential, it should be
noted that this system is designed to operate in single house without any data integration with
any external server, so no one besides the user is able to obtain power consumption data.
C. Codes and algorithms used for connectivity purposes of sensors and basic devices in the design
are referenced, and the credit should go to the author as stated in legal legislation policies.

 Safety constraints:
A. Working with single phase 50Hz 220Vrms voltage sources, and measuring relatively high
currents passing through the loads, it is important to make sure that all the wires are insulated
correctly and safely so it will not cause any problem.
B. Short circuits or electrocutions' possibilities due to wiring complexities were avoided by
checking the circuits' connection every time before the operation.
C. Some of the devices used were poorly insulated for such amounts of current passing through
them, so they will be stored inside wooden boxes, so the devices will not be touched by the
users and hazards are eliminated.
D. A water heater used to represent an iron will be kept in cold water as a heat sink as the heater's
temperature rises quickly to very high temperatures, and the water will be changed continuously
to avoid any injuries.
E. Vibrations and movement of the motors will be solved by sticking them in wooden boxes so as
to limit their ability to move and cause any unfavorable accidents.
F. Fans were used to model some HAs; they were mechanically isolated from users by inserting
them into the wooden boxes to have the minimal interface between them and the user as their
blades are dangerous.

 Manufacturability constraints:
A. Due to the presence of several appliances and as each is connected to many devices, and due to
the presence of a 220 Vrms AC circuit and a 5V DC circuit where all the circuits are integrated
with the appliances and the controller, the complexity of the wiring between the two system
was very high.

43
Design

B. The minimum measured current by the current sensor is 100mA, HAs were chosen to
withdraw more than this amount.
C. Noise of the sensor at zero current and all values were present, and were treated by linear and
nonlinear calibration equations.
D. The noise caused by near fluxes of other devices affected the reading of the current sensors.
They were reduced to the minimal amount by covering the current sensors by a metal sheet
which will work as a mirror that reflects the flux, and by keeping the sensor away from many
devices as possible.
E. Low power factors of some induction motors as they are running at no load, the problem was
solved by multiplying the power values by a scale to achieve the required power values.

44
Results

4 Results
4.1 Prototype setup

The system was built step by step during the stages of the design. Some phases took shorter time
than expected, other took longer than expected. The prototype setup consists of two parts:
hardware and software.

 Hardware Prototype Setup


At first, the RL modeling approach for the HAs was chosen, but due to all of the complexities
and the disadvantages of this approach explained earlier, this approach was abandoned and the
approach of using real life motor and representative appliances in addition to some resistances
was chosen. The devices were brought and tested individually during the design process.
Furthermore, wooden boxes were customized to fit every single device to simplify connection
and to assure safety.

 Software Prototype Setup


The code was built from scratch in some parts, or previous codes were edited in other parts.
The current sensing code in [12] was tested individually on a single input, and then a function
was made out of the code to measure all of the appliances. The control function was built
separately and then tested and adjusted. Different libraries had to be included as some coding
objects had to be used. The algorithms building process in all of its parts contained trials and
errors in order to find the most suitable and efficient code.
 Note: Check Figure 7.1 in Appendix B to see the final prototype setup.

4.2 Experiment setup

At the beginning, all the elements were tested to ensure their correct functionality .Then they were
assembled together to build the entire system. The scope of experimenting for the hardware
components and software scheme was as follows in Table 4.1.

45
Results

Table ‎4.1: The scope of experimenting the smart power monitorng and management system

Experiment
Experiment Type Experiment Summary
Number

1 Designed models testing All the proposed models worked properly.

Final current sensor calibrated code achieved


the sensing function within accepted limits of
2 Current Sensors testing
error. All the currents for all the designed
models were measured properly.

The 8 channels were tested to perform its basic


3 The eight-channel relay testing switching function. All the channels achieved
the switching task required.

Each appliance was connected to the power


Single appliance circuit hardware supply with a current sensor, a relay and a
4
test switch. All appliances separately operated
correctly.

All the hardware components were connected


with all the current sensors and the 8-channel
5 Complete circuit hardware test relay to test for the harmonic communication.
All appliances operated together with no
deduced errors.

The final hardware and software schemes were


Complete circuit hardware and
6 tested to prove validation. System performed its
software test
requirements correctly.

46
Results

4.3 Experiment results discussion

The following section discusses the results of the testing the prototype. The results are divided into
two classes as shown in Figure 4.1.

Figure ‎4.1: The final smart system results

Power monitoring and measurements results:

Seven ACS712 5A modules were used for measuring the currents for seven appliances. Other
electrical data (Voltage and Power factor) were written in the code for each appliance as well as
modeling scales. Hence the final power estimations for each HA and the total power was calculated
in the code after the data aggregation from the currents sensors modules and the predefined values
in the code. Figure 4.2 shows screenshots of the serial port interface screen displaying the currents
and powers of all appliances.

47
Results

Figure ‎4.2: Serial port readings


Table 4.2 tabulates the above readings for the seven home appliances were taken, compared with
the rated powers. The percentage error and the total average error were calculated for all
appliances.

Table ‎4.2: Power measuring system experimenting

Tested HA Rating Power Measured Power/ Percentage Error/ %


(Nominal)/Watts Watts
Fridge 500 495.43 0.914

Bulb 600 608.16 1.360

Iron 1000 1009.74 0.974

TV 150 150.7 0.467

Vacuum Cleaner 2000 2038.04 1.902

AC Conditioner 1000 1001 0.181

Dishwasher 1500 1520.26 1.350

Average Percentage Error % 1.021

48
Results

The final average percentage error is 1.021%. This percentage is accepted as it is within the range of
the accepted experimental error. And if any or all of the power readings differ by this value, the
control algorithm results will not be affected at all.

Control algorithm scheme results

The main goal of the smart power monitoring and management system is to monitor the power
consumption of all the house appliances in real time, and to be capable of turning ON/OFF some
of the appliances to keep the power consumption in the house below 4kW at all times .

The performance of the control algorithm scheme was tested by applying several trials as indicated
in Table 4.3. It should be noted that the fridge should always be ON in all the cases. The trials are
thoroughly explained after the table.

Table ‎4.3: Smart power monitoring and management system experimenting

HA’s HA’s Trial 1 2 3 4 5 6 7


Priority Type Number
Rank

1 Fridge ON ON ON ON ON ON ON

2 Bulb ON ON ON ON ON ON OFF

3 Iron ON ON OFF ON OFF ON OFF

4 TV ON ON OFF ON ON ON OFF

5 Vacuum Cleaner OFF OFF ON ON ON ON ON

6 AC Conditioner ON OFF OFF ON ON OFF OFF

7 Dishwasher OFF ON OFF ON ON ON ON

The green cell represent the ON state appliance

The red cell represent the OFF state appliance

The yellow cell represent the paused state appliance

49
Results

Trial 1

When turning on the fridge, bulb, iron, TV and the air conditioner respectively while turning off
the vacuum cleaner and the dishwasher, the total power consumption was 3250 W.

3250W < 4000 W (The maximum allowed power consumption limit)

Trial 2

When turning on the fridge, bulb, iron, TV and the dishwasher respectively while turning off the
vacuum cleaner and the air conditioner , the total power consumption was 3750 W.

3750W < 4000 W (The maximum allowed power consumption limit)

Trial 3

When turning on the fridge, bulb and vacuum cleaner respectively while turning off all the other
appliances , the total power consumption was 3100 W.

3100 W < 4000 W (The maximum allowed power consumption limit)

Trial 4

When turning on the fridge, bulb, iron and TV, the system is in the stable mode as the power
consumption didn’t exceed the threshold. Then when turning on the vacuum cleaner the system
allowed it to be on for a short while but as the total power consumption reached 4250W, the
system turned it off and put it in the appliances paused list.

The total power returned to 2250W, with a 1750W available power opening place for other
appliances to be turned on without exceeding the defined limit. So by turning on the air conditioner
the total power consumption of the system was 3250W < 4000 W (The maximum allowed power
consumption limit).

Then when turning the dishwasher on, the system allowed it to be on for a short while and then it
was turned off and put in the appliances paused list as the total power consumption reached
4750W. After turning it off, the total power returned to 3250W, with a 750W available power.

50
Results

The vacuum cleaner and the dishwasher were turned off as to maintain the system below the
4000W consumption and due to their priority order. As they were saved in the paused list, they will
be turned on immediately if some of the higher priority appliances turned off by the user and if
there is enough power available for them without exceeding the predefined limit.

Trial 5

Turing on the fridge, bulbs, TV and the vacuum cleaner respectively, while turning off the iron.
The total power consumption of the system was 3250W < 4000 W (The maximum allowed power
consumption limit). When trying to turn the air conditioner on and the dishwasher, the system will
turn them on for a short duration of time to test if there is a place for them, and then they were
turned off and put in the appliances paused list as the total power consumption exceeded the
threshold limit in both cases.

Trial 6

As on trial 4 when turning on the fridge, bulb, iron and TV, the system was in the stable mode as
the power consumption didn’t exceed the threshold. Then when turning on the vacuum cleaner the
system turned it on for a short while and then turned it off and put in the appliances paused list as
the total power consumption reached 4250W.

The total power returned to 2250W, with a 1750W available power opening place for other
appliances to be turned on without exceeding the defined limit. So by turning the dishwasher the
total power consumption of the system was 3750W < 4000 W (The maximum allowed power
consumption limit).

Trial 7

When turning on the fridge, vacuum cleaner, and dishwasher, respectively while turning off all the
other appliances the total power consumption was 4000W, reaching in this case the maximum
power consumption limit. No actions were taken by the system.

From the trials above, it is noted that the system only operates when required and performs its
required operations correctly and in a smart efficient manner.

51
Results

4.4 Validation of requirements and constraints

4.4.1 Design Requirements:

 Power Requirement: From the trials in the section before, it can be found that the power
requirement was met during the whole time, and the power consumed did not exceed the
desired limit.
 Time Requirement: The part of the code responsible for turning off the appliance took 2
milliseconds (ms). See Figure 4.3 which shows the time before turning off the devices (706
ms) and the time after the devices were turned off (708 ms). The time requirement specifies
that the response time in case of power increase above specified limit must be less than 2
power cycles (0.04 seconds for a 50Hz system), and this requirement was met in the turning
off process. But for the turning on process of the HAs, a delay of 200 ms was needed in
testing each appliance to avoid inrush currents in order to obtain correct current and power
values, so the time requirement in this part of the control process was not met due to
uncontrolled hardware behaviors.

Figure ‎4.3: Time taken to turn off

4.4.2 Realistic constraints:

 Economic Constraints:
The cost of the main components was not very high, and most of the used motors and devices
were taken for free or purchased by a relatively low cost, the cost of the final design was close
to 200JDs, so the economic constraint was met

52
Results

 Environmental constraints:
The noises coming from the induction motors were reduced as much as possible, by inserting
the motors inside wooden boxes. The noise produced was still audible but it was reduced as
much as possible.

 Ethical constraints:
The ethical constraints were met as follow:
A. Some electrical parameters of the modeled home appliances were ignored and not taken into
consideration as the used parameters were taken from the modeled devices, then the power was
multiplied by a factor.
B. The system operates in single house without any data integration with any external server, so no
one besides the user is able to obtain any data. If the system is upgraded in the future to
monitor data in more than one house, the data sent will be encrypted and protected to ensure
the safety of information, and if the collected data is used for any statistical calculations, the
user will be informed and his permission will be taken.
C. All the codes and papers were referenced.

 Safety constraints:
The safety constraints were met as follows:
A. Working with single phase 50Hz 220Vrm voltage sources, and measuring relatively high
currents passing through the loads, all the wires were insulated correctly and safely in a manner
to not cause harm to the circuitry of any hazards to the users.
B. Short circuits and electrocutions' happened once in the testing phase, but during the final
prototype setup, each connection was checked at least three time to avoid such faults.
C. All the devices were stored inside wooden boxes, so the interface between the devices and the
user was minimized as some of the appliances were poorly insulated.
D. A water heater used to represent an iron was kept in cold water as a heat sink as the heater's
temperature rises quickly to very high temperatures, and the water was changed continuously to
avoid any injuries.
E. The wooden boxes limited the ability of the motor to move and cause any unfavorable
accidents, because the type of the chosen wooden boxes was heavy enough to tolerate the
weight, vibration and the movement of the used induction motors.

53
Results

F. Fans were used to model some HAs; they were mechanically isolated from users by inserting
them into the wooden boxes to have the minimal interface between them and the user as their
blades are dangerous.

 Manufacturability constraints:
The manufacturability constraints were met as follow:
A. The complexity of the wiring was solved by using different wire colors for different nodes and
connection and the colors were systemized. Wires of studied lengths were used, and the wires
were grouped to keep the connection as simple and as organized as possible.
B. The minimum measured current by the current sensor is 100mA, HAs were chosen to
withdraw more than this amount so all the values of the currents were successfully measured.
C. Noise of the sensor at zero current and all values were present, and were treated by linear and
nonlinear calibration equations. The equations were successful and the noise was reduced.
D. The noise caused by near fluxes of other devices affected the reading of the current sensors.
They were reduced to the minimal amount by covering the current sensor by aluminum foil
metal sheets and by keep the sensor as far away from other wires as possible.
E. Low power factors of some induction motors as they are running at no load; the problem was
solved by multiplying the power values by a scale. And the required modeled power values were
achieved.

54
Conclusion and Future Work

5 Conclusion and Future Work


Electrical energy is one of the largest discoveries in human life, diverse electrical appliances and
applications have been discovered resulting in a huge revolution in humans' life. Proceeding from
the importance of electricity, another important consideration arises that is power consumption
provisioning.

Multiple models and frameworks came to serve as solutions for optimizing the energy
consumption. The smart power monitoring and management system served not just as a high level
solution for energy consumption optimization, but as an attractive system for homeowners to
pursue for reducing their electricity bill, protecting the environment and prevent blackouts.

The system proved its intelligence in dealing with all possible cases, and proved its high accuracy.
The system is very applicable on a domestic house to house level. The priority algorithm proposed
is very flexible and smart enough not to cause any disturbing during daily lives.

Regarding future work, many suggestions could be proposed as follows:

 Applying a complete power meter system that is capable to measure all the electric parameter of
each appliance such as the operating times, the power factor...etc.
 Enabling users to define the appliances priorities according to their lifestyles.
 Enabling users to introduce as many appliances as required
 Adding a data logging system that is connected with the consumers’ cell phones, which records
all the electric consumption profiles for each appliance. Allowing the consumers to monitor
their homes, even if they are away
 Adding a data logging system that is connected with the consumers’ cell phone, which enables
users to control the system and the appliances wirelessly.
 Beside the logger there should be a reporting system that monitors the system performance in
general along with pricing unit for estimating the electricity bill for the consumer.
 Applying this system in household sector by exchanging the hardware components with more
reliable modules that suit the big systems implementations.

55
References

6 References
[1] "‫ من استهالك الكهرباء‬% 43 ‫"القطاع المنزلي يستحوذ على‬, ‫جريدة الغد‬, 2015. [Online]. Available:
http://www.alghad.com/articles/910492 .
[2] Umer, Saher, Yasuo Tan, and Azman Osman Lim. "Priority based power sharing scheme for
power consumption control in smart homes."
[3] Rastegar, Mohammad, Mahmud Fotuhi-Firuzabad, and Hamidreza Zareipour. "Home energy
management incorporating operational priority of appliances." International Journal of
Electrical Power & Energy Systems 74 (2016): 286-292.
[4] Busquet, Ana Rossello, et al. "Reducing Electricity Demand Peaks by Scheduling Home
Appliances Usage." Energy Systems and Technologies for the Coming Century (2011).
[5] Barker, Sean. Model-driven analytics of energy meter data in smart homes. Diss. University of
Massachusetts Amherst, 2014.‫‏‬
[6] Pipattanasomporn, Manisa, et al. "Load profiles of selected major household appliances and
their demand response opportunities." IEEE Transactions on Smart Grid 5.2 (2014): 742-750.
[7] "Arduino - Introduction", Arduino.cc. [Online]. Available:
https://www.arduino.cc/en/Guide/Introduction .
[8] ACS712, Datasheet. "Fully Integrated, Hall effect-Based Linear Current Sensor IC with 2.1
kVRMS Isolation and a Low-Resistance Current Conductor." (2006).
[9] "Single Phase Induction Motor | Electrical4u", Electrical4u.com. [Online]. Available:
http://www.electrical4u.com/single-phase-induction-motor/.
[10] A. Subeih, A. AlGhababsheh, and I. Hattar, “Design of a Consumer-Side Load Shifting
Scheme for Improving Domestic Load Profile,” Princess Sumaya University for Technology,
Amman-Jordan, 2015.
[11] "Power Consumption of Typical Household Appliances", Daftlogic.com. [Online]. Available:
https://www.daftlogic.com/information-appliance-power-consumption.htm .
[12] “Current Sensing Code.” 26-Sep-2015.
[13] Z. Zhao, “An Optimal Power Scheduling Method Applied in Home Energy Management
System Based on Demand Response,” ETRI Journal, vol. 35, no. 4, pp. 677–686, Aug. 2013.
[14] M. Santinato, E. Arione, and G. Braghini, Electronic system for power consumption management of
appliances. Google Patents, 2003.

56
References

[15] A. Agnetis, G. de Pascale, P. Detti, and A. Vicino, “Load Scheduling for Household Energy
Consumption Optimization,” IEEE Transactions on Smart Grid, vol. 4, no. 4, pp. 2364–2373,
Dec. 2013.
[16] M. Safdar, M. Ahmad, A. Hussain, and M. Lehtonen, “Optimized residential load scheduling
under user defined constraints in a real-time tariff paradigm,” in Electric Power Engineering (EPE),
2016 17th International Scientific Conference on, 2016, pp. 1–6.
[17] A. Vyavhare, S. Tejaswini, and S. Rao, “Priority-Based Scheduling of Smart Appliances With a
Renewable Energy Source,” 2014.
[18] G. Xiong, C. Chen, S. Kishore, and A. Yener, “Smart (in-home) power scheduling for demand
response on the smart grid,” in Innovative smart grid technologies (ISGT), 2011 IEEE PES, 2011,
pp. 1–7.
[19] Aswani, R. N. "c" Home Energy Management System for High Power–intensive Loads,"."
Emerging Trends in Electrical, Electronics & Instrumentation Engineering: An international
Journal (EEIEJ) 1 (2014): 9-17.
[20] S. Björg Sigurjónsdóttir, “Monitoring and reducing the consumption of home electric
appliances,” University of Groningen, 2013.
[21] Electrical Appliance Typical Energy Consumption Table, 1st ed. . . .
[22] W. [duplicate], "What does "load" mean and what are the different types?",
Electronics.stackexchange.com. [Online]. Available:
http://electronics.stackexchange.com/questions/91975/what-does-load-mean-and-what-are-
the-different-types.
[23] "types of loads", http://electrical-engineering-course.blogspot.com/. [Online]. Available:
http://electrical-engineering-course.blogspot.com/2011/06/types-of-loads.html .
[24] "types of loads", types of loads, 2011. .
[25] b. ev ans, arduino programming notebook, 1st ed. brian evans, 2007.
[26] 8.0A GLASS PASSIVATED BRIDGE RECTIFIER, 1st ed.
[27] "Arduino - ArduinoBoardMega", Arduino.cc. [Online]. Available:
https://www.arduino.cc/en/Main/arduinoBoardMega .

57
Appendices

7 Appendices
7.1 Appendix A

1. #include <MemoryFree.h>
2. #include <pgmStrToRAM.h>
3. #include <StandardCplusplus.h>
4. #include <system_configuration.h>
5. #include <unwind-cxx.h>
6. #include <utility.h>
7. #include <algorithm>
8. #include <stdio.h>
9. #include <map>

10. using namespace std;

11. #define RELAY1 3


12. #define RELAY2 4
13. #define RELAY3 5
14. #define RELAY4 6
15. #define RELAY5 7
16. #define RELAY6 8
17. #define RELAY7 9

18. float current = 0;


19. const unsigned long sampleTime = 100000UL; // sample over 100ms, it is
an exact number of cycles for both 50Hz and 60Hz mains
20. const unsigned long numSamples = 250UL; // choose the number of
samples to divide sampleTime exactly, but low enough for the ADC to keep up

58
Appendices

21. const unsigned long sampleInterval = sampleTime / numSamples; // the sampling


interval, must be longer than then ADC conversion time
22. const int adc_zero = 510; // relative digital zero of the arudino input from ACS712 (could
make this a variable and auto-adjust it)
23. float y, z;

24. unsigned long start, t1, t2;

25. float currents[7] = {};


26. float offset[7] = { -0.07, 0.09, -0.05, 0.02, 0, 0.04, -0.33 };
27. float pf[7] = { 0.905, 1, 1, 1, 0.92, 0.49, 0.34 };
28. float scale[7] = { 4.74, 6, 1.235 ,1.68, 14.3, 33.13, 11.73 };
29. float power[7] = {};
30. float power2[7];
31. const int N = 7;
32. bool userState[7] = {};
33. bool relay[7] = { 1, 1, 1, 1, 1, 1, 1 }; //relay 0 means off, 1 means on

34. int button = 0;


35. const int buttonPin = 13;

36. void setup()


37. {
38. Serial.begin(9600);
39. pinMode(RELAY1, OUTPUT);
40. digitalWrite(RELAY1, HIGH);
41. pinMode(RELAY2, OUTPUT);
42. digitalWrite(RELAY2, HIGH);

59
Appendices

43. pinMode(RELAY3, OUTPUT);


44. digitalWrite(RELAY3, HIGH);
45. pinMode(RELAY4, OUTPUT);
46. digitalWrite(RELAY4, HIGH);
47. pinMode(RELAY5, OUTPUT);
48. digitalWrite(RELAY5, HIGH);
49. pinMode(RELAY6, OUTPUT);
50. digitalWrite(RELAY6, HIGH);
51. pinMode(RELAY7, OUTPUT);
52. digitalWrite(RELAY7, HIGH);
53. pinMode(buttonPin, INPUT);
54. }

55. void loop() {

56. button = digitalRead(buttonPin);


57. if (button)

58. /* start = millis ();


59. Serial.println("loop begin");
60. displayResult( start);*/

61. for (int i = 0; i < 7; ++i) {


62. currents[i] = CurrentSense(i);
63. currents[i] += offset[i];
64. power[i] = 220 * currents[i] * pf[i] * scale[i];
65. power2[i]=max(power2[i],power[i]);
66. if (currents[i]<0.1) {

60
Appendices

67. currents[i] = 0;
68. power[i] = 0;
69. }
70. if (power[i] > 0)
71. userState[i] = 1;
72. else
73. { userState[i] = 0;}
74. Serial.print(i); Serial.println(" current " ); Serial.println(currents[i]);
75. Serial.print(i); Serial.println(" power " ); Serial.println(power[i]);
76. }
77. control(4000);
78. }

79. float CurrentSense(int x)


80. {
81. unsigned long currentAcc = 0;
82. unsigned int count = 0;
83. unsigned long prevMicros = micros() - sampleInterval;
84. while (count <numSamples)
85. {
86. if (micros() - prevMicros >= sampleInterval)
87. {
88. int adc_raw = analogRead(x) - adc_zero;
89. currentAcc += (unsigned long)(adc_raw * adc_raw);
90. ++count;
91. prevMicros += sampleInterval;
92. }
93. }

94. float rms = sqrt((float)currentAcc / (float)numSamples) * (50 / 1024.0);

61
Appendices

95. rms = rms - 0.101; //final reading calibration and noise reduction
96. if (rms < 0.2) { rms = 0; }
97. if (rms>0.2 && rms<0.6) { rms = (-700.4*(pow(rms, 6))) + (1821 * (pow(rms, 5))) + (-
1890 * (pow(rms, 4))) + (999 * (pow(rms, 3))) + (-283.1*(pow(rms, 2))) + (41.56*(rms)) -
(2.347); }
98. else if (rms>0.6 && rms<2) { rms = (-0.004*(pow(rms, 5))) + (0.064*(pow(rms, 4))) + (-
0.37*(pow(rms, 3))) + (0.965*(pow(rms, 2))) + (-0.462*(rms)) + (0.554); }
99. else if (rms>2.0) { rms = (-0.061*pow(rms, 3)) + (0.871*pow(rms, 2)) + (-3.189*(rms)) +
(5.511); }
100. return rms;
101. }

102. void control(float fullpower) {


103. //Serial.println( fullpower,6);
104. vector<int>tmp, tmp2;
105. /*t1=millis();
106. Serial.println("before off");
107. displayResult( t1);*/

108. for (int i = 0; i < N; ++i) {


109. if (relay[i] == 0) //store which devices are off in tmp
110. tmp.push_back(i);
111. if (relay[i] && userState[i]) {
112. if (power[i] <= fullpower) { // turning off devices of less priority if full power
exceeded
113. relay[i] = 1;

62
Appendices

114. fullpower -= power[i];


115. }
116. else {
117. digitalWrite(i + 3, LOW);
118. relay[i] = 0;
119. }
120. }
121. }
122. /*t2=millis();
123. Serial.println("after off");
124. displayResult( t2);*/

125. delay (500);


126. // Serial.println(fullpower,6);
127. //for(int j=0;j<tmp.size();++j)
128. //Serial.println(tmp[j]);

129. for (int j = 0; j < tmp.size() ; ++j) // for loop run the number of stored off devices
130. {
131. int s = tmp[j]; //s is the position of the off-device
132. int newPower=fullpower;
133. for(int k=s+1;k<N;++k){
134. if(userState[k] && relay[k])
135. newPower+=power[k]; //power if next device is off
136. }

137. if(power2[s]>0 && power2[s]>(newPower))


138. continue; // if no place for current device, go to next one

63
Appendices

139. relay[s] = 1; // turn on the off device to check if there is a place for it to be on
140. digitalWrite(s + 3, HIGH);

141. delay (200); //delay to avoid inrush currents


142. currents[s] = CurrentSense(s);
143. currents[s] += offset[s];
144. power[s] = 220 * currents[s] * pf[s] * scale[s];
145. power2[s]=max(power2[s],power[s]);

146. if (currents[s]<0.1) {
147. currents[s] = 0;
148. power[s] = 0;
149. }
150. if (power[s] > 0)
151. userState[s] = 1;
152. else
153. userState[s] = 0;

154. if (relay[s] && userState[s]) {


155. if (power[s]<newPower) {
156. digitalWrite(s + 3, HIGH); // turn it on if possible
157. relay[s] = 1;
158. }
159. else {
160. digitalWrite(s + 3, LOW);
161. relay[s] = 0;
162. continue; //skip to next device

64
Appendices

163. }
164. }

165. for (int k = s + 1; k < N && power[s] > fullpower; ++k) {// starting from the
next device on priority, turn off devices of lower p if on

166. if (relay[k] && userState[k]) {


167. fullpower += power[k];
168. relay[k] = 0;
169. digitalWrite(k + 3, LOW); //turn off next device
170. }
171. }
172. if (fullpower>= power[s])
173. fullpower -= power[s];
174. else
175. {digitalWrite(s+3, LOW); //turn current device off if no place for it
176. relay[s]=0;}

177. }}

178. void displayResult( long x)


179. {
180. float h,m,s,ms;
181. unsigned long over;

182. h=int(x/3600000);
183. over=x%3600000;

65
Appendices

184. m=int(over/60000);
185. over=over%60000;
186. s=int(over/1000);
187. ms=over%1000;
188. Serial.print("Raw elapsed time: ");
189. Serial.println(x);
190. Serial.print("Elapsed time: ");
191. Serial.print(h,0);
192. Serial.print("h ");
193. Serial.print(m,0);
194. Serial.print("m ");
195. Serial.print(s,0);
196. Serial.print("s ");
197. Serial.print(ms,0);
198. Serial.println("ms");
199. Serial.println();
200. }

7.2 Appendix B:

Figure ‎7.1: Final design of the system

66

You might also like