Home Automation System using Arduino and Android

43
1 Hashemite University Computer Engineering Department Home Automation System using Arduino and Android Graduation Project 2015/2016 Made by: Ahmed Okasha, Mohammad Ayesh, Fadi Al-fuqha, Enas Abu-sharhan Supervised by: Dr. AnasAl Majali

Transcript of Home Automation System using Arduino and Android

Page 1: Home Automation System using Arduino and Android

1

Hashemite University

Computer Engineering Department

Home Automation System using

Arduino and Android

Graduation Project

2015/2016

Made by:

Ahmed Okasha,

Mohammad Ayesh,

Fadi Al-fuqha,

Enas Abu-sharhan

Supervised by: Dr. AnasAl Majali

Page 2: Home Automation System using Arduino and Android

2

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.

Page 3: Home Automation System using Arduino and Android

3

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

Automatically controlled using smart phone application:

1. Switch fan on/off according to the temperature.

2. Switch water tank motor on/off according to the water level.

3. Switch outdoor led on/off according to the outdoor light intensity.

4. Display temperature, water level and light intensity on the smart phone.

Page 4: Home Automation System using Arduino and Android

i

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

Page 5: Home Automation System using Arduino and Android

ii

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

Page 6: Home Automation System using Arduino and Android

i

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

iii

Page 7: Home Automation System using Arduino and Android

ii

Chapter 1 Introduction

Page 8: Home Automation System using Arduino and Android

1

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.

Page 9: Home Automation System using Arduino and Android

2

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.

Page 10: Home Automation System using Arduino and Android

3

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.

Figure 1 shows the architecture for the project

Page 11: Home Automation System using Arduino and Android

4

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].

Figure 2shows the architecture for the project[2]

Page 12: Home Automation System using Arduino and Android

5

Chapter 2 Requirements and

Design

Page 13: Home Automation System using Arduino and Android

6

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.

User’s requirement to control the following manually through smart phone:

1. Open and close garage door.

2. Switch fan on/off.

3. Switch water tank motor on/off.

4. Switch led on/off.

User’s requirement to control the following automatically through microcontroller:

5. Switch fan on/off according to the temperature.

6. Switch water tank motor on/off according to the water level.

7. Switch outdoor led on/off according to the outdoor light intensity.

8. Display temperature, water level and light intensity on the smart phone.

The following graph summarizes how data from the sensors are displayed on smartphone’s

screen.

Figure 3Arduino to Android summary

Arduino get sensor values.

Then sends them to local server via the ethernet

shield.

The server connected on same LAN accepts the data and updates the

database.

The smartphone connected on same LAN gets the updated values

and display them on screen .

Page 14: Home Automation System using Arduino and Android

7

The following graph summarizes how data from the smartphonearereadon the Arduino.

Figure 4Android to Arduino summary

Commands from the samrtphone are

sent to the local server.

Server accepts the data and updates

the database

Arduino reads data from the database

Accodring to the data , the arduino performs differnet

functions.

Page 15: Home Automation System using Arduino and Android

8

Chapter 3 Implementation

Page 16: Home Automation System using Arduino and Android

9

Chapter 3 Implementation This chapter discusses the implementation of the project from three perspectives. Hardware,

Software and connectivity.

3.1: Hardware implementation This chapter discusses the project from hardware perspective, the electric devices, components

and their usage.

The components include the microcontroller, different types of sensors, and motors used.

One of the main parts of the project is the programmable chip that controls the whole thing. First,

we will briefly answer: what is a microcontroller? What are the differences between different

types of controllers?

The subsection mainly focuses on the comparison between the Arduino and the Raspberry Pi.

A microcontroller is a small computer, known also as System on Chip (SoC) implemented on a

single integrated circuit containing a processor core, memory, and programmable

input/output peripherals. Microcontrollers are designed for embedded applications and used in

automatically controlled products and devices, like toys, medical devices, home automation etc.

There are different types of microcontrollers and metrics. We will compare the Arduino

microcontroller versus the Raspberry Pi as they are the most commonly used controllers in the

projects.

3.1.1Raspberry Pi verses Arduino “Raspberry Pi is a fully functional computer. It has all the trappings of a computer, with a

dedicated processor, memory, and a graphics driver for output through HDMI”. It even runs a

specially designed version of the Linux operating system. Arduino boards are microcontrollers,

not full computers. They do not run a full operating system, but simply execute written code as

their firmware interprets.

It might sound like Raspberry Pi is superior to Arduino, but that's only when it comes to software

applications. The Arduino simplicity makes it much better for pure hardware projects, in which

you simply want things to respond to various sensor readings and manual input.

From the network side, Pi has a built-in Ethernet port, which allows easy access to any network

with little setup. Wireless Internet on the Pi isn’t hard to achieve either, For Arduino we will

need an extra chip known as shield outfitted with an Ethernet port.

While both the Pi and Arduino have a number of interface ports, it’s much easier to connect

analog sensors to the Arduino. The microcontroller can easily interpret and respond to a wide

range of sensor data using the code you put on it, which makes it great if you intend to repeat a

series of commands or respond to sensor data as a means of making adjustments to servos and

devices. The Pi on the other hand, requires a software to effectively interface with the same

devices.

Page 17: Home Automation System using Arduino and Android

10

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].

Chip Arduino Raspberry Pi

Cost per unit $10 $50

performance 16MHz 1.2GHz

Flexibility High High

Capability to connect sensors

Can be connected directly

Needs specific software

Connectivity to LAN Needs an external shield Built-in port

Operating System No Operating System Linux

Table 1 comparison between Arduino and Raspberry pi

Page 18: Home Automation System using Arduino and Android

11

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. Newton’s 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]

Figure 5systematic diagram for the Ultra Sonic Sensor.

Page 19: Home Automation System using Arduino and Android

12

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]

Figure 6 shows systematic diagram for the PIR sensor.

Page 20: Home Automation System using Arduino and Android

13

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.

Light source Illumination (Lux)

Moon Light 0.1 60W bulb at 1m 50

Light source Illumination (Lux)

Fluorescent Lighting 500 Bright sunlight 3000

Table 2 shows the illumination fro different sources

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)

Page 21: Home Automation System using Arduino and Android

14

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.5°C ensured accuracy (at 25°C), and rated for full (−55 ° C to 150°C)range.[6]

Figure 9 shows systematic diagram for temperature sensor.

Page 22: Home Automation System using Arduino and Android

15

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

Figure 11 shows a DC motor

Page 23: Home Automation System using Arduino and Android

16

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.

Figure 12 shows aservo motor

Figure 13 show servo working mechanism

Page 24: Home Automation System using Arduino and Android

17

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.4 Arduino IDE An open source software for Arduino boards used to write and upload codes on the Arduino

boards without any complicates. It runs on different platforms including Windows. It provides

extra options to monitor and communicate with Arduino boards. Programs written using Arduino

Software (IDE) are known as sketches and saved in “.ino” extension [10].

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.

Page 25: Home Automation System using Arduino and Android

18

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.

Disadvantages of using Android.

It does not assure security for application as the source code is available.

Android requires internet connection to be active[11].

3.2.6 Android studio

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].

Page 26: Home Automation System using Arduino and Android

19

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 Wi-Fi versus Bluetooth A comparison between Wi-Fi and Bluetooth to select the most suitable technology between

them.

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]

Page 27: Home Automation System using Arduino and Android

20

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.

Disadvantages of Bluetooth Technology:

It can be hacked into

If installed on a cell phone it is prone to receiving cell phone viruses.

It only allows short range communication between devices.

It can only connect two devices at once.

It can lose connection in certain conditions. [14]

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

Frequency 2.4 GHz 2.4, 3.6, 5 GHz

Cost Low High

Bandwidth Low ( 800 Kbps ) High (11 Mbps )

Specifications

authority

Bluetooth SIG IEEE, WECA

Primary Mobile phones, mouse, Notebook computers, desktop

Page 28: Home Automation System using Arduino and Android

21

Bluetooth Wi-Fi

Devices keyboards, office and

industrial automation

devices.

computers, servers, TV, Latest mobiles.

Hardware

requirement

Bluetooth adaptor on all the

devices connecting with

each other.

Wireless adaptors on all the devices of

the network, a wireless router and/or

wireless access points

Range 5-30 meters With 802.11b/g the typical range is 32

meters indoors and 95 meters (300 ft)

outdoors. 802.11n has greater range.

2.5GHz Wi-Fi communication has

greater range than 5GHz. Antennas can

also increase range.

Power

Consumption

Low High

Ease of Use Fairly simple to use. Can be

used to connect up to seven

devices at a time. It is easy

to switch between devices or

find and connect to any

device.

It is more complex and requires

configuration of hardware and software.

Latency 200ms 150ms

Bit-rate 2.1Mbps 600 Mbps

Table 3 wifi and bluetooth comparison

Page 29: Home Automation System using Arduino and Android

22

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.

3.3.2.1 Client – Server model “The client-server model is a distributed communication framework of network processes among

service requesters, clients and service providers. The client-server connection is established

through a network or the Internet”.

Clients include Web browsers, chat applications, and email software.The project communication

is based on HTTP requests and responses[16].

3.3.2.1.1 HTTP

“HTTP stands for Hypertext Transfer Protocol. It's the network protocol used to deliver

virtually all files and other data (collectively called resources) on the World Wide Web”. HTTP

takes place through TCP/IP sockets.

A browser is an HTTP client because it sends requests to an HTTP server (Web server), which

then sends responses back to the client. The standard (and default) port for HTTP servers to

listen on is 80, though they can use any port.

3.3.2.2 Arduino – Sever communication

1. Arduino makes a HTTP request by using GET through a URL requesting for a file on the

server.

2. PHP program runs on the server which connects the database to the user request.

3. Using SQL statements PHP files can pass the data from the Arduino to the database.

4. At the end the database made is updated.

Page 30: Home Automation System using Arduino and Android

23

User Guide

Page 31: Home Automation System using Arduino and Android

24

Figure 14 An arduino UNO with an ethernet shield

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.

Power Connector

Ethernet Connector

Page 32: Home Automation System using Arduino and Android

25

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.

Figure 15 shows back of a router

Ethernet port

Page 33: Home Automation System using Arduino and Android

26

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.

Figure 16 shows cmd result

Page 34: Home Automation System using Arduino and Android

27

Android side:

Switch to control the led on

or off Shows temperature reading

Shows light intensity reading

Shows water level reading

Switch to select manual or automatic mode

Switch to control the fan on

or off Switch to control the garage door on

or off Switch to control the water pump on

or off

“F” indicates LED is on

Figure 17 shows the startup of the application

Figure 18 shows the LED switch button when pressed

Page 35: Home Automation System using Arduino and Android

28

“T” indicates manual control

mode

Figure 20 shows how to toggle fan swicth on and off

“ON” indicates the fan is on

Figure 19 shows how to toggle manual mode

Page 36: Home Automation System using Arduino and Android

29

“On” indicates water pump is on

“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

Page 37: Home Automation System using Arduino and Android

30

In automatic control mode:

Fan turns on or turns off

depending on temperature

reading.

If the temperature is higher than

25°, the fan will work otherwise

it will not work.

Temperature is higher

than 25, and the fan is on

Figure 23 shows how to toggle automatic mode

Figure 24 shows the automatic mode of the fan

“F” indicates automatic control mode

Page 38: Home Automation System using Arduino and Android

31

In automatic control mode:

Water pump turn on or turn off

depending on water level reading

If the water level is higher than

10 cm, the Water pump will work

otherwise will not work.

Temperature is lower

than 25°, the fan is off

Figure 25 shows the automatic mode of the fan

Water level is lower than

10, the water pump is on.

Figure 26shows the automatic mode of water pump

Page 39: Home Automation System using Arduino and Android

32

Water level is higher than

10, the water pump is off.

Figure 27 shows the automatic mode for water pump motor

Page 40: Home Automation System using Arduino and Android

33

Chapter 5 Conclusion and

future work

Page 41: Home Automation System using Arduino and Android

34

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.

5.2 Limitations and future work.

The project has few limitations that as follows:

1. The system is vulnerable to the different types of attacks.

2. Hardware limitation i.e. Arduino UNO have low performance and low number of pins

3. The need of a laptop as local server

4. There must be an internet connection on the router.

5. Low range of connectivity i.e. we can’t connect outside the range of LAN.

For future work we suggest the following upgrades:

1. To add the security mechanisms such as the authentication in the mobile phone and

making an access list on the database to prevent any unauthorized access. Data must be

sent encrypted every time in a different key through the network to prevent the sniffing

and replay attacks.

2. To get feedback from ON/OFF switches.

3. Schedule a plan for electronic devices selected by the user to control children usage for

example computers and TV.

4. Schedule a plan for electronic devices selected by the user to control air conditioners and

washing machines.

5. Implement fire detection system and turning off the power in case of emergency and

notify the user on his smartphone.

6. Alert the user the gas jar emptyor a gas leakage is detected.

Page 42: Home Automation System using Arduino and Android

35

References

[1] D. Evans, "The Internet of Things: How the Next Evolution of the Internet Is Changing Everything",

Cisco. Retrieved 15 February 2016, 2011.

[2] P. Gadtaula, Home Automation, Telemark University College , 2015.

[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.

[5] l. ada, PIR Motion Sensor, adafruit learning center, 2016.

[6] T. instruments, LM35 Precision Centigrade Temperature Sensors, 2016.

[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.

[13] DIGITALWALT, Wi-Fi – Advantages and Disadvantages of Wi-Fi, 2012.

[14] J. Stlouis, Bluetooth Technology Simplified, 2011.

[15] http://www.diffen.com/difference/Bluetooth_vs_Wifi, Bluetooth vs. Wi-Fi.

[16] http://www.computerhope.com/jargon/s/server.htm.

[17] elecfreaks(http://www.elecfreaks.com/estore/).

[18] Electrocomponents, Light Dependednt Resistor Data sheet, 1997.

[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.

Page 43: Home Automation System using Arduino and Android

36

[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.