Professional Documents
Culture Documents
Made by:
Ahmed Okasha,
Mohammad Ayesh,
Fadi Al-fuqha,
Enas Abu-sharhan
1
Acknowledgment
In the name of God, the infinitely Compassionate and Merciful.Praise be to
ALLAH, who guided us in the darkness to the right path. We are grateful for his
Prophet Muhammad (P.B.U.H) for giving us the inspiration and strength to do the
best in our life. Our families have always been on our side in the time we needed
them the most giving us love and hope. Without them our work would never see
the light. We would like to thank our supervisor Dr. Anas Al Majali for guiding us
in the right direction throughout the project. He has been a great support.
Finally we would like to thank our department and our friends fortheir
encouragement and understanding.
2
Abstract
The aim of this project is to design and implement a home automation system that
controls and organizes various home appliances. The user (i.e. home owner)
controls his home appliances using his smart phone. The home automation system
processes user direct commands, user preferences and data received from various
sensors to control home appliances.
The project is implemented in hardware and software components that interact
through network connections. The main challenge is to implement the project in
an economical way such that it can be easily deployed and used by homeowners.
An Arduino microcontroller and a mobile phone with an Android platform running
on top of it are the hardware and software used. For the network part, an apache
local server is used to make a connection between the microcontroller and the
mobile phone and allow data transfer to take place in an efficient matter.
Different functions are implemented using this system which includes the
following:
Manually controlled by smart phone application:
1. Open and close garage door.
2. Switch fan on/off.
3. Switch water tank motor on/off.
4. Switch led on/off
3
Table of Contents
Chapter 1: Introduction ................................................................................................................................ 1
1.1 Related work ....................................................................................................................................... 3
Project 1: Smart Home-Control and Monitoring System Using Smart Phone ...................................... 3
Project 2: Pratik Gadtaula Home Automation ...................................................................................... 4
Chapter 2 Requirements and Design ............................................................................................................ 6
Chapter 3 Implementation............................................................................................................................ 9
3.1: Hardware implementation ................................................................................................................ 9
3.1.1Raspberry Pi verses Arduino ......................................................................................................... 9
3.1.2 Sensors ....................................................................................................................................... 11
3.1.3 Motors........................................................................................................................................ 15
3.2 Software implementation ................................................................................................................. 17
3.2.1XAMPP......................................................................................................................................... 17
3.2.2Apache ........................................................................................................................................ 17
3.2.3 PHP ............................................................................................................................................. 17
3.2.4 Arduino IDE ................................................................................................................................ 17
3.2.5 Android....................................................................................................................................... 17
3.2.6 Android studio............................................................................................................................ 18
3.3 Connectivity ...................................................................................................................................... 19
3.3.1 Wi-Fi versus Bluetooth ............................................................................................................... 19
3.3.2 Server ......................................................................................................................................... 22
Chapter 4 User guide .................................................................................................................................. 24
From Arduino-side : ................................................................................................................................ 24
Router-side:............................................................................................................................................. 25
Server-side: ............................................................................................................................................. 26
Android side: ........................................................................................................................................... 27
Chapter 5 Conclusion and Future work ...................................................................................................... 34
5.1 Conclusion. ........................................................................................................................................ 34
5.2 Limitations and future work ............................................................................................................. 34
References .................................................................................................................................................. 35
i
LIST OF FIGURES
FIGURE 1 SHOWS THE ARCHITECTURE FOR THE PROJECT ............................................................................... 3
FIGURE 2 SHOWS THE ARCHITECTURE FOR THE PROJECT ............................................................................... 4
FIGURE 3 ARDUINO TO ANDROID SUMMARY.............................................................................................. 6
FIGURE 4 ANDROID TO ARDUINO SUMMARY.............................................................................................. 7
FIGURE 5SYSTEMATIC DIAGRAM FOR THE ULTRA SONIC SENSOR. ................................................................. 11
FIGURE 6 SHOWS SYSTEMATIC DIAGRAM FOR THE PIR SENSOR. .................................................................. 12
FIGURE 7 SHOWS THE SYSTEMATIC DIAGRAM OF THE LDR WITH RESULTS WHEN THE LIGHT SOURCE IS ON ............ 13
FIGURE 8 SHOWS THE SYSTEMATIC DIAGRAM OF THE LDR WITH RESULTS WHEN THE LIGHT SOURCE IS OFF ........... 13
FIGURE 9 SHOWS SYSTEMATIC DIAGRAM FOR TEMPERATURE SENSOR. ........................................................... 14
FIGURE 10SHOWS SYSTEMATIC DIAGRAM FOR THE BRIDGE TO WHICH THE DC MOTOR WILL BE CONNECTED ......... 15
FIGURE 11 SHOWS A DC MOTOR........................................................................................................... 16
FIGURE 12 SHOWS ASERVO MOTOR ....................................................................................................... 16
FIGURE 13 SHOWS SERVO WORKING MECHANISM ..................................................................................... 16
FIGURE 14 AN ARDUINO UNO WITH AN ETHERNET SHIELD......................................................................... 24
FIGURE 15 SHOWS BACK OF A ROUTER ................................................................................................... 25
FIGURE 16 SHOWS CMD RESULT ............................................................................................................ 26
FIGURE 17 SHOWS THE STARTUP OF THE APPLICATION ............................................................................... 27
FIGURE 18 SHOWS THE LED SWITCH BUTTON WHEN PRESSED ..................................................................... 27
FIGURE 19 SHOWS HOW TO TOGGLE MANUAL MODE................................................................................. 28
FIGURE 20 SHOWS HOW TO TOGGLE FAN SWICTH ON AND OFF ................................................................... 28
FIGURE 21 SHOWS HOW TO TOGGLE GARAGE DOOR SWITCH ON AND OFF .................................................... 29
FIGURE 22 SHOWS HOW TO TOGGLE WATER PUMP SWICTH ON AND OFF ...................................................... 29
FIGURE 23 SHOWS HOW TO TOGGLE AUTOMATIC MODE............................................................................ 30
FIGURE 24 SHOWS THE AUTOMATIC MODE OF THE FAN.............................................................................. 30
FIGURE 25 SHOWS THE AUTOMATIC MODE OF THE FAN.............................................................................. 31
FIGURE 26SHOWS THE AUTOMATIC MODE OF WATER PUMP ....................................................................... 31
FIGURE 27 SHOWS THE AUTOMATIC MODE FOR WATER PUMP MOTOR .......................................................... 32
ii
List of Tables
TABLE 1 COMPARISON BETWEEN ARDUINO AND RASPBERRY PI .................................................................... 10
TABLE 3 SHOWS THE ILLUMINATION FRO DIFFERENT SOURCES...................................................................... 13
TABLE 3 WIFI AND BLUETOOTH COMPARISON .......................................................................................... 21
iiii
Chapter 1 Introduction
ii
Chapter 1: Introduction
In an era where the technology accelerates increasingly, microchips made a huge step in the
digital revolution. Mobile phones, vehicles, embedded systems are getting smarter and more
powerful each day, and helping the human being face challenges and problems regarding time,
economics, environment and communication from a different perspective.
Today, technology made its way through to be one of main essentials for humans to have a
comfort lifestyle or even surviving in some cases. It is a matter of time until everything will be
smart enough and will be connected to the internet. They will be communicating without the
interference of humans themselves.
Technology has pros and cons, for many reasons it has been argued that technology is not rising
the human race because of the downside effects which includes both laziness of body and mind,
having personal security problems etc.
We think that the positive side is the more dominate due to the pros which includes having more
safety in our transportation vehicles, homes, getting a better healthcare, solving security
problems. In addition, technology provides us more time for different activities.
As a part of the automation league, our homes are following too. Home Automation System,
which is implemented in this project, is considered part of the internet of things concept. The
vision which will consist of 50 billion devices by 2020.[1]
Home automation System consists of microcontrollers and sensors connected together via
different communication models. There is no single way to implement it as we will discuss later.
Its applications are mainly found according to the needs of the user and considering his budget
too.
As a function of the Home Automation System for example, microcontrollers are programmed to
shut down the unused home appliances thus decreasing unnecessary power consumption and
saving power, energy and bills for a single home user. However, implementing it country-wide;
the overall decrease in the consumption can be noticed.
1
This documentation contains 5 chapters described briefly as follows: Chapter 2 discusses the
user requirements in project to make a specific design. Chapter 3 describes implementation of
the project and it is divided into three subsections. Hardware implementationdiscusses hardware
components that include sensors, motors and microcontrollers. Software implementation that
includes software components used in this project which includes XAMPP, Android platform
and different programs which provides an environment for code. And the third subsection which
discusses connectivity. Chapter 4 is a user guide for normal users. Chapter 5 discusses the
limitation in the project and future work for upgrades in the project. And gives a brief
conclusion.
2
1.1 Related work
Project 1: Smart Home-Control and Monitoring System Using Smart
Phone
The architecture used in this paper is designed based on low cost and flexible home automation
system. The monitoring system uses an embedded micro-web server and Android based smart
phone with built in support for Wi-Fi to control and access the devices at home.
The architecture is divided into home environment and remote environment. In home
environment we have Arduino device working in coordinate with sensors/devices for receiving
sensor information and controlling devices accordingly. The system consists of a micro Web-
server based on Arduino Ethernet-Shield and Router to make the access available for the other
devices.
Remote environment has the functionality of monitoring using Android based Smart phone.
Therefore any Android based Smart phone with built in support for Wi-Fi can be used to access
and control the devices at home.
3
Project 2: Pratik GadtaulaHome Automation
The architecture used in this thesis is divided into three zones: Home zone, Central Server and
Monitoring Devices. In home zone we have central Raspberry-PI and Arduino device working in
coordination with sensors/devices for receiving sensor information and controlling devices
accordingly.
The web server and the database in the raspberry Pi provided access for Database management
and viewing created webpage in browser.
Monitoring devices such laptops and smart phones is monitoring the information using web
services on browser screen of these devices and information can be known from anywhere and
anytime [2].
4
Chapter 2 Requirements and
Design
5
Chapter 2 Requirements and Design
This chapter sets the project design based on the user requirements. To do so, we first define the
type of project users.
There are two types of users:
1. The user who can get into code level of the project and adjust the parameters and
functions of the project. We call them the administrators. They have the authority to
access and maintain the project code and hardware components accordingly.
2. The second type of users are the normal users. The project is designed according to their
needs. They have no authority access to the code and cannot maintain the hardware
components.
The following graph summarizes how data from the sensors are displayed on smartphones
screen.
The smartphone
The server connected on
connected on same LAN
same LAN accepts the
gets the updated values
data and updates the
and display them on
database.
screen .
6
The following graph summarizes how data from the smartphonearereadon the Arduino.
Commands from
Server accepts the
the samrtphone are
data and updates
sent to the local
the database
server.
Accodring to the
Arduino reads data data , the arduino
from the database performs differnet
functions.
7
Chapter 3 Implementation
8
Chapter 3 Implementation
This chapter discusses the implementation of the project from three perspectives. Hardware,
Software and connectivity.
9
Arduino have a 'real-time' and 'analog' capability that the Pi do not provide. This flexibility
allows it to work with just about any kind of sensor or chips. Raspberry Pi does not offer such
flexibility; i.e. reading from analog sensors requires extra hardware assistance. Table 1
summarizes the comparison. We used Arduino for its cost and flexibility [3][4].
10
3.1.2 Sensors
A Sensor is an electronic device which detects different physical changes in the surrounding. The
output of the sensor is a signal generated which can be transferred and processed to extract
further information or to make another device respond in a certain way. The project contains
different types of sensors to perform further tasks.
3.1.2.1 Ultrasonic sensor
Ultrasonic sensor is a device calculates the distance of objects by emitting a sound wave pulse
which reflects off objects. The reflected pulse which is called echo is received by the sensor.
The actual value evaluated is the time between the emitted and received pulse. Newtons law of
motion is used to calculate the distance of the observed time.
The module used in this project is Ultrasonic Ranging Module HC - SR04.
In the project Ultra Sonic Sensor is used to measure the height of the water in tank and according
to the output, the microcontroller will turn the water tank motor system on/off.
The module has the following features:
Ultrasonic ranging from 2cm - 400cm distance measurement, the ranging accuracy can reach to
3mm with trigger Input Signal 10uS TTL pulse and Echo Output Signal Input TTL lever signal.
[5]
11
3.1.2.2 Motion sensor
PIR (Passive Infrared Sensor) is made of materials sensitive to IR. As an object that radiate heat
such as human beings or animals, they cause a positive differential change in the IR levels in the
sensor and as the warm body leaves the range of the sensor, the sensor generates a negative
differential change. These changes in the pulses are the signals that are detected.
In the project PIR Sensor is used to detect motion and according to the output signals the
microcontroller will turn lights on/off in a room.
The module has the following features:
PIR sensors can detect motion from a range of 6 meters away with adjustable delay before firing
(approx. 2-4 seconds) and adjustable sensitivity.[5]
12
3.1.2.3 Light Dependent Resistor
Light dependent Resistor or LDR is a variable resistor sensitive to light intensity in according to the
photoelectric effect. The effect frees electrons proportional to the flux of light shines. The unit observed
in the microcontroller is the electric pressure. In the project LDR is used to adjust the light intensity
outdoors.
Figure 7shows the systematic diagram of the LDR with results when the light source is on (led is off)
Figure 8shows the systematic diagram of the LDR with results when the light source is off (led is on)
13
3.1.2.4 Temperature Sensor
Temperature sensor is an electronic component sensitive to the temperature degree. The
sensitivity differs according to the industrial process. The unit observed in the microcontroller is
the electric pressure. The temperature is evaluated by observing the increase of the voltage of the
sensor with the increase of temperature degree.
In the project Temperature sensor is used to measure the temperature in a room and send the data
to Arduino which in turn switches the fan on/off.
The module has features such as linear + 10-mV/C scale factor, calibrated directly in Celsius
(Centigrade), 0.5C ensured accuracy (at 25C), and rated for full (55 C to 150C)range.[6]
14
3.1.3 Motors
Motor is a machine that converts a form of energy to mechanical energy. This project uses
electrical energy to power the motor.
3.1.3.1 DC Motor
DC motor is an electrical motor that converts electrical energy from power source into
mechanical energy. We are not concerned about the structure of the motor as much as the
functionality [9].
In this project the DC motor is used to spin as a fan when the microcontroller triggers it.
Figure 10shows systematic diagram for the bridge to which the DC motor will be connected
15
3.1.3.2 Servo motor
Servos are controlled by sending an electrical pulse of variable width, or pulse width
modulation (PWM)through the control wire (Figure 13). There is a minimum pulse, a maximum
pulse, and a repetition rate.
Servo motors can usually only turn 90 degrees in either direction for a total of 180 degree
movement. There are two types of servo motors AC and DC. Figure 9 shows how a servo motor
works.
The project uses servo motor to open and close the garage door.
16
3.2 Software implementation
This chapter discusses the project from the software perspective. The programs and platforms
used.
3.2.1XAMPP
XAMPP package is a free and open source programs that creates a local web server without any
difficulties. XAMPP stands for Cross-Platform (X), Apache (A), MariaDB (M), PHP (P) and
Perl (P). It can be installed on different platforms including Windows [7].
3.2.2Apache
Apache web server is a web server application that helps to deliver web content to be accessed
through the internet. It is an open source HTTP serverandit is fast, reliable, and secure [8].
3.2.3 PHP
PHP (recursive acronym for PHP: Hypertext Preprocessor) is a widely-used open source
general-purpose scripting language that is used for web development [9].
3.2.5 Android
Android is open source system and based on the Linux kernel, it is designed for devices with
touch screens, it is providing a testing and debugging tools for application.
The programming language used in Android is Java, Android has SQL data base to store data,
also it use the Android Software Development Kit which It is a process that is to use the creation
of new applications running on Android. Android platform supports different connection
technologies including Wi-Fi.
17
Advantages of using Android.
Using Android we can access core mobile device functionality.
Easy development since it contains SDK, which provides build, run and debugging Android
applications.
Android Studio is used for programming Android applications. It gives programmers graphical
tools for creating Android apps,it is provide a test for application projects that run on a
device[12].
18
3.3 Connectivity
This chapter discusses the project from the network perspective and answers how are the
Arduino and android communicating? What are the different models used? And a comparison
between different network technologies.
3.3.1.1 Wi-Fi
Wi-Fi is a wireless technology based on IEEE 802.11. It uses microwaves to create
communication through devices known as routers. It has great potential, but, as with any other
technology, along with the advantages, there are disadvantages.
Advantages of Wi-Fi:
The main advantages of Wi-Fi are the lack of wires. And it is used to connect a variety of
devices, not only between themselves but also to the Internet. Another advantage is to create a
mesh Wi-Fi. To connect a new device to your network, simply turn on the Wi-Fi and do the
simple setting in the software.
Standardization of Wi-Fi technology allows you to connect to the network in any country. Wi-Fi
allows us to achieve high compatibility.
Disadvantages of Wi-Fi:
Wi-Fi is sensitive to electromagnetic radiation generated by household appliances. This primarily
affects the speed of data transmission.
Despite the global standardization, many devices from different manufacturers are not fully
compatible, which in turn affects the speed of communication.
Wi-Fi has a limited radius of action and it is suitable for home networking, which is more
dependent on the environment. So for home router with Wi-Fi in the room has a range of up to
45 meters and up to 450 meters outside.
At high density Wi-Fi points channels can interfere with each other. This affects the quality of
the connection.[13]
19
3.3.1.2 Bluetooth
Bluetooth is a wireless technology standard for exchanging data over short distances (using
short-wavelength) from fixed and mobile devices, and building personal area networks (PANs).
Advantages of Bluetooth:
Cheap.
Easy to install.
It makes connecting to different devices convenient.
It is wireless.
It is free to use if the device is installed with it.
Table 3[15] summarize the comparison. This project uses Wi-Fi for connectivity as it allows
internet connection and provides a larger signal range and higher Bit-Rate.
Bluetooth Wi-Fi
20
Bluetooth Wi-Fi
Hardware Bluetooth adaptor on all the Wireless adaptors on all the devices of
requirement devices connecting with the network, a wireless router and/or
each other. wireless access points
Ease of Use Fairly simple to use. Can be It is more complex and requires
used to connect up to seven configuration of hardware and software.
devices at a time. It is easy
to switch between devices or
find and connect to any
device.
21
3.3.2 Server
A server is a computer program or a device that provides services for other programs or devices,
called "clients". Servers can provide various functionalities, such as sharing data or performing
computation for a client. Typical servers are database servers, file servers, mail servers, print
servers, web servers, game servers, and application servers.
22
User Guide
23
Chapter 4 User guide
In this chapter a guide for normal users is introduced. The user will follow the following instruction to
get the project working well.
It should be noticed that the electronic devices should be kept in a dry and clean place while switched
on or off. They must be kept out of hand from children and fixed in a stable way.
From Arduino-side :
1- Connect the power plug to the Arduino connector.
2- Connect the Ethernet cable (cross-over cable CAT6) on the Ethernet-shield connector.
Ethernet Connector
Power Connector
24
Router-side:
1- Power on the router.
2- Connect the server to the router network using Wi-Fi.
3- Connect the other side of the Ethernet-shield cable in the yellow router connectors.
Ethernet port
25
Server-side:
Connect the server to the router network using Wi-Fi before connecting the Arduino cable to
the router.
1. Make sure that router has IPv4 of 192.168.1.100 by following these steps:
2. In Windows Operating system go to start -> run -> type cmd then press enter
3. Type ipconfig.
4. In the Wi-Fi list search for IPv4 to see if the IP is 192.168.1.100 as shown in the figure
If the IPv4 was not 192.168.1.100, disconnect all the connections with router then reconnect
the server at first step, then connect the Ethernet-shield and the mobile phone.
26
Android side:
F indicates LED is on
27
T indicates manual control
mode
Figure 20 shows
how to toggle
fan swicth on
and off
28
ON indicates garage door is open
Figure 21 shows
how to toggle
garage door
switch on and
off
Figure 22 shows
how to toggle
water pump
swicth on and off
29
F indicates automatic control mode
Figure 23 shows
how to toggle
automatic mode
Temperature is higher
than 25, and the fan is on
30
Temperature is lower
than 25, the fan is off
31
Water level is higher than
10, the water pump is off.
32
Chapter 5 Conclusion and
future work
33
Chapter 5 Conclusion and Future work
In this chapter gives a conclusion for the project with recommendation for future work.
5.1 Conclusion.
The project is implemented in hardware and software components that interact through network
connections. The main challenge is to implement the project in an economical way such that it
can be easily deployed and used by homeowners.
The data is collected from sensors by the Arduino. Arduino microcontroller is connected to the
LAN with Ethernet shield. The configuration of the Arduino for Ethernet shield contains a static
IP address for the shield and the local server.
Arduino via the shield sends data every 5 seconds (can be adjusted) to the server via a URL
using Get method. Server accepts the data and updates the database in the right columns and
through in the same time gets the manual/automatic command with other switch status from the
correct columns too.
The smartphone reads data from the server using JSON method to get sensor values and display
them on screen and updates the switch columns on the database if the user has clicked on them.
34
References
[1] D. Evans, "The Internet of Things: How the Next Evolution of the Internet Is Changing Everything",
Cisco. Retrieved 15 February 2016, 2011.
[3] L. ORSINI, Arduino Vs. Raspberry Pi: Which Is The Right DIY Platform For You?,
http://readwrite.com/, 2014.
[4] B. Bourque, Arduino vs. Raspberry Pi: Mortal enemies, or best friends?,
http://www.digitaltrends.com/, 2015.
[7] https://www.apachefriends.org/index.html.
[8] http://httpd.apache.org/.
[9] http://php.net/manual/en/intro-whatis.php.
[10] https://www.arduino.cc/en/Guide/Environment.
[11] http://technouniversityworld.blogspot.com/2012/03/brief-description-on-android-os.html.
[12] http://developer.android.com/tools/projects/index.html.
[16] http://www.computerhope.com/jargon/s/server.htm.
[17] elecfreaks(http://www.elecfreaks.com/estore/).
[19] www.instructables.com/id/Arduino-Modules-L298N-Dual-H-Bridge-Motor-Controll/?ALLSTEPS.
[20] http://php.net/manual/en/intro-whatis.php.
[21] https://www.arduino.cc/en/Main/Software.
35
[22] http://technouniversityworld.blogspot.com/2012/03/brief-description-on-android-os.html.
[23] http://technouniversityworld.blogspot.com/2012/03/brief-description-on-android-os.html.
[24] http://technouniversityworld.blogspot.com/2012/03/brief-description-on-android-os.html.
[25] https://en.wikipedia.org/wiki/Server_(computing).
[26] http://onlinepresent.org/proceedings/vol24_2013/23.pdf.
36