Anda di halaman 1dari 78

Generated by CamScanner from intsig.

com

Generated by CamScanner from intsig.com

WIFI BASED HOME AUTOMATION

CHUAH YIH JIAN

Submitted to the Faculty of Electrical Engineering In partial fulfillment of requirement for the degree of Bachelor of Engineering (Electrical-Mechatronics)

Faculty of Electrical Engineering Universiti Teknologi Malaysia

JUNE 2013

Generated by CamScanner from intsig.com

iii

Specially dedicated and thanks to my family for the support, understandings, and encouragement:

My father, Chuah Seaoi Wah My mother, Ang Soo Eng My brother, Chuah Yih Chuan My sister, Chuah Yih Shuang

iv

ACKNOWLEDGEMENT

First of all, I would like to express my greatest gratitude to my supervisor, Associate Professor Dr. Rosbi Bin Mamat, who gave me ideas, support, and encouragement throughout the progress of my Final Year Project. I am glad to have his guidance and help along the effort to accomplish this project.

Besides that, my sincere appreciation also goes to my parent, brother and sister. Along these four years in Universiti Teknologi Malaysia, they are always being so tolerant and supportive either morally or financially. Thanks to their love and continuous support on me. They are the one gave me motivation to complete my project.

Last but not least, thanks to all my friends who had helps me when I faced technical problems in this project. I feel great to have you all for mentally support throughout the project. I wish you all the best in future life and hope that our friendship will last forever.

ABSTRACT

Home automation is getting common in people lives in order to improve the convenience, comfort, and energy efficiency. Imagine that, every appliance can be switch on and controlled just before u reach home. For security purpose, we can install camera connected to the Internet to observe any intruders and who is going to get into our house. In this project, an automate control system which using Wifi based technology as a platform to control appliances and security system was implemented. User would be able to control home appliances by using universal electronic devices which contains a web browser, such as personal computer, smart phone, and tablet in everywhere and anytime. In the hardware implementation, Arduino Uno and Arduino Ethernet shield as main parts in producing web server by using Arduino IDE. Arduino Ethernet will be connected to a router which directs the hardware to the internet access. Web server works as a host between communication of home appliances and microcontroller. While in software implementation, a web-page is created by using HTML language as a user interface to control the home appliances. In the home automation prototype, appliances are including lamp, fan, LDR sensor, and LED light. On the other hand, security system consists of PIR sensor to detect intruder, and a buzzer to act as alarm.

vi

ABSTRAK

Rumah automasi semakin biasa dalam kehidupan orang ramai supaya meningkatkan kemudahan, keselesaan, dan kecekapan sistem perumahan. Bayangkan, setiap perkakas dalam rumah boleh dikawal dan disediakan sebelum jangkauan rumah. Bagi tujuan keselamatan, kita boleh memasang kamera yang bersambungan dengan internet untuk mengesan penceroboh yang cuba memasuki rumah. Dalam projek ini, saya telah membina suatu sistem kawalan automasi dengan menggunakan teknologi berasakan Wifi sebagai platform untuk mengawal peralatan elektrik dalam rumah dan juga sistem keselamatan. Pengguna boleh mengawal peralatan elektrik dalam rumah dengan menggunakan alat-alat elektronik yang mengandungi pelayaran web, seperti computer peribadi, telofon pintar, dan tablet pada bila-bila masa dan di mana-mana jua. Dalam pemasangan, Arduino Uno dan Arduino Ethernet shield berfungsi utma dalam menghasilkan pelayan web. Ia akan dibina dengan menggunakan Arduino IDE. Arduino Ethernet Shield akan disambungkan ke router supaya mendapat akses internet. Pelayan web berfungsi sebagai pelayan komunikasi di antara alat elektrik dengan mikropengawal. Selain itu, perlamanan web dibina dengan menggunakan HTML sebagai alat untuk mengawal alat elektrik dalam rumah. Dalam sistem automasi, alat elektrik mengandungi lampu, kipas dc, LDR sensor, dan LED. Manakala sistem keselamatan mengandungi PIR sensor yang berfungsi untuk mengesan penceroboh, dan juga buzzer untuk berfungsi sebagai penggera.

vii

TABLE OF CONTENT

CHAPTER PAGE

TITLE

DECLARATION DEDICATION ACKNOWLEDGEMENT ABSTRACT ABSTRAK TABLE OF CONTENTS LIST OF TABLES LIST OF FIGURES LIST OF ABBREVIATIONS LIST OF APPENDICES

ii iii iv v vi vii x xi xii xiv

1 1.1 1.2 1.3 1.4

INTRODUCTION Project Overview Problem Statement Objective Scope of Project

1 1 2 3 3

viii

2 2,1 2.2

LITERATURE REVIEW AND THEORY Introduction Literature review 2.2.1 GSM Based Wireless Home Appliance Control by Nordin (2010) 2.2.2 PC Based Home Automation Using Speech Recognition and Network by Chong (2011) 2.2.3 Development of Web-based Mobile Robot By Azizan (2011) 2.3 Related Journals 2.3.1 2.3.2 ZigBee Based Home Automation by Jitendra (2007) Design and Implementation of a WiFi-Based Home Automation System by Elshafee (2012)

5 5 5 5

9 9 11

3 3.1 3.2

METHODOLOGY Introduction Project Planning 3.2.1 3.2.2 3.3 3.4 Gantt Chart of FYP1 Gantt Chart of FYP2

13 13 15 15 16 17 18 18 18 19 20 22 22 23 24 25 26 28

Project Flow Hardware Implementation 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 Arduino Boards Aduino Uno Microcontroller Arduino Ethernet Shield Interface between Home Appliances and Arduino Board Interface between Security System and Arduino Board

3.5

Software Implementation 3.5.1 3.5.2 3.5.3 3.5.4 3.5.5 Arduino IDE Software HTML Graphical User Interface Web Server Home Appliances and Security System Programming

ix

3.5.6 3.5.7 3.6

Graphical User Interface by Using HTML Web Server Programming

32 34 37

Port Forwarding

4 4.1 4.2 4.3 4.4

RESULTS AND DISCUSSIONS Chapter Overview Hardware Completion Software Completion Results of the Project 4.4.1 4.4.2 4.5 Security System Home Appliances

39 39 39 42 44 44 45 48 48

Discussion 4.5.1 Flexibility, Mobility, and Large Coverage

5 5.1 5.2

CONCLUSION AND SUGGESTION Conclusion Suggestion

50 50 51

REFERENCES Appendix A Appendix B

52 53 62

LIST OF TABLES

TABLE NO. PAGE 3.1 3.2

TITLE

Gantt Chart for FYP1 Gantt Chart for FYP2

15 16

xi

LIST OF FIGURES

FIGURE NO. PAGE 2.1 2.2 2.3 2.4 2.5 3.1 3.2 3.3 3.4 3.5 3.6 3.7 3.8 3.9 3.10

TITLE

Block Diagram of the Home Automation System Web Page Mobile Robot Project Overview ZigBee Network Model ZigBee Devices Connection System Architecture Project Overview Arduino Uno Arduino Ethernet Shield Home Appliances Schematic Diagram Security System Schematic Diagram Arduino IDE Graphical User Interface Template IP Address and Port Number Configuration Flow Chart for Home Appliances and Security System Graphical User Interface by Using HTML

7 9 10 11 12 14 19 20 21 22 24 25 27 31 33

xii

3.11 3.12 3.13 4.1 4.2 4.3 4.4 4.5 4.6 4.7 4.8 4.9 4.10 4.11 4.12

Web Server Flow Chart Port Forwarding Configuration Forward Porting Table Prototype House Structure of Prototype House Home Appliances Installation Circuit Connection Control Web Page Triggering Button for PIR Sensor Security Condition Display in Web Page LDR Value Display in Web Page LED Light Switched ON Lamp and Fan Trigger Buttons Lamp Switched ON Access Web Page with Universal Electronics Devices

36 37 38 40 41 41 42 43 44 45 46 46 47 47 49

xiii

LIST OF ABBREVIATION

GSM PDA HTML GUI RF API OS USB TCP SNR PCB IDE LED LDR PIR DIY PWM

Global System for Mobile communication Personal Digital Assistant HyperText Markup Languange Graphical User Interface Radio Frequency Application Programming Interface Operating System Universal Serial Bus Transmission Control Protocol Signal to Noise Ratio Printed Circuit Board Integrated Development Environment Light Emitting Diode Light Dependent Resistors Passive Infrared Sensor Do It Yourself Pulse Width Modulation

xiv

URL

Uniform Resource Locator

LIST OF APPENDICES

APPENDIX PAGE A B

TITLE

Software Main Program Cost Listing

53 62

CHAPTER 1

INTRODUCTION

1.1

Project Overview

For many years the home automation is among us, but in recent years is catching a lot more. Automation components have fall its price and popularization of smartphones makes all carry in his pocket a device able to control certain components of our house if we install home automation systems. Home automation system is getting common in every household. Every appliance can be switch on and controlled just before you reach home. For security purpose, we can install camera connected to the Internet to observe any intruders and who is going to get into our house. The control in lighting of a particular part of the house is just in one click. Another key point is automation may help people with disabilities in their daily routine. Everything is possible and affordable. It seems that in the coming years this technology will continue to drop in price.

There are several technologies applied in home automation. There has been significant research into the field of home automation. The X10 industry standard, developed in 1975 for communication between electronic devices, is the oldest standard identified from the authors review, providing limited control over household devices through the homes power lines. Next, Java technology, which incorporates built-in network security features, produces a secure solution. However, an intrusive and expensive wired installation and the use of a high end PC were the

disadvantage. Afterwards, Bluetooth technology was used to build home automation system. This architecture reduces the amount of physical wiring required. However, the architecture does not completely alleviate the intrusiveness of the installation due to the incorporation of some wired communications. Moreover the sharing of a single Bluetooth module between numerous devices has the disadvantage of incurring an access delay(Gill, Shuang-Hua, Fang, & Xin, 2009).

To get rid of wired communication among devices, wireless technology had been applied in home automation. GSM based, web based, Zigbee based home automation had been implemented as the latest technologies used in smart home. Wifi-based home automation is one of the best among these wireless technologies. Implementing Wifi-based technology manage to decrease deployment cost and increase the ability of upgrading, and system reconfiguration. Besides that, it is more secure which allow authorize user to control and monitor the system. Its connectivity dispersed over large areas. Home automation becomes possible everywhere and at any time with wireless network accessed using any mobile devices such as smart phone and PDAs which consist of web browser in reach of the network(Ahmed ElShafee, 2012).

1.2

Problem Statement

Nowadays, home automation is become more common in order to improve our live quality. It provides comfort and also allowing centralized control of appliances furthermore contribute to cost reduction and energy saving. Besides that, it helps older people and people with disability to control home appliances without moving all over their house especially double story house. If the system installation cost is affordable, everyone is willing to get it. Home automation system face main challenges such as high cost ownership, inflexibility, poor manageability, and difficulty in achieving security.

With Wifi based home automation, one can access to the control panel through any mobile devices which is available in web browsing. System will make use of secure wireless LAN connections between distributed hardware modules and server, and secure communication protocols between users and server.

1.3

Objective

The objective of this project is to develop and design a Wifi-based home automation with appliances control and security system. The design will include the following features:

Enable user to control home appliances by using universal electronic devices which contains a web browser, such as personal computer, smart phone, and tablet.

Contribute to cost reduction by energy saving. Electricity consumption can be reduced. User can access the web browser control interface anytime, anywhere using any device capable of browsing the internet. User able to control light, motion sensor, dc fan.

1.4

Scope of Project This project is divided into two parts, which is hardware and software

development. The following are the scopes of the project, including:

The system is able to switch on or off for lamp and fan. Dimmer function and speed control are excluded. Motion sensor is able to sense intruders and feedback the information to the web browser.

A web page created by using HTML is used as the user interface which has control button and motion detector.

CHAPTER 2

LITERATURE REVIEW AND THEORY

2.1

Introduction

Information covered in this chapter are included related projects which had been done by graduates in Universiti Technologi Malaysia, related journals published by several authors, and theories.

2.2

Literature review

2.2.1

GSM Based Wireless Home Appliance Control by Nordin (2010)

In this project, GSM had been used as the wireless module to develop a automate system which can enhance the security system and optimized control of the home appliances. Author convinced that GSM module is better because it uses radio frequencies efficiently, speech quality is better than in analogue system, and it is technically possible within all country using the GSM system. Hand phone equipped with GSM function would be the wireless remote controller, enable users to control their home appliances in anywhere anytime. Through SMS (Short Message Service), message will be sent to the user on time once intrusions are detected. At the same

time, alarm will be triggered ON to against the intruder. Lamp and fan is the only appliances used in the prototype module.

Development of the system was divided into two parts, which is hardware and software. In hardware part, magnetic contact sensor and motion sensor were used as the tools to detect intruders. While PIC 16F877A worked as a microcontroller to process input and output data. It been chosen because of low cost, wide availability, and reprogrammed capability. Besides that, GSM modem, MAX 232 converter, IC MAXIM 232, and mobile phone were communication and interfacing tools.

In software part, MicroC was used as programming tool for PIC 16F877A, while Proteus (ISIS 6 Professional) was used to design circuit. Visual Basic 2008 was used to design Graphic User Interface. In order to link computer and hardware to mobile phone, AT command is used( Nordin, 2010).

2.2.2

PC Based Home Automation Using Speech Recognition and Network by Chong (2011)

Chong used speech recognition and network as interfaces to design a home automate control system. This system enable user to control their home appliances such as lamp, fan, air-conditioner, security gate and so on by using a computer or graphic user interface (GUI). Speech recognition instead of remote control was implemented in this system in order to allow any of family members to control home appliances. Besides that, there is additional accessibility to the control interface by using Window Live Mesh application as a platform to enable user control appliances through internet. In summary, he developed the system using RF wireless communication protocol and speech recognition technology. However, this system is just suitable for short range control and it cannot be controlled in far distance.

There are several parts of board are used to build the hardware. Microcontroller PIC18F4550 used in transmitter part while PIC16F877A used in receiver part. Programming tool consist of PIC Programmer UIC00A which is considered low cost yet reliable and user friendly for students. For the user interface, a PC with Intel platform which is running on window vista or above is sufficient. Last but not least, Local Area Network is needed in order to control home appliances by using window live mesh. In software part, GUI program code is built using Visual Basic 2008 which provided API for the user to code their program, thus, it is simple compared with C++ or C# language. For the program in PIC, PICBASIC PRO Compiler is used, it is said to be much easier to read and write than assembly language(Chong, 2011).

Figure 2.1: Block diagram of the home automation system

2.2.3

Development of Web-based Mobile Robot by Azizan (2011)

At early stage of the research on the Internet-based control system, client interface or remote user program was implemented by window program. It was preferred because of easy to develop and the programming is much simpler. However, only Windows-based computer can access the system. As a result, it limits the scope of client only to Windows-based computer and makes the system to be less flexibility. Furthermore, the client application needs to be installed on each client computer. As improvement, researchers had changed it from the windows program to a web-based application which is machine independent application. By doing so, any

mobile devices with web browsing ability can access the web-based system such as, windows-based computer, Mac OS, smart phone, PDA and Linux users.

Azizan used internet network interface to control basic movements of a PICbased mobile robot remotely. Single Computer Board is used as a server computer and will be mounted on the mobile robot. The server will be installed with Windows as operating system and Apache as a web server program. Hardware used was included PCM-3353 as server computer, USB wireless adapter and router as network connection set up, stepper motor controller with driver UCN 5804 and microcontroller PIC18F458 as controller of the mobile robot, and IR sensor and USB camera as path planning component. In software part, Microsoft Visual Studio 2008 is used to develop the website of the system. The Web pages and the Web forms are designed and programmed in ASP .NET technologies with 3.5 version of .NET framework. The server program is Windows-based software that contains a network module to handle the data send by the client through TCP/IP connection. The server program has been designed and programmed by using VB with 2.0 version of .NET framework. Network and socket programming has been used to implement the TCP/IP for the network communication between the server program and the client. And last, MikroC Pro is used as an advanced C compiler for PIC microcontrollers(Azizan 2011).

Figure 2.2: Web Page Mobile Robot Project overview

2.3

Related Journals

2.3.1

ZigBee Based Home Automation

ZigBee protocol IEEE 802.15.4 wireless standard can be used to set up network for home automation. Zigbee module needed small initial cost and can be useful to control fans, lights, and other home appliances which operation can be controlled with the help of a microcontroller. There are several advantages such as low cost, open standards enable markets, excellent performance in environments with low SNR, Very low power consumption, and it can be implemented with any type of microcontroller. The generic seven-layer model is applied to all network and media types. The adaptation ISOOSI network reference model for ZigBee purposes is illustrated in the figure. ZigBee network model does not use presentation, session or transport layer and user application is directly tied into Application layer (APL). ZigBee IEEE802.15.4 standard defines three frequency bands to employ a standard all over the world. Secure data transfer is possible with the help of secure service provider (SSP). The MAC layer manages and maintains communications between radio network and access points by coordinating (Prof.Jitendra R.Rana,2009).

10

Figure 2.3: ZigBee Network Model

In order to make the system work, ZigBee devices such as following are needed.

Coordinator (ZC): Organizes the network and maintains routing tables, Routers (ZR): It can talk to the coordinator, to other routers and to reducedfunction end devices, End devices (ZED): It can talk to routers and the coordinator, but not to each other.

11

Figure 2.4: ZigBee Devices Connection

Jitendra proposed home automation network consist of PIC 18F4522 microcontroller as central processing unit through which signals sensed by ZigBee receiver unit are given to the relay circuit through which various controlling actions will take place. All the activities which are taking place with ZigBee device, sensors and controller will be displayed on the LCD panel.

2.3.2

Design and Implementation of a WiFi-Based Home Automation System by Elshafee (2012)

This paper mainly described about the design and prototype implementation of a home automation with Wifi technology. Elshafee proposed two main parts in the system, web server as the first part, which enable users to monitors and control their home. Hardware interface module is the next part, which included appropriate interface to sensors and actuator of home automation system.

12

WiFi technology is selected to be the network infrastructure that connects server and hardware interface modules. It has the potential to increase system mobility and scalability. The Proposed home automation system is implemented using ASP, HTML and CSS. The server application software package for the proposed home automation system is a web based application built using asp.net, Microsoft Visual Studio 2010. Server application software runs on windows OS, requires IIS web server, and .Net version 4.0 being installed. Server use database to keep log of home automation system components, we choose to use XML files to save system log. The Arduino software, built using C language, using IDE comes with the microcontroller itself. Arduino software is responsible for collecting events from connected sensors, then applies operation to actuators and pre-programed in the server. Hardware consists of four different PCBs, the Arduino PCB, WiFi shield PCB, 3 input alarms PCB, and 3 output actuators PCB. Arduino Microcontroller is the core of hardware interface module, which is responsible for exchanging data between home automation server from one side, and sensors, and actuators from the other side (Ahmed ElShafee, 2012).

Figure 2.5: System Architecture

13

CHAPTER 3

METHODOLOGY

3.1

Introduction

Project methodology divided into two parts, which is hardware and software implementation.

In overall, Arduino Uno and Arduino Ethernet shield as main part in producing web server by using Arduino IDE. Arduino Ethernet will be connected to a router which directs the hardware to the internet access. Web server works as a host between communication of home appliances and microcontroller. Security system consists of a PIR (Passive Infrared Sensor) function as sensor to sense intruders and a buzzer to function as an alarm. Besides that, home appliances consist of 240V bulb functions as a high voltage and high current device, 5V LED light, LDR (light dependent resistor) sensor, and a 12V speed controllable fan.

A web-page will be created by using HTML language, worked as user interface enable user to control the automate system.

14

internet

Router

End-user

End-user

Home appliance s
Web server Security system

Arduino Uno + Ethernet shield

End-user

Figure 3.1: Project Overview

15

3.2

Project Planning

3.2.1

Gantt Chart of FYP 1

No 1 2 3 4 5 6 7 8 9 10 11

Task/activi ties Briefing on FYP Determine topic of interest Discuss topic with supervisor Study on technology related Literature review Submit proposal
Determine hardware to purchase Presentatio n preparation Thesis writing Preliminar y hardware develop Submit thesis for FYP 1

W3

W4

W5

W6

W7

W8

W9

W 10

W 11

W 12

W 13

W 14

W 15

W 16

Table 3.1: Gantt Chart for FYP1

16

3.2.2

Gantt Chart of FYP 2

No

Task/activitie s

W 1

W 2

W3

W 4

W5

W6

W 7

W 8

W 9

W W W W W 1 1 1 1 1 0 1 2 3 4

Project overview Hardware develop Software develop Hardware and Software integration Analysis and test Thesis writing Final presentation

Table 3.2: Gantt Chart for FYP2

17

3.3

Project Flow

hardware

Design circuit for sensor and appliances compatible with Arduino module.

Functionality and behavior of sensor, lamp, and fan. Testing

Design the GUI for the system. software

Network

Set up Arduino web server. Provide Communication platform between clients and host.

Integration of hardware and software.

Integration

Trouble shoot and simulation

Resolve errors. Test the functionality of the whole system.

18

3.4

Hardware implementation

This session will discuss about the component used in hardware implementation, which included Arduino Uno microcontroller, Arduino Ethernet shield WiFi module, PIR sensor, and schematic design for home appliances connections.

3.4.1

Arduino boards

Arduino is a single-board microcontroller designed to make the process of using electronics in multidisciplinary projects more accessible. The hardware consists of a simple open source hardware board designed around an 8-bit Atmel AVR microcontroller. Besides that, a new model has been designed to be more powerful, around a 32-bit Atmel ARM. Arduino boards can be purchased preassembled or as DIY kits. An important aspect of the Arduino is the standard way that connectors are exposed, allowing the CPU board to be connected to a variety of interchangeable add-on modules known as shields. Some shields communicate with the Arduino board directly over various pins, but many shields are individually addressable via an I C serial bus, allowing many shields to be stacked and used in parallel. The Arduino board exposes most of the microcontroller's I/O pins for use by other circuits.

3.4.2

Arduino Uno Microcontroller

Aduino Uno is a microcontroller board based on ATmega328. In this project, it will be used to receive and transmit data. UART TTL serial communication is the way Arduino Uno communicating with computer and other microcontroller. To power ON the microcontroller, one can either uses USB connection or by using

19

AC-to-DC adapter. Uno provides automatic software reset, which allows user to load program although the software is still running. Sketch of code can be simply load and done with shorter timeout. Following are features of Arduino Uno: Operating voltage Input Voltage Digital I/O pins Analog Input pins : 5v : 7-12v : 14 (6 provide PWM output) :6

DC current per I/O pin : 40mA Flash memory EEPROM Clock speed : 32KB : 1KB : 16MHz

Figure 3.2: Arduino Uno

3.4.3

Arduino Ethernet Shield

This module enable user to connect Arduino Uno to the internet through RJ45 cable. The Arduino Ethernet Shield allows an Arduino board to connect to the internet. It is based on the Wiznet W5100 Ethernet chip which provides a network (IP) stack capable of both TCP and UDP. It supports up to four simultaneous socket connections. Use the Ethernet library to write sketches which connect to the internet using the shield. The Ethernet shield connects to an Arduino board using long wire-

20

wrap headers which extend through the shield. This keeps the pin layout intact and allows another shield to be stacked on top.

This shield operates in 5v voltage. Provides 10/100Mb connection speed and 9v output. Besides that, it consists of overload and short circuit protection feature. It also produces low output ripple and noise.

Figure 3.3: Arduino Ethernet Shield

3.4.4

Interface between Home Appliances and Arduino board

Home appliances consist of a 12v fan, LDR sensor, LED light and a 240v high voltage high current light bulb. Light bulb is connected to output pin9. To protect the microcontroller Uno from the high current connection, protection circuit is designed. Protection circuit consists of relay, transistor and diode. Transistor act as a switch, diode used to prevent back flow of current, and relay is used to turn ON the high current high voltage light bulb. LDR sensor is connected to analog input pin5. It functioned to sense the light intensity outside the house prototype in order to light ON LED light which connected to output pin4 once light intensity is less than

21

40. Besides that, 12V dc fan is connected to output pin 9, which is PWM output pin. 12V and 350mA power adapter is functioned as power source to supply 12V to the fan. By using the PWM value of the pin9, speed of the fan is able to be controlled.

Arduino Ethernet Shield

Figure 3.4: Home Appliances Schematic Diagram

22

3.4.5

Interface between Security System and Arduino Board

PIR (Passive Infrared) sensor is chosen to detect motion in the front door. It operates by measures infrared light radiating from the objects in its field of view. If there are changes of intensity, the motion will be detected. PIR sensor is connected to the input pin3 of Arduino Uno. On the other hand, a buzzer is connected to the output pin8, functioned as alarm to be triggered ON when motion is detected.

Arduino Ethernet Shield

Figure 3.5: Security System Schematic Diagram

23

3.5

Software Implementation

Basically, Software is divided into two parts, which are web server and Graphical User Interface (GUI). Web server is created by using Arduino IDE, while GUI is designed by using HTML language.

3.5.1

Arduino IDE Software

Arduino IDE is open source software written in Java, designed to introduce programming to newcomers unfamiliar with software development. The software includes a code editor with features such as syntax highlighting, brace matching, automatic indentation, and also compiling and uploading programs to the board. C or C++ programming language is used to write program code which called sketch.(WikiPedia, 2013)

Arduino IDE contains of text editor for code sketching, a message area, a text console, a toolbar with buttons for common functions, and a series of menus. File

extension .ino or .pde is file type which sketches will be saved. Feedback message such as saving, exporting, and errors will be display in the message area. Besides that, console displays text output by the Arduino environment including error message and other information. The toolbar buttons allow you to verify and upload programs, create, open, save sketches, and open the serial monitor. Before uploading your sketch, you need to ensure that correct items such as the Arduino boards and serial port have been selected. When uploading a sketch, actually Arduino boot loader is used, which is a small program that has been loaded in the microcontroller. (Arduino, 2007)

24

Toolbar

Text editor

Message Area

Figure 3.6: Arduino IDE

3.5.2

HTML

HTML is the main language used to create web page that can be display in a web browser. Thus, in this project, HTML language is used to create a web page which consists of control buttons and information about the condition of appliances and security. Usually, HTML is written in the form of HTML elements such as tags enclosed in angle brackets. The tags are always written in pairs. Between pair of tag, web designer can add text, comments, and other types of text-based content. Besides that, HTML elements form the building blocks of all websites. It allows images and objects to be embedded and can be used to create interactive forms. Web browser is used to read HTML documents and compose them into visible or audible web pages. It does not display the HTML tags, but uses the tags to interpret the content of the

25

page. On the other hands, web browser can also refer to Cascading Style Sheets (CSS) to define the appearance and layout of the text and other material. (WikePedia, 2001)

3.5.3

Graphical User Interface

Interface consists of ON and OFF button to turn the state of home appliances. Besides that, a spreadsheet needed updating the reading feedback from PIR sensor. An alarm places on the template to indicate intruders. Following is the template of the GUI.

WELCOME TO YOUR SMART HOME

Reading feedback from


Pir sensor

Alarm indicate intruders

Lamp button

Dc fan button

Shown condition of lamp and fan

Figure 3.7: Graphical User Interface Template

26

3.5.4

Web server

Arduino provides an open source platform to allow user building their codes easily. Any operating system such as Windows, Mac, and linux, those are compatible with Arduino IDE. Web server plays an important role in this project, act as a host between the communication among end user and microcontroller.

In order to create a web server, first, we need to combine Arduino Uno and Ethernet shield together. Using the example provided in IDE library to set up my web server. From the example, we can modify the function as what we desired. After that, we need to specify an IP address of the internet shield. At the same time, configure router IP address same as Ethernet shield. Thus, data can be accessed by entering the IP address of the Ethernet shield into the URL bar of a web browser. By doing so, control system just can be access in local network. Port number for the Ethernet shield can be configured in the Arduino IDE, 80 is the default port number for http if it is not been configured. In this project, IP address is configured as 192.168.0.13, while port number is set to be 27. Thus, user needs to enter http://192.168.0.13:27 in order to access the web page.

27

Configure IP address and port number of the Ethernet shield

Figure 3.8: IP Address and Port Number Configuration

28

3.5.5

Home Appliances and Security System Programming

29

start

Read intensity value from LDR sensor, store in photocell

Photocell<40 ? Turn ON LED Turn ON LED

PIR ON button pressed ?

Turn ON PIR sensor

PIRstate=high? Turn OFF buzzer Turn ON buzzer

30

PIR OFF button pressed ?

Turn OFF PIR sensor

LAMP ON button pressed ?

Turn ON lamp

LAMP OFF button pressed ?

Turn OFF lamp

FAN HIGH button pressed ?

Turn ON fan with high speed

31

FAN LOW button pressed ?

Turn ON fan with low speed

FAN OFF button pressed ?

Turn OFF fan

End

Figure 3.9: Flow Chart for Home Appliances and Security System

32

3.5.6

Graphical User Interface Programming by Using HTML

33

Figure 3.10: GUI by Using HTML

34

3.5.7

Web Server Programming

35

start

Assign IP as 192.168.0.13 and port number as 27

Begin connection of Ethernet and server

Listening for incoming http request

Client is available

CurrentLineIsBlank =true?

36

Reply http request to client

Send a standard http response header to client

Display web page in clients web browser CurrentLineIsBlank =true 5 second

Auto reload webpage every

End of line?

Client stop

End

Figure 3.11: Web Server Flow Chart

37

3.6

Port Forwarding

Port forwarding is used to translating the address or port number of a packet to a new destination according to the routing table. The destination may be a predetermined network port with protocols such as TCP and UDP on a cost within a NAT-masqueraded, typically private network, based on the port number on which it was received at the gateway from the originating host. This technique is used to permit communications by external hosts with services provided within a private local area network.

Figure 3.12: Port Forwarding Configuration

In order to access my home control system, IP address of the web server has to be visible to all networks other than local network. To do so, port forwarding is necessary to be configured in the routers administration page. When user are trying to access the control system from outside, incoming request will be sent to the local router. Through the port forward configuration in the router, router will response to the incoming request by forwarding the connection to the specified port assigned to the web server. After being able to access the web server, router will send back the http request to the users web browser and display the web page on the web browser. In this project, service port and internal port are configured as port number 27, same

38

as the port for the Ethernet shield. Besides that, IP address is set to be 192.168.0.13 and protocol will be TCP. Next, enabled it and save it. After all, user is able to access the web page anywhere and anytime. Figure 3.13: Forward Porting Table

The web server have been added to the list of virtual servers, any incoming request to the port number 27 and public IP address of the router will be port forwarding. In the configuration page, virtual server can be added to provide more services. At last, when user is trying to access the web page outside the local network, one must enter the public IP address of the router and the port number in the URL bar of the web browser.

39

CHAPTER 4

RESULTS AND DISCUSSIONS

4.1

Chapter Overview

This chapter basically represents the result for the overall in this project. Besides that, discussion regarding the result and completion of the project will carried out.

4.2

Hardware Completion

Wifi based automation system has been installed in a prototype house, which is built by using wood, polystyrene, and cardboards. The door of the prototype house is foldable in order to create the situation where door is open and movement of intruder is detected. Circuit of connection between Aduino Uno board and appliances is installed on the top of the prototype house. Its position is fixed by using pin, and the whole circuit is covered by a roof. Combination of Arduino Uno board and Ethernet shield are switches ON by supplying power source 5V through USB connection with laptop. To set up the whole system, following steps are carried out.

40

I.

Plug in the USB cable to the laptop which connected with Arduino Board. Thus, the microcontroller is power ON.

II.

Plug in the LAN cable to the router which connected with the Ethernet Shield. After done it, web server is ready.

III.

Next, we need to ensure the appliances connection, plug in the lamp and also the 12V supply for the fan.

IV.

To access the web page, enter http://192.168.0.13:27 into the URL bar of any web browser in any electronic device.

V.

After all, you are available to control the home automation system now.

Figure 4.1: Prototype House

41

Circuit connection

Appliances installation

Figure 4.2: Structure of Prototype House

LDR SENSOR

LED

PIR SENSOR

FAN LAMP

BUZZER

Figure 4.3: Home Appliances Installation

42

USB cable 12V power supply LAN cable Lamp wire PIR sensor

Lamp

buzzer fan

Figure 4.4: Circuit Connection

4.3

Software Completion

A web server is created which is able to conduct a communication platform between user and microcontroller Arduino board. It is able to listening incoming request from the client and replying the request by sending the http header. Thus, control web page will be display in the web browser of the user. When the user click on the control button, signal of digital high or low will be send to the server through http request. Web server will process the request and on the other hand, trigger the pin of microcontroller 1 or 0.

43

A web page has been designed by using HTML language. It consists of control button for lamp, PIR sensor, and dc fan. Besides that, it also shows the condition of security system, and condition of appliances including fan and lamp.

Figure 4.5: Control Web Page

44

4.4

Results of The Project

4.4.1

Security System

Security system consists of PIR sensor and buzzer. In the web page, there is push button for the user to turn ON or OFF PIR sensor. The purpose of this option is providing user to switch ON PIR sensor when they are away, while turn OFF it when someone is staying in the house. If the PIR sensor is OFF, the buzzer would be switch OFF also in order to avoid any annoying wrong alarm. When, PIR s ensor is ON, it will sense the intruder by detecting any changes of infrared light intensity. If movement is detected, buzzer will be switched ON for 10 seconds and message motion detected!! will be display in the web page to alert the user. After 10 seconds, buzzer will be switched OFF if do not have any movement detected.

Triggering button for PIR sensor

Figure 4.6: Triggering Button for PIR Sensor

45

Security condition will display Motion Detected! when movement is detected.

Figure 4.7: Security Condition Display in Web Page

4.4.2

Home Appliances

Home appliances consist of lamp, speed controllable fan, LDR sensor and LED. LDR sensor sense the light intensity outside the prototype house. If the light intensity is less than 40, LED light will be switched ON. LED light is placed as a down light at the top of the front door. This function indicates that the condition at the front door is always bright at night. User would not face darkness when tend to unlock the front door from outside. Light intensity value will be display in the web page. Thus, user can retrieve the condition of the LED light by seeing whether the light intensity is less than 40.

Besides that, fan can be switched ON in high or low speed. When the FAN high button is pressed, PWM value of 244 will be send to the microcontroller in order to trigger the dc fan with high speed. While PWM value of 57 will be sent when the FAN low button is pressed.

46

Light intensity value displayed in webpage.

Figure 4.8: LDR Value Display in Web Page

LED switch ON when LDR value is less than 40

Figure 4.9: LED Light Switched ON Lamp is the one appliance which operates in high current and high voltage. Its connected to the microcontroller by using relay. This connection indicates the automation system is able to apply in people real routine life. Any other appliances which require high current high voltage supply can be connected at the same way as light bulb.

47

Lamp trigger buttons

Fan trigger buttons

Figure 4.10: Lamp and Fan Trigger Buttons

Figure 4.11: Lamp Switched ON

48

4.5

Discussion

4.5.1

Flexibility, Mobility, and Large Coverage

There are many existed home automation system, such as Zigbee module, Bluetooth module, and RF module. However, Wifi module has advantages in overall among those. In terms of flexibility, web page control user interface can be access in universal electronic devices which support web browsing. Control user interface no more restricted to be applicable in Android form or IOS form only. On the other hand, web page user interface can be access in any operating system platform which supports web browsing.

Besides that, Wifi module also has advantage in term of mobility. RF module is just like a remote control centralized all the home appliances control, but it cannot be mobile. On the other hand, Wifi module control system can be carried out on hand in anywhere. When user is willing to access the automation system, any electronic devices with internet access ability can become the mobile remote control.

Last but not least, Wifi module home automation system definitely has a large coverage compared to other module. As the port forwarding is configured in the router, the control web page can be access in anytime and anywhere.

49

Figure 4.12: Access Web Page with Universal Electronic Devices

50

CHAPTER 5

CONCLUSION AND SUGGESTIONS

5.1

Conclusion

Project had been completed according to the project flow and Gantt chart. Objectives of the project were achieved at the end of the accomplishment.

User is able to control home appliances by using universal electronic devices which contains a web browser, such as personal computer, smart phone, and tablet. Contribute to cost reduction by energy saving. User can access the web browser control interface anytime. In home appliances, User able to control lamp, fan, and LED light. While in security system, PIR sensor is able to sense any movement detected and at the same time trigger ON buzzer. Condition of the security system will be displayed in the web page.

As a conclusion, Wifi-based Home Automation system can improve human life in terms of convenience and comfort. Ones can control their home in anytime and anywhere.

51

5.2

Suggestions

There are several suggestions regarding the future development in this project. I. Increases the confidentiality of the control system by develop a user authentication page in the web page. Users have to login to the control web page with user ID and password.

II.

Apply more appliances which require high current high voltage to improve the system to be applied in real world.

III.

Develop a wireless system which can cancel the wire installation between the connection of appliances and microcontroller.

52

REFERENCES

1. Ahmed ElShafee, K. A. H. (2012). Design and Implementation of a WiFi Based


Home Automation System.

2. AZIZAN, M. H. B. (2011). Development of a Web-Based Mobile Robot. ElectricalMechatronics open access, Universiti Teknologi Malaysia.

3. CHONG, C. C. (2011). PC Based Home Automation Using Speech Recognition and


Network. Undergraduate, Universiti Teknologi Malaysia.

4. Gill, K., Shuang-Hua, Y., Fang, Y., & Xin, L. (2009). A zigbee-based home
automation system. Consumer Electronics, IEEE Transactions on, 55(2), 422-430. doi: 10.1109/tce.2009.5174403

5. NORDIN, K. M. B. (2010). GSM BASED WIRELESS HOME APPLIANCES CONTROL.


UNDERGRADUATE UTM THESIS, UTM.

6. Arduino (2007, 8th may 2013). Arduino Development Environment Retrieved


26th May, 2013, from http://arduino.cc/en/Guide/Environment

7. Prof.Jitendra R.Rana (2007), P. S. N. P. J. N. E. C. ZigBee Based Home Automation. 8. WikiPedia. (2013, 30th May 2013). Arduino Retrieved 20th May, 2013, from
http://en.wikipedia.org/wiki/Arduino#Software

53

APPENDIX A

Software Complete Program

#include <SPI.h> #include <Ethernet.h> // ethernet configuration byte ip[] = { 192, 168, 0, 13 }; Server server(27);

// initial int LED = 8; int PIR = 3; int LDR = 5 ; int LAMP = 4; int FAN = 9; int BUZZER =2; int PIRstate = 0; int lampstate = 0; // led is connected to digital pin 4 // PIR sensor is connected to digital pin 3 //LDR sensor is connected to analog in 5 //LAMP is connected to digital pin 2 //FAN is connected to digital pin 9 // BUZZER is conneced to digital pin 8 // variable for PIR sensor status // variable for LAMP status

54

int fanstate = 0;

// variable for FAN status

float photocell = 0; // variable for photocell (LDR) analog value char c = 0; // received data

char command[2] = "\0"; // command void setup() { Ethernet.begin(mac, ip); server.begin(); pinMode(LED, OUTPUT); pinMode(LAMP, OUTPUT); pinMode(PIR, INPUT); pinMode(FAN, OUTPUT); pinMode(BUZZER, OUTPUT); }

void loop() { Client client = server.available(); // detect if current is the first line boolean current_line_is_first = true;

if (client) { // an http request ends with a blank line

55

boolean current_line_is_blank = true; while (client.connected()) { if (client.available()) { char c = client.read(); // if we've gotten to the end of the line (received a newline // character) and the line is blank, the http request has ended, // so we can send a reply if (c == '\n' && current_line_is_blank) { // send a standard http response header client.println("HTTP/1.1 200 OK"); client.println("Content-Type: text/html"); client.println(); client.println("<html>"); // auto reload webpage every 5 second client.println("<META HTTP-EQUIV=REFRESH CONTENT=5 URL=>"); // webpage title client.println("<body style='width:60%;margin:auto'>"); client.println("<div style='border:1px solid white;borderradius:10px;background-color:#0099ff;'>");

client.println("<center><p><h1><center> WELCOME HOME!!

56

</h1></p><center><br /><hr>");

// read analog pin 1 for the value of photocell

photocell = analogRead(LDR); if (photocell < 40) { digitalWrite (LED,HIGH);} else { digitalWrite (LED,LOW);} client.print("<p2>LDR SENSOR: <h2>Light Intensity = <font color=white>"); client.println(photocell, 2); client.println("</font></h2></p2><br /><hr>");

// read digital pin 13 for the state of PIR sensor client.println("<p3>SECURITY SYSTEM :</p3>"); client.println("<form method=get name=form>"); client.println("<button name=b value=1 type=submit style=height:60px;width:120px;border-radius:20px;backgroundcolor:green;>PIR On</button>"); client.println("<button name=b value=2 type=submit style=height:60px;width:120px;border-radius:20px;backgroundcolor:red;>PIR Off</button>");

57

client.println("</form><br />");

client.println("intruder detection ="); if (PIRstate == HIGH) // PIR sensor detected movement { client.println("<font color=red>Motion Detected!</font>"); } else // No movement is detected { client.println("<font color=green>No Movement</font>"); }

if (PIRstate == HIGH) { // PIR sensor detected movement unsigned char i;

for(i=0;i<25;i++){ digitalWrite(BUZZER,HIGH); delay(100);//Delay 1ms digitalWrite(BUZZER,LOW); delay(100);//Delay 1ms } }

58

else // No movement is detected { digitalWrite(BUZZER,LOW); } client.println("<hr><br />"); // button functions client.println("<p4>APPLIANCES:<h4>"); client.println("<form method=get name=form>"); client.println("<button name=b value=3 type=submit style=height:60px;width:120px;border-radius:20px;backgroundcolor:green;>LAMP On</button>"); client.println("<button name=b value=4 type=submit style=height:60px;width:120px;border-radius:20px;backgroundcolor:red;>LAMP off</button>"); client.println("</form><br />"); client.println("<form method=get name=form>"); client.println("<button name=b value=5 type=submit style=height:60px;width:120px;border-radius:20px;backgroundcolor:green;>FAN high</button>"); client.println("<button name=b value=6 type=submit style=height:60px;width:120px;border-radius:20px;backgroundcolor:green;>FAN low</button>"); client.println("<button name=b value=7 type=submit

59

style=height:60px;width:120px;border-radius:20px;backgroundcolor:red;>FAN off</button>"); client.println("</h4></p4></form><br /><hr>");

client.print("<p6>APPLIANCES CONDITION :"); lampstate = digitalRead(2); client.print("<h6 style=color:white> LAMP : "); if (lampstate == HIGH) { client.println("<font color=green> ON </font><br/>"); } else { client.println("<font color=red> OFF </font><br/>"); }

client.print("FAN : "); if (!strcmp(command, "5")) { analogWrite(FAN, 244); client.println("<font color=green> ON </font><br/></h6></p6>"); } else if (!strcmp(command, "6")) { analogWrite(FAN, 57); client.println("<font color=green> ON </font><br/></h6></p6>"); } else if (!strcmp(command, "7")) {

60

analogWrite(FAN, 0); client.println("<font color=red> OFF </font><br/></h6></p6>"); } else if (fanstate == 0) {client.println("<font color=red> OFF </font><br/></h6></p6>");} client.println(</div></body>); client.println(</html>); break; } if (c == \n) { // were starting a new line current_line_is_first = false; current_line_is_blank = true; } else if (c != \r) { // weve gotten a character on the current line current_line_is_blank = false; } // get the first http request if (current_line_is_first && c == =) { for (int I = 0; I < 1; i++) { c = client.read(); command[i] = c;

61

} // LED control if (!strcmp(command, 3)) { digitalWrite(LAMP, HIGH); } else if (!strcmp(command, 4)) { digitalWrite(LAMP, LOW); } if (!strcmp(command, 1)) { PIRstate = digitalRead(PIR); } else if (!strcmp(command, 2)) { PIRstate = 0; } } } } // give the web browser time to receive the data delay(1); client.stop(); } }

62

APPENDIX B

Cost Listing

Parts/Components 1. 2. 3. 4. 5. 6. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. Arduino UNO & USB Cable Arduino Ethernet Shield v2.0 PIR Sensor Module Dc fan 12V Light bulb, socket and plug Transistor TIP122 Buzzer 6-12v c/w wire Songle SPDT Relay SRD 05v Diodes 1N4004 Transistor 2N2222 Adapter Teletron TMC-500PM Male to male jumper Wire Female to female jumper wire Coregcute board Double sided tape Thick board Thin board Mounting board A2 LAN cable

Qty. 1 1 1 1 1 2 1 1 1 1 1 1 packet 1 packet 1 1 2 1 1 1

Unit Price (RM) 75.00 93.00 22.00 6.50 6.00 1.80 3.00 2.80 0.25 0.45 20.00 14.00 5.00 8.00 1.80 8.00 2.00 2.30 10.00

Price (RM) 75.00 93.00 22.00 6.50 6.00 3.60 3.00 2.80 0.25 0.45 20.00 14.00 5.00 8.00 1.80 16.00 2.00 2.30 10.00

Total

291.70

Anda mungkin juga menyukai