android app based home automation

25
KHULNA UNIVERSITY OF ENGINEERING AND TECHNOLOGY ELECTRONICS & COMMUNICATION ENGINEERING (ECE) Android Application Based Home Automation System & Smart Security System ELECTRONICS PROJECT DESIGN AND DEVELOPMENT ECE-3200 January 24, 2017 DEVELOPED BY FAISAL KADIR ROLL: 1309005 ASHIKUR RAHMAN ROLL: 1309024

Upload: ashikur-rahman

Post on 14-Apr-2017

47 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: android app based home automation

KHULNA UNIVERSITY OF ENGINEERING AND TECHNOLOGY ELECTRONICS & COMMUNICATION ENGINEERING (ECE)

Android Application Based Home Automation System & Smart Security System

ELECTRONICS PROJECT DESIGN AND DEVELOPMENT ECE-3200

January 24, 2017 DEVELOPED BY

FAISAL KADIR ROLL: 1309005

ASHIKUR RAHMAN ROLL: 1309024

SUPERVISED BY

MR. SHUVASHIS SAHALecturer

Dept. of Electronics & Communication EngineeringKUET, Khulna, Bangladesh

ELECTRONICS PROJECT DESIGN & DEVELOPMENT

Page 2: android app based home automation

COURSE NO: ECE-3200 DEVELOPED BY: FAISAL KADIR (1309005)

ASHIKUR RAHMAN (1309024) Supervised by: MR. SHUVASHIS SAHA

Signature Lecturer Dept. of Electronics & Communication EngineeringKUET, Khulna, Bangladesh

1 | P a g e

Page 3: android app based home automation

ACKNOWLEDGEMENT All praises are for the Almighty; the sustainer who has been showering his endless blessings on us throughout our life. We take this opportunity to express our profound gratitude and deep regards to our supervisor Mr. Shuvashis Saha (Lecturer, Dept. of Electronics & Communication Engineering) for his guidance, monitoring and constant encouragement throughout the course of this project. Finally, we like to thank all the teachers of our department, our parents and our batch mates, friends for their humble contribution and help for our project.

2 | P a g e

Page 4: android app based home automation

ABSTRACT | Chapter 1

ABSTRACT: Nowadays, people have smartphones with them all the time. So, it makes sense to use these to control home appliances. Presented here is a home automation system using a simple Android app, which you can use to control electrical appliances with clicks or voice commands. Commands are sent via Bluetooth to Arduino Uno. So, you need not get up to switch on or switch off the device while watching a movie or doing some work.

OBJECTIVES: The main objectives of our Project are given below,

App Based Home Appliances like light, TV, fan, water motor etc. control App Based Door locking and Garage locking system Smart home monitoring system Fire alarm with power saving mode and fire service call

Anti-theft alarm with police call

Voice control of above objectives

INTRODUCTION: Wikipedia defines automation as "the use of control systems and information technologies to reduce the need for human work in the production of goods and services." And no matter how technologically behind-the-times you think you are, you likely use some form of automation in your home every day. Typical examples of basic automation include garage-door openers, alarm clocks, timers on a coffee machine and remote controls.

However, when we talk about home automation and smart homes, the capabilities go quite a bit further. And instead of individual devices working independently, a smart home integrates multiple sub-systems that are all controlled by a master home automation controller. This main automation controller is like the home automation system's quarterback, receiving input from all devices around the home, issuing commands and controlling everything.

These controllers generally run complex software, allowing them to execute single or multiple actions based on a variety of events. These events can come in many forms but can essentially be broken down to just two categories: timed and triggered.

Arduino | Chapter 2

3 | P a g e

Page 5: android app based home automation

2.1 Arduino: The open source electronics Arduino is an open-source electronics platform based on easy-to-use hardware and software. Arduino boards are able to read inputs - light on a sensor, a finger on a button, or a Twitter message - and turn it into an output - activating a motor, turning on an LED, publishing something online. You can tell your board what to do by sending a set of instructions to the microcontroller on the board. To do so you use the Arduino programming language (based on Wiring), and the Arduino Software (IDE), based on Processing.

Over the years, Arduino has been the brain of thousands of projects, from everyday objects to complex scientific instruments. A worldwide community of makers - students, hobbyists, artists, programmers, and professionals - has gathered around this open-source platform, their contributions have added up to an incredible amount of accessible knowledge that can be of great help to novices and experts alike.

Arduino was born at the Ivrea Interaction Design Institute as an easy tool for fast prototyping, aimed at students without a background in electronics and programming. As soon as it reached a wider community, the Arduino board started changing to adapt to new needs and challenges, differentiating its offer from simple 8-bit boards to products for IoT applications, wearable, 3D printing, and embedded environments. All Arduino boards are completely open-source, empowering users to build them independently and eventually adapt them to their particular needs. The software, too, is open-source, and it is growing through the contributions of users worldwide.

2.2 Why Arduino Thanks to its simple and accessible user experience, Arduino has been used in thousands of different projects and applications. The Arduino software is easy-to-use for beginners, yet flexible enough for advanced users. It runs on Mac, Windows, and Linux. Teachers and students use it to build low cost scientific instruments, to prove chemistry and physics principles, or to get started with programming and robotics. Designers and architects build interactive prototypes, musicians and artists use it for installations and to experiment with new musical instruments. Makers, of course, use it to build many of the projects exhibited at the Maker Faire, for example. Arduino is a key tool to learn new things. Anyone - children, hobbyists, artists, programmers - can start

4 | P a g e

Figure 1: Arduino Mega 2560 R3

Page 6: android app based home automation

tinkering just following the step by step instructions of a kit, or sharing ideas online with other

members of the Arduino community.

There are many other microcontrollers and microcontroller platforms available for physical computing. Parallax Basic Stamp, Netmedia's BX-24, Phidgets, MIT's Handyboard, and many others offer similar functionality. All of these tools take the messy details of microcontroller programming and wrap it up in an easy-to-use package. Arduino also simplifies the process of working with microcontrollers, but it offers some advantage for teachers, students, and interested amateurs over other systems:

Inexpensive - Arduino boards are relatively inexpensive compared to other microcontroller platforms. The least expensive version of the Arduino module can be assembled by hand, and even the pre-assembled Arduino modules cost less than $50

Cross-platform - The Arduino Software (IDE) runs on Windows, Macintosh OSX, and Linux operating systems. Most microcontroller systems are limited to Windows.

Simple, clear programming environment - The Arduino Software (IDE) is easy-to-use for beginners, yet flexible enough for advanced users to take advantage of as well. For teachers, it's conveniently based on the Processing programming environment, so students learning to program in that environment will be familiar with how the Arduino IDE works.

Open source and extensible software - The Arduino software is published as open source tools, available for extension by experienced programmers. The language can be expanded through C++ libraries, and people wanting to understand the technical details can make the leap from Arduino to the AVR C programming language on which it's based. Similarly, you can add AVR-C code directly into your Arduino programs if you want to.

Open source and extensible hardware - The plans of the Arduino boards are published under a Creative Commons license, so experienced circuit designers can make their own version of the module, extending it and improving it. Even relatively inexperienced users can build the breadboard version of the module in order to understand how it works and save money.

2.3 Android Android is a mobile operating system developed by Google, based on the Linux kernel and designed primarily for touchscreen mobile devices such as smartphones and tablets. Android's user interface is mainly based on direct manipulation, using touch gestures that loosely correspond to real-world actions, such as swiping, tapping and pinching, to manipulate on-screen objects, along with a virtual keyboard for text input. In addition to touchscreen devices, Google has further developed Android TV for televisions, Android Auto for cars, and Android Wear for wrist watches, each with a specialized user interface. Variants of Android are also used on notebooks, game consoles, digital cameras, and other electronics.

Android has the largest installed base of all operating systems (OS) of any kind. Android has been the best-selling OS on tablets since 2013, and on smartphones it is dominant by any metric.

Initially developed by Android, Inc., which Google bought in 2005, Android was unveiled in 2007 along with the founding of the Open Handset Alliance – a consortium of hardware, software, and telecommunication companies devoted to advancing open standards for mobile devices. As of

5 | P a g e

Page 7: android app based home automation

July 2013, the Google Play store has had over one million Android applications ("apps") published – including many "business-class apps" that rival competing mobile platforms – and over 50 billion applications downloaded. An April–May 2013 survey of mobile application developers found that 71% of developers create applications for Android, and a 2015 survey found that 40% of full-time professional developers see Android as their priority target platform, which is comparable to Apple's iOS on 37% with both platforms far above others. In September 2015, Android had 1.4 billion monthly active devices.

Android's source code is released by Google under open source licenses, although most Android devices ultimately ship with a combination of open source and proprietary software, including proprietary software required for accessing Google services. Android is popular with technology companies that require a ready-made, low-cost and customizable operating system for high-tech devices. Its open nature has encouraged a large community of developers and enthusiasts to use the open-source code as a foundation for community-driven projects, which deliver updates to older devices, add new features for advanced users or bring Android to devices originally shipped with other operating systems. The success of Android has made it a target for patent (and copyright) litigation as part of the so-called "smartphone wars" between technology companies.

2.4 Android App Based Home Automation We have developed an android application to automate our home. The app has various features:

Opening Login System, which will save our home to being controlled by this app Bluetooth Connectivity, which connects the app with Arduino Real time room temperature showing Different home appliances like light, fan, TV, AC are included for control Smart Door locking and garage locking options Voice control system for everything using the help of Google Speech Recognition

6 | P a g e

Page 8: android app based home automation

7 | P a g e

Figure 2: Login Screen Figure 3: Home Screen of our App

Figure 4: Controlling through the app

Page 9: android app based home automation

2.5 Block diagram of our automated system

2.6 Arduino Code://defining pin numbers

#include<LiquidCrystal.h>

#include <Servo.h>

#include <Stepper.h>

LiquidCrystal lcd(14,15,16,17,18,19);

Servo doorServo;

Servo garageServo;

const int bulbPin = 2;

const int fanPin = 3;

const int tvPin = 4;

const int acPin = 5;

const int doorPin = 8;

const int garagePin = 9;

const int gasSensorPin= 20;

const int buzzerPin= 21;

8 | P a g e

Page 10: android app based home automation

int smoke_level;

const int in1Pin = 12;

const int in2Pin = 11;

const int in3Pin = 10;

const int in4Pin = 9;

const int tempPin = A0;

int tempVal;

#define STEPS 50

Stepper motor(STEPS, in1Pin, in2Pin, in3Pin, in4Pin);

char data=0;

void setup()

{

lcd.begin(16,2);

doorServo.attach(doorPin);

// garageServo.attach(garagePin);

Serial.begin(9600);

pinMode(bulbPin,OUTPUT);

pinMode(fanPin,OUTPUT);

pinMode(tvPin,OUTPUT);

pinMode(acPin,OUTPUT);

pinMode(tempPin,INPUT);

//

pinMode(gasSensorPin, INPUT);

pinMode(buzzerPin, OUTPUT);

//

pinMode(in1Pin, OUTPUT);

pinMode(in2Pin, OUTPUT);

pinMode(in3Pin, OUTPUT);

pinMode(in4Pin, OUTPUT);

9 | P a g e

Page 11: android app based home automation

motor.setSpeed(50);

}

void loop()

{

smoke_level= digitalRead(gasSensorPin);

tempVal = analogRead(tempPin);

float temperature = tempVal * 0.4883;

Serial.print(temperature);

Serial.print("\n");

//LCD shows the status of home.

lcd.setCursor(0,0);

lcd.print("Temp: ");

lcd.setCursor(6,0);

lcd.print(temperature);

lcd.setCursor(11,0);

lcd.print(" C");

delay(2000);

if(Serial.available()>0)

{

int angle = 0;

data=Serial.read();

if (data=='B')

{digitalWrite(bulbPin,HIGH);lcd.setCursor(0,1);

lcd.print("Light is on ");delay(1000);lcd.clear();}

else if (data=='b')

{digitalWrite(bulbPin,LOW);lcd.setCursor(0,1);

lcd.print("Light is off ");delay(1000);lcd.clear();}

else if (data=='F')

{ digitalWrite(fanPin,HIGH);lcd.setCursor(0,1);

10 | P a g e

Page 12: android app based home automation

lcd.print("Fan is on ");delay(1000);lcd.clear();}

else if (data=='f')

{ digitalWrite(fanPin,LOW);lcd.setCursor(0,1);

lcd.print("Fan is off ");delay(1000);lcd.clear();}

if (data=='T')

{digitalWrite(tvPin,HIGH);lcd.setCursor(0,1);

lcd.print("TV is on ");delay(1000);lcd.clear();}

else if (data=='t')

{ digitalWrite(tvPin,LOW);lcd.setCursor(0,1);

lcd.print("TV is off ");delay(1000);lcd.clear();}

if (data=='A')

{digitalWrite(acPin,HIGH);lcd.setCursor(0,1);

lcd.print("AC is on ");delay(1000);lcd.clear();}

else if (data=='a')

{digitalWrite(acPin,LOW);lcd.setCursor(0,1);

lcd.print("AC is off ");delay(1000);lcd.clear();}

if(data=='D')

{for(angle=0; angle<=90;angle=angle+45)

{ doorServo.write(angle);delay(100);} lcd.setCursor(0,1);

lcd.print("Door is unlocked");delay(1000);lcd.clear();

}

else if(data=='d')

{for(angle=90; angle>=0;angle=angle-45)

{ doorServo.write(angle);delay(100);} lcd.setCursor(0,1);

lcd.print("Door is locked");delay(1000);lcd.clear();

}

if(data=='G')

{ lcd.setCursor(0,1); lcd.print("Garage opening");

11 | P a g e

Page 13: android app based home automation

for (int i= 0; i<=72;i=i+15)

{motor.step(i);}

lcd.setCursor(0,0); lcd.print("Temp: ");

lcd.setCursor(6,0); lcd.print(temperature);

lcd.setCursor(11,0); lcd.print(" C");

lcd.setCursor(7,1);lcd.print("opened ");

delay(1000);lcd.clear();

}

else if(data=='g')

{ lcd.setCursor(0,1); lcd.print("Garage closing");

for (int j= 0; j>=-72; j=j-15)

{motor.step(j);}

lcd.setCursor(0,0); lcd.print("Temp: ");

lcd.setCursor(6,0); lcd.print(temperature);

lcd.setCursor(11,0); lcd.print(" C");

lcd.setCursor(7,1);lcd.print("closed ");

delay(1000);lcd.clear();

}

}

// smart security of fire protection

if(smoke_level == 0){

tone(buzzerPin,50,5000);

lcd.setCursor(0,1); lcd.print("Fire!!! Escape>>");

for(int angle=0; angle<=90;angle=angle+45)

{ doorServo.write(angle);delay(100);}

for (int i= 0; i<=72;i=i+15)

{motor.step(i);}

digitalWrite(bulbPin, LOW);

digitalWrite(fanPin, LOW);

12 | P a g e

Page 14: android app based home automation

digitalWrite(tvPin, LOW);

digitalWrite(acPin, LOW);

delay(1500);

lcd.setCursor(0,1); lcd.print("Call FireService");

delay(2000);

}

else if(smoke_level == 1){

digitalWrite(buzzerPin, LOW);

lcd.setCursor(0,1); lcd.print("Ah!!! Safe Now ");

}

}

EQUIPMENT LIST | Chapter 3

NO. NAME OF EQUIPMENT AMOUNT PRICE PER

PIECE (tk)

SUBTOTAL

(tk)

01. Arduino Mega 2560 R3 1 1350 1350

02. 4 channel 5V relay module 1 280 280

03. Breadboard 2 120 240

04. Temperature Sensor 1 100 100

05. Smoke Sensor 1 180 180

06. PIR Motion Sensor 1 85 85

07. LCD Display 1 120 120

08. Bulb Holder 2 15 30

09. 2 pin Socket 1 15 15

10. Battery (9V) 1 45 45

11. Li-ion Battery 1 290 290

12. Buzzer 1 10 10

13. Servo Motor SG90R 1 160 160

14. Stepper Motor (Bipolar) 1 460 460

13 | P a g e

Page 15: android app based home automation

15. Jumpers 50 1.50 75

16. Cork Sheet 1 90 90

17. Bluetooth Module 1 350 350

TOTAL 3880

FEATURES & LIMITATIONS | Chapter 4

4.1 ADVANTAGES Our project provides the following advantages to the user.

1) Full time smart phone home automation with voice control 2) User can access his door or garage simply by touching on the door or garage icon or

voice command.3) The room temperature is shown in the LCD display as well as in our app.4) All the commands’ status is shown in the display e.g. fan on or off .

5) Fire Alarm and user protection : turning off the power in home saving from electric surges or exhausting and emergency unlocking the main door and the garage to exit and the app instantly call to the Fire Service Department.

6) Anti-theft alarm : the alarm will be activated when there is any unknown person accessed.

4.2 LIMIATTIONS OF OUR PROJECT In this Project almost we done all of our objectives, but still we have some limitation. The Limitation of our Project are discussed in below,

1) As we used Bluetooth for communicating between the android and Arduino, the data rate is not so fast and the range is small.

2) The temperature sensor we used to measure temperature, is not so accurate. Sometimes, it showed unbelievable temperature like 61.21°C or 47.69°C.

3) We used servo motor to just lock or unlock the door but user have to pull the door by himself.

4.3 FUTURE PLAN We see our project to be enhanced in the future and we hope to implement the followings:

1) We will include more and more features in our app like real time room monitoring via CC Camera as well as in our circuit.

14 | P a g e

Page 16: android app based home automation

2) We will include automatic police station calling and fire service calling thorough our

app. 3) We will use more accurate sensors to detect the occurrences accurately4) We will upgrade the security systems like biometric access, face detection, image

processing based garage opening etc.

PROJECT ATTACHMENT | Chapter 5 Project Picture- 01

15 | P a g e

Page 17: android app based home automation

Project Picture- 02

16 | P a g e

Page 18: android app based home automation

Project Picture- 03

17 | P a g e

Page 19: android app based home automation

Project Picture- 04

Conclusion | Chapter 6

6.1 CONCLUSION In this Electronics development project, we developed an prototype of home automation which really can be implemented in home costing very little amount of money. In beginning of this projects, we thought that we might not be capable of fulfilling the project. But, our honorable supervisor Mr. Shuvashis Saha sir encouraged us and instructed us very cordially. At last, alhamdulillah we have succeeded. Though we have faced different difficulties, we are happy to complete our project.

18 | P a g e

Page 20: android app based home automation

6.2 REFERENCES 1. Deepali Javale, Mohd. Mohsin, Shreerang Nandanwar and Mayur Shingate. International Journal of Electronics Communication and Computer Technology (IJECCT) Volume 3 Issue 2 (March 2013).

2. The official Arduino Website: http://arduino.cc/en/Guide/Introduction3. Ming Yan and Hao Shi, SMART LIVING USING BLUETOOTHBASED ANDROID SMARTPHONE, 2013.4. https://en.wikipedia.org/wiki/Android_(operating_system)5. http://www.cedia.org/blog/what-is-a-smart-home-the-basics-of-home-automation6. ai2.appinventor.mit.edu

Thanks to MIT App Inventor 2

19 | P a g e