Bluetooth Based Home Automation

Download as pdf or txt
Download as pdf or txt
You are on page 1of 71

2 | P a g e BLUETOOTH BASED HOME AUTOMATION SYSTEM

Table of Content

1. Overview of Project

1.1 Introduction

1.2 Block diagram

1.3 Project Modules


2. Hardware Description

2.1 Microcontroller

2.1.1 ATMEGA 8

2.1.2 Block Diagram

2.1.3 Features

2.1.4 Pin diagram


2.1.5 Pin description

2.1.6 Special Function Registers


2.1.7 Memory Organization
Program Memory

Data Memory
2.1.8 Watchdog Timer

2.2 BLUETOOTH MODULE (HC-05):Overview

2.1.7.1 Specifications

2.1.7.1 Pin out configuration


2.1.7.1 Typical Application Circuit
2.1.7.1 Pairing

2.1.7.1 Hc-05 Bluetooth module working voltage


2.1.7.1 Serial communication

2.3 Driver IC
ULN2003 Darlington Transistor Arrays

Simplified Schematics
Functional Block Diagram
Pin diagram

Inductive Load Drive


Resistive Load Drive
3 | P a g e BLUETOOTH BASED HOME AUTOMATION SYSTEM

2.4 Switches

2.4.1Relay

2.5 Connector

2.6 Aurdino burner


2.7Power supply

3. Software Introduction

3.1 PROTEUS

3.2 KEIL
3.3 VP812

3.4 Android App

4. Serial communication-Introduction Serial


communication in 89s52

4.1 Selection of baud rate


4.2 SBUF register

4.2.1 Configuration of SCON register


4.2.2 SM0, SM1

4.3 REN (receive enable)


4.4 TI (transmit interrupt)
4.5 RI (receive interrupt)

4.6 Steps for transmitting and receiving of character

4.6.1The steps that 8051 goes through in transmitting a character via TxD

4.6.2Programming the 8051 to transfer character bytes serially


4.6.3Importance of TI Flag

4.6.4Programming the 8051 to receive character bytes serially

5. Program
5.1 PROGRAM CODE
5.2 Program detail
4 | P a g e BLUETOOTH BASED HOME AUTOMATION SYSTEM

6. Circuit diagram & Component List

6.1 Component list

7. Problem descriptions

8. Advantages & Disadvantages

8.1 Advantages

8.2 Disadvantages

9. Future scope

10. Conclusion
5| P a g e BLUETOOTH BASED HOME AUTOMATION SYSTEM

1. OVERVIEW OF PROJECT

1.1 INTRODUCTION:

Automation involves introducing a degree of computerized or automatic control to certain


electrical and electronic systems in a building. These include lighting, temperature control, etc.
The past decade has seen significant advancement in the field of consumer electronics. Various
intelligent appliances such as cellular phone, air conditioners, home security devices, home
theaters, etc., are set to realize the concept of a smart home. They have given rise to a Personal
Area Network in home environment, where all these appliances can be interconnected and
monitored using a single controller.

This project demonstrates an automation system which contains a remote mobile host controller
and several client modules (eg.Office, home appliances). The client modules communicate with
the host controller through a wireless device such as a Bluetooth enabled mobile phone, in this
case, an android based Smart phone.

Although automation today is not a new thing but most advanced home automation systems in
existence today require a big and expensive change of infrastructure. We have proposed an
automation system that can control appliances like TVs, Fan, Tube lights from an android mobile
using Bluetooth. In this a low cost secure cell phone based, flexible automation system is
introduced. Devices are connected to the microcontroller based switching circuit.
6 | P a g e BLUETOOTH BASED HOME AUTOMATION SYSTEM

The communication between the cell phone and the microcontroller board is wireless. Additional
devices can be connected into the system with little modifications. The phone will be Android
OS based phone. The switching circuit will be having microcontroller coding to control the
electronics devices like fans and lights etc. 8-bit microcontroller board based on the ATMEGA 8
and the HC-05 Bluetooth module is used. It supports wireless serial communication over
Bluetooth. This board has 32 digital input and output ports.

The atmega 8 can be programmed using the microcontrollers high-level interactive embedded C
language. The Bluetooth antenna in our module picks up the packets sent from the cell phone.
Subsequently, these packets containing the device status as commands are pipelined through
atmega8 microcontroller and the designed analogue circuitry according to the definition of each
output.

Different home or office appliances are connected to the digital output ports of the circuit via
relays to provide sufficiently high currents and voltage compatibility. For test purposes, 25W,
240V lamps will be used.

We send commands from an application which is developed in phone to turn ON/OFF a device.
A feedback circuit has been designed and implemented to indicate the devices actual status after
it receives the command (ON/OFF) from the cell phone. Once the command has been sent to
turn ON a device, the feedback circuit senses the current and gives an output signal by turning
ON a respective led on the switching circuitry indicating that the device is ON. Otherwise, the
device is malfunctioning indicating that the command was not
7 | P a g e BLUETOOTH BASED HOME AUTOMATION SYSTEM

executed successfully. We can also operate the appliances of Home or Office in

Bluetooth range area.

1.2 Block diagram:-

Figure 1: Block diagram of Bluetooth based home automation

In this block diagram communication is in both direction between android mobile and Bluetooth
module. This communication is done one by one only one at a time. This communication is
called half duplex.

Feedback is done by getting 220v.feedback circuitry is so deigned that microcontroller can easily
sense.

1.3 Project Modules :-


The project can be better described by dividing it into two categories, namely,

1. Hardware
2. Software
8 | P a g e BLUETOOTH BASED HOME AUTOMATION SYSTEM

2. Hardware Description

2.1 Microcontroller:-Micro controller is just like a small computer but the basic difference
comes in size and memory. These have CPU, RAM, ROM, I/O and timers are all on a single
chip. It means you dont need any extra device to make it functional like with a micro-processor.
Generally this microcontroller is used where a specific task is needed to do. So fixed amount of
on-chip ROM, RAM, and number

2.1.1.ATMEGA 8:- The Atmel AVR ATmega8 is a low-power CMOS 8-bit microcontroller
based on the AVR RISC architecture. By executing powerful instructions in a single clock cycle,
the ATmega8 achieves throughputs approaching 1MIPS per MHz, allowing the system designer
to optimize power consumption versus processing speed.

The AtmelAVR core combines a rich instruction set with 32 general purpose working
registers. All the 32 registers are directly connected to the Arithmetic Logic Unit (ALU),
allowing two independent registers to be accessed in one single instruction executed in one clock
cycle. The resulting architecture is more code efficient while achieving throughputs up to ten
times faster than conventional CISC microcontrollers.
9 | P a g e BLUETOOTH BASED HOME AUTOMATION SYSTEM

2.1.2. Block Diagram:-


Figure 2: Block diagram of atmega 8 micro controller
10 | P a g e BLUETOOTH BASED HOME AUTOMATION SYSTEM

2.1.3. Features

I. High-performance, Low-power AtmelAVR 8-bit Microcontroller II.


Advanced RISC Architecture

III. 130 Powerful Instructions Most Single-clock Cycle Execution

IV. 32 8 General Purpose Working Registers

V. Fully Static Operation

VI. Up to 16MIPS Throughput at 16MHz VII.


On-chip 2-cycle Multiplier

VIII. High Endurance Non-volatile Memory segments

IX. 8Kbytes of In-System Self-programmable Flash program memory

X. 512Bytes EEPROM

XI. 1Kbyte Internal SRAM

XII. Write/Erase Cycles: 10,000 Flash/100,000 EEPROM

XIII. Data retention: 20 years at 85C/100 years at 25C(1)

XIV. Optional Boot Code Section with Independent Lock Bits

XV. In-System Programming by On-chip Boot Program

XVI. True Read-While-Write Operation

Programming Lock for Software Security


11 | P a g e BLUETOOTH BASED HOME AUTOMATION SYSTEM

2.1.4 Pin diagram:-

Fig. 3: Pin Diagram of ATMEGA 8


2.1.5. Pin description:-

VCC Digital supply voltage.

GND Ground.
12 | P a g e BLUETOOTH BASED HOME AUTOMATION SYSTEM

Port B (PB7..PB0)

XTAL1/XTAL2/TOSC1/
TOSC2

Port B is an 8-bit bi-directional I/O port with internal pull-up resistors (selected for each bit). The
Port B output buffers have symmetrical drive characteristics with both high sink and source
capability. As inputs, Port B pins that are externally pulled low will source current if the pull-up
resistors are activated. The Port B pins are tri-stated when a reset condition becomes active, even
if the clock is not running. Depending on the clock selection fuse settings, PB6 can be used as
input to the inverting Oscillator amplifier and input to the internal clock operating circuit.
Depending on the clock selection fuse settings, PB7 can be used as output from the inverting
Oscillator amplifier.

If the Internal Calibrated RC Oscillator is used as chip clock source, PB7..6 is used as TOSC2..1
input for the Asynchronous Timer/Counter2 if the AS2 bit in ASSR is set.

Port C (PC5..PC0)

Port C is an 7-bit bi-directional I/O port with internal pull-up resistors (selected for each bit).
The Port C output buffers have symmetrical drive characteristics with both high sink and source
capability. As inputs, Port C pins that are externally pulled low will source current if the pull-up
resistors are activated. The Port C pins are tri-stated when a reset condition becomes active, even
if the clock is not running.

PC6/RESET

If the RSTDISBL Fuse is programmed, PC6 is used as an I/O pin. Note that the electrical
characteristics of PC6 differ from those of the other pins of Port C.
13 | P a g e BLUETOOTH BASED HOME AUTOMATION SYSTEM

If the RSTDISBL Fuse is unprogrammed, PC6 is used as a Reset input. A low level on this pin
for longer than the minimum pulse length will generate a Reset, even if the clock is not running.
The minimum pulse length is given in Table 15 on page 38. Shorter pulses are not guaranteed to
generate a Reset. The various special features of Port C are elaborated on page 61.

Port D (PD7..PD0)

Port D is an 8-bit bi-directional I/O port with internal pull-up resistors (selected for each bit).
The Port D output buffers have symmetrical drive characteristics with both high sink and source
capability. As inputs, Port D pins that are externally pulled low will source current if the pull-up
resistors are activated. The Port D pins are tri-stated when a reset condition becomes active, even
if the clock is not running. Port D also serves the functions of various special features of the
ATmega8

RESET

Reset input. A low level on this pin for longer than the minimum pulse length will generate a
reset, even if the clock is not running. The minimum pulse length is given in Table 15. Shorter
pulses are not guaranteed to generate a reset.

AVCC

AVCC is the supply voltage pin for the A/D Converter, Port C (3..0), and ADC (7..6). It should
be externally connected to VCC, even if the ADC is not used. If the ADC is used, it should be
connected to VCC through a low-pass filter. Note that Port C (5..4) use digital supply voltage,
VCC.
14 | P a g e BLUETOOTH BASED HOME AUTOMATION SYSTEM

AREF

AREF is the analog reference pin for the A/D Converter.

ADC7..6 (TQFP and

QFN/MLF
Package Only)

In the TQFP and QFN/MLF package, ADC7..6 serve as analog inputs to the A/D converter.
These pins are powered from the analog supply and serve as 10-bit ADC channels.

2.2 BLUETOOTH MODULE (HC-05):

Overview: Communication device:-over project is based on wireless communication between


micro controller and mobile phone. But alone micro controller is not able to communicate
directly to the android mobile phone.

Bluetooth Serial modules operation doesnt need drive, and can communicate with the other
Bluetooth device that has the serial. But communication between two Bluetooth modules
requires at

Least two conditions:

(1) The communication must be between master and slave.

(2) The password must be correct.

HC-05 module is an easy to use Bluetooth SPP (Serial Port Protocol) module, designed for
transparent wireless serial connection setup. Serial port Bluetooth module is fully qualified
Bluetooth V2.0+EDR (Enhanced Data Rate) 3Mbps Modulation with complete 2.4GHz radio
transceiver and baseband. It uses CSR

Blue core 04External single chip Bluetooth system with CMOS technology and
15 | P a g e BLUETOOTH BASED HOME AUTOMATION SYSTEM

with AFH (Adaptive Frequency Hopping Feature). It has the Foot print as small as
12.7mmx27mm.

HC-05 module is an easy to use Bluetooth SPP (Serial Port Protocol) module, designed for
transparent wireless serial connection setup. Serial port Bluetooth module is fully qualified
Bluetooth V2.0+EDR (Enhanced Data Rate) 3Mbps Modulation with complete 2.4GHz radio
transceiver and baseband Bluetooth Wireless networks for short range communications have a
wide spread usage of Bluetooth radio transmissions between 24002480 MHz Modern mobile
devices embed small, low-powered and cheap integrated chips functioning as short-range radio
transceivers for Bluetooth radio communications. Device pairing, authentication, encryption and
authorization techniques have given recognition to Bluetooth technology due to its vital security
mechanisms.

Different types of Bluetooth applications can be developed using Android platform architecture
using the Bluetooth profiles. The device manufacturers provide the services using the support of
these profiles in their devices to maintain compatibility for the Bluetooth technology

Fig. 5.HC-05 Bluetooth


16 | P a g e BLUETOOTH BASED HOME AUTOMATION SYSTEM

2.2.1. Specifications

Hardware features
Typical -80dBm sensitivity.

Up to +4dBm RF transmits power.

Low Power 1.8V Operation, 3.3 to 5 V I/O.

PIO control.

UART interface with programmable baud rate.

With integrated antenna.

With edge connector.

Software features
Slave default Baud rate: 9600, Data bits:8, Stop bit:1,Parity:No parity.

PIO9 and PIO8 can be connected to red and blue led separately. When master and slave are
paired, red and blue led blinks 1time/2s in interval, while

disconnected only blue led blinks 2times/s.


Auto connects to the last device on power as default.

Permit pairing device to connect as default.

Auto pairing PINCODE:1234 as default.

Auto reconnect in 30 min when disconnected as a result of beyond the range of


connection.

2.2.2. Pin out configuration

Figure 6: Pin-out of HC-05


17 | P a g e BLUETOOTH BASED HOME AUTOMATION SYSTEM

2.2.3. Typical Application Circuit:

2.2.4. Pairing:

After connect the Bluetooth module, scan for new devices from the Android phone and you will
find the module with the device name HC-05, after that, click to connect, if some message
appears asking about Pairing code just put

1234 as default code.

BLUE LED = ACTIVE (Blinking 500ms period inactive connection, change 1seg with active
connection)

How to get to the standard communication mode


1. Leave free KEY, dont connect it to VDD neither GND.

2. Supply power to the module. Then the module will enter to communication mode. It can
be used for pairing.
18 | P a g e BLUETOOTH BASED HOME AUTOMATION SYSTEM

2.2.5. HC-05 BLUETOOTH MODULE WORKING VOLTAGE:-

The Bluetooth module HC-05 is used to receive & transmit data between Bluetooth device and
MCU. It requires power supply from 3.3V to 5V.

2.2.6. SERIAL COMMUNICATION:-

To transfer to a device located many meters away, the serial method is used. The data is sent
one bit at a time. Here not 8bit data is send 2 extra bit are send along with it .this two bit are
called start bit and stop bit. These two bit are used so synchronization can be done between
transmitter and receiver.

2.3 Driver IC:

2.3.1 ULN2003 Darlington Transistor Arrays:-

The ULN2003 device is a high-voltage, high- current Darlington transistor array. The device
consists of eight NPN Darlington pairs that feature high-voltage outputs with common-cathode
clamp diodes for switching inductive loads. The collector-current rating of each Darlington pair
is 500 mA. The Darlington pairs may be connected in parallel for higher current capability.

2.3.2 Simplified Schematics


Fig. 7.Simplified Schematics of ULN2003
19 | P a g e BLUETOOTH BASED HOME AUTOMATION SYSTEM

2.3.3. Functional Block Diagram:

Fig. 8.Functional block diagram of ULN2003

Each channel of ULN2003 consists of Darlington connected NPN transistors. This connection
creates the effect of a single transistor with a very high current gain. This can be as high as
10,000 A/A at certain currents. The very high gain allows for high output current drive with a
very low input current, essentially equating to operation with low GPIO voltages. The GPIO
voltage is converted to base current via the 2.7 k resistor connected between the input and base
of the pre-driver

Darlington NPN. The 7.2 k & 3.0 k resistors connected between the base and emitter of each
respective NPN act as pull-downs and suppress the amount of leakage that may occur from the
input. The diodes connected between the output and COM pin is used to suppress the kick-back
voltage from an inductive load that is excited when the NPN drivers are turned off (stop sinking)
and the stored energy in the coils causes a reverse current to flow into the coil supply via the
kick-back diode. In normal operation the diodes on base and collector pins to emitter will be
reversed biased. If these diode are forward biased, internal
20 | P a g e BLUETOOTH BASED HOME AUTOMATION SYSTEM

parasitic NPN transistors will draw (a nearly equal) current from other (nearby) device pins.

2.3.4 Pin diagram:-


Fig. 9.pin diaygram of uln 2003

ULN2003 Darlington Transistor Arrays pin no 10 can be used for inductive or non-inductive
load. These high output current driver pin can sink 500mA.If requirement of more current then
two pin can also be connected parallel. Parallel
21 | P a g e BLUETOOTH BASED HOME AUTOMATION SYSTEM

connection must be done both input and output. Input and output current will multiply according
to number of input and output connected parallel.

2.3.5 Inductive Load Drive

When the COM pin is tied to the coil supply voltage, ULN2803A is able to drive inductive loads
and suppress the Kick-back voltage via the internal freewheeling diodes.

2.3.6 Resistive Load Drive

When driving a resistive load, a pull-up resistor is needed in order for ULN2003 to sink current
and for there to be a logic high level. The COM pin can be left floating for these applications

2.4 Switches:-

Switches are used for connecting or disconnecting electrical circuit. Many types of switches are
there. Some are operate mechanically or electrically. Some types are SPST, SPDT, DPST and
DPDT in case of switch. SPST stands for single pole single through, SPDT stands for single pole
double through, DPST stands for double pole single through and DPDT stands for double pole
double through, In relays points are defines by NO, NC. NO stand for normally on and NC
stands for normally off.

2.4.1 Relay:-

Relays are electromagnetic switch. Which can be turn on and off by Appling electrical current.
Working voltage is printed on the relay. In this project we are
22 | P a g e BLUETOOTH BASED HOME AUTOMATION SYSTEM

using 6volt relay. Many relay use an electromagnet to mechanically operate a switch.

Fig.10. .Relays

2.5 Connector:-

Connectors are used for joining two wires temporally by using connector big circuit can be
divided and after completion they can rejoin. Now a days every time inverter circuited can be
removed out without using de soldering.

2.6 Aurdino burner:-

Arduino is common term for a software company, project, and user community, that designs and
manufactures computer open-source hardware, open-source software, and microcontroller-
based kits for building digital devices and interactive objects that can sense and control physical
devices.[1]
23 | P a g e BLUETOOTH BASED HOME AUTOMATION SYSTEM

Arduino is common term for a software company, project, and user community, that designs and
manufactures computer open-source hardware, open-source software, and microcontroller-
based kits for building digital devices and interactive objects that can sense and control physical
devices.[1]

The project is based on microcontroller board designs, produced by several vendors, using
various microcontrollers. These systems provide sets of digital and analog I/O pins that can
interface to various expansion boards (termed shields) and other circuits. The boards feature
serial communication interfaces, including Universal Serial Bus (USB) on some models, for
loading programs from personal computers. For programming the microcontrollers, the Arduino
project provides an integrated development environment(IDE) based on a programming
language named Processing, which also supports the languages C and C++.
24 | P a g e BLUETOOTH BASED HOME AUTOMATION SYSTEM

The first Arduino was introduced in 2005, aiming to provide a low cost, easy way for novices
and professionals to create devices that interact with their environment using sensors and
actuators. Common examples of such devices intended for beginner hobbyists include simple
robots, thermostats, and motion detectors.

Arduino boards are available commercially in preassembled form, or as do-it- yourself kits. The
hardware design specifications are openly available, allowing the Arduino boards to be produced
by anyone. Adafruit Industries estimated in mid-2011 that over 300,000 official Arduinos had
been commercially produced,[2] and in 2013 that 700,000 official boards were in users' hands.

The project is based on microcontroller board designs, produced by several vendors, using
various microcontrollers. These systems provide sets of digital and analog I/O pins that can
interface to various expansion boards (termed shields) and other circuits. The boards feature
serial communication interfaces, including Universal Serial Bus (USB) on some models, for
loading programs from personal computers. For programming the microcontrollers, the Arduino
project provides an integrated development environment(IDE) based on a programming
language named Processing, which also supports the languages C and C++.

The first Arduino was introduced in 2005, aiming to provide a low cost, easy way for novices
and professionals to create devices that interact with their environment using sensors and
actuators. Common examples of such devices intended for beginner hobbyists include simple
robots, thermostats, and motion detectors.
25 | P a g e BLUETOOTH BASED HOME AUTOMATION SYSTEM

Arduino boards are available commercially in preassembled form, or as do-it- yourself kits. The
hardware design specifications are openly available, allowing the Arduino boards to be produced
by anyone. Adafruit Industries estimated in mid-2011 that over 300,000 official Arduinos had
been commercially produced,[2] and in 2013 that 700,000 official boards were in users' hands.

2.7 LCD:-

LCD (Liquid Crystal Display) screen is an electronic display module and find a wide range of
applications. A 16x2 LCD display is very basic module and is very commonly used in various
devices and circuits. These modules are preferred over seven segments and other multi segment
LEDs. The reasons being: LCDs are economical; easily programmable; have no limitation of
displaying special & even custom characters (unlike in seven segments), animations and so on.

A 16x2 LCD means it can display 16 characters per line and there are 2 such lines. In this LCD
each character is displayed in 5x7 pixel matrix. This LCD has two registers, namely, Command
and Data.

The command register stores the command instructions given to the LCD. A command is an
instruction given to LCD to do a predefined task like initializing it, clearing its screen, setting the
cursor position, controlling display etc. The data register stores the data to be displayed on the
LCD. The data is the ASCII value of the character to be displayed on the LCD. Click to learn
more about internal structure of a LCD.
26 | P a g e BLUETOOTH BASED HOME AUTOMATION SYSTEM

Pin Diagram:

Pin Description:

Pin
Function Name
No
1 Ground (0V) Ground

2 Supply voltage; 5V (4.7V 5.3V) Vcc

3 Contrast adjustment; through a variable resistor VEE

Selects command register when low; and data register when


4 Register Select
high

5 Low to write to the register; High to read from the register Read/write

6 Sends data to data pins when a high to low pulse is given Enable

7 DB0

8-bit data pins


8 DB1
27 | P a g e BLUETOOTH BASED HOME AUTOMATION SYSTEM

9
DB2

10 DB3

11 DB4

12 DB5

13 DB6

14 DB7

15 Backlight VCC (5V) Led+

16 Backlight Ground (0V) Led-

3. Software

INTRODUCTION: Electronic design automation (EDA or ECAD) is a category of software


tools for designing electronic systems such as printed circuit boards

and integrated circuits. The tools work together in a design flow that chip designers use to design
and analyze entire semiconductor chips. The various softwares used are:

3.1 EAGLE:-

EAGLE stands for, Easily Applicable Graphical Layout Editor in English

and, Einfach anzuwendender grafischer Layout-Editor inGerman. It is designed

and developed by CadSoft Computer GmbH and is a flexible, expandable and scriptable,
electronic design automation (EDA) application with schematic capture editor, printed circuit
board (PCB) layout editor, auto-router and computer-aided manufacturing (CAM) and bill of
materials (BOM) tools. Premier Farnell bought EAGLE in 2008.[1]
28 | P a g e BLUETOOTH BASED HOME AUTOMATION SYSTEM
29 | P a g e BLUETOOTH BASED HOME AUTOMATION SYSTEM

3. 2 Serial communication in atmega8

SERIAL COMMUNICATION-INTRODUCTION: Serial is a device communication protocol


that is standard on almost every PC. Do not confuse it with universal serial bus (USB). Most
computers include two EIA-232 based serial ports. Serial is also a common communication
protocol for instrumentation in many devices, and numerous GPIB-compatible devices come
with an EIA-232 port. Furthermore, you can use serial communication for data acquisition in
conjunction with a remote sampling device

5. Program

5.1 PROGRAM CODES:

#include <reg52.h> #define


OUT_PORT1 P2 #define
HIGH 1

sbit IN = P2^0;
sbit IN2 = P2^1;

sbit CFL1 = OUT_PORT1^5;


sbit CFL2 = OUT_PORT1^6;
sbit CFL3 = OUT_PORT1^7;
30 | P a g e BLUETOOTH BASED HOME AUTOMATION SYSTEM

void com3();
void com2();
void com1();

void delay(const unsigned int ms);


unsigned char z;

unsigned char Mess1[]="SW OFF,"; unsigned


char Mess2[]="SW ONN,"; unsigned char
Mess3[]="Access Denied,";\ void main()

unsigned char mybyte;


unsigned char old;
unsigned char rx;

TMOD=0x20; //use Timer 1, mode 2

TH1=0xFD; //9600 baud rate

SCON=0x50;

TR1=1; //start timer

while (1) { //repeat forever

while (RI==0); //wait to receive; //save value


31 | P a g e BLUETOOTH BASED HOME AUTOMATION SYSTEM

old = SBUF;
RI=0;
delay(30);
rx = SBUF;
RI=0;

if (old = rx)

mybyte = old;

else

mybyte = rx;

if(mybyte==0x01)

CFL1=CFL1^HIGH;//toggle bit

mybyte=0xff;

old =0xff;

if(IN2==0)
32 | P a g e BLUETOOTH BASED HOME AUTOMATION SYSTEM

{ //check switch on

com2(); //send status

else

com1();

else if(mybyte==0x02)

CFL2=CFL2^HIGH;

mybyte=0xff;
if(IN==0) {

com2();

else

{
33 | P a g e BLUETOOTH BASED HOME AUTOMATION SYSTEM

com1();

else if(mybyte==0x03)

CFL3=CFL3^HIGH;

mybyte=0xff;
if(CFL3==0) {

com1();

else

com2();

else if(mybyte==0x04) // check port 1 value

{
34 | P a g e BLUETOOTH BASED HOME AUTOMATION SYSTEM

SBUF=P2;

while(TI==0); //wait for transmit


TI=0;

else if(mybyte==0x05) // check port 1 value

if(IN==0)

{ //check switch on
com2(); //send status

else

com1();

else if(mybyte==0x06) // check port 1 value

{
35 | P a g e BLUETOOTH BASED HOME AUTOMATION SYSTEM

if(IN2==0)

{ //check switch on
com2(); //send status

else

com1();

else

com3();

void com3()

for (z=0;z<15;z++) {
36 | P a g e BLUETOOTH BASED HOME AUTOMATION SYSTEM

SBUF=Mess3[z]; //place value in buffer


while(TI==0); //wait for transmit

TI=0;

void com2()

for (z=0;z<8;z++) {

SBUF=Mess2[z]; //place value in buffer


while(TI==0); //wait for transmit

TI=0;

void com1()

for (z=0;z<8;z++) {
37 | P a g e BLUETOOTH BASED HOME AUTOMATION SYSTEM

SBUF=Mess1[z]; //place value in buffer


while(TI==0); //wait for transmit

TI=0;

void delay(const unsigned int ms)

unsigned int x, y;

for(x = 0; x<=ms;x++)

for(y=0;y<=1275;y++);

5.2 Program detail

1. #include <reg52.h>:-By using this we define the header file of micro controller 89s52.

2. #define OUT_PORT2 P1:-this line is used for defining a port with output port.
38 | P a g e BLUETOOTH BASED HOME AUTOMATION SYSTEM

3. SBUF is an 8-bit register used solely for serial communication For a byte data to be
transferred via the Txd line, it must be placed in the SBUF register .The moment a byte is
written into SBUF, it is framed with the start and stop bits and transferred serially via the
Txd line .SBUF holds the byte of data when it is received by 8051 RxD line .When the
bits are received serially via RxD, the 8051 deframes it by eliminating the stop and start
bits, making a byte out of the data received, and then placing it in SBUF.

4. SCON is an 8-bit register used to program the start bit, stop bit, and data bits of data
framing, among other things.

5. TI (transmit interrupt) When 8051 finishes the transfer of 8-bit character .It raises TI flag
to indicate that it is ready to transfer another byte TI bit is raised at the beginning of the
stop bit.

6. RI (receive interrupt) When 8051 receives data serially via RxD, it gets rid of the start
and stop bits and places the byte in SBUF register It raises the RI flag bit to indicate that
a byte has been received and should be picked up before it is lost .RI is raised halfway
through the stop bit.
39 | P a g e BLUETOOTH BASED HOME AUTOMATION SYSTEM

6. Circuit diagram & Component List

6.1. Component list:-

S.No Component Name Nos. Required

1 HC-05 Bluetooth module 1

2 ATMEGA8 micro controller IC 1

3 ULN2003 IC 3

4 5V relay 2

5 Crystal 12MHz or 11.0592MHz 1

6 1K Resistor 1

7 22f or 10f electrolyte capacitor 2

8 30pf or 22pf ceramic capacitor 2

9 10k resistor network 3

10 7805 IC 2

11 12V battery 2

12 220v to 6v-0-6v step down transformer 1

13 1N4007 diode 3
40 | P a g e BLUETOOTH BASED HOME AUTOMATION SYSTEM

6.2 Circuit Diagram:


Circuit diagram of main board
41 | P a g e BLUETOOTH BASED HOME AUTOMATION SYSTEM

Circuit diagram of Relay board


42 | P a g e BLUETOOTH BASED HOME AUTOMATION SYSTEM
43 | P a g e BLUETOOTH BASED HOME AUTOMATION SYSTEM

7. Problem description

The various problems & FAQs associated with the project are:

7.1. No manual control to switch on and off or in system when

failed:-

In that case we can use a two way switch so if automation system fails than control given
to manual. As the manual control provided unskilled user can perform his routine control.
As shown below.

In fig a two way connection with relay is shown. The control act as a XOR operation
mines that output is one when both input are same. So output is available when positions
of both switches are same.
44 | P a g e BLUETOOTH BASED HOME AUTOMATION SYSTEM

Fig. 29.Wiring connection to switch

7.2. No confirmation of change of output:-

To overcome this problem programming can be do so that controller can compare its
previous state. So if state of switch not changes than controller send an error comes or
no change.

7.3. No debugging option:-

This can be a very good feature of project i.e. you can check that where problem
comes at hardware or in software. So controller gave all information about
communication.
7.4. Complex user interface:-

User interface must be simple so no need to teach the other every time.

But in similar project interface is complex.


45 | P a g e BLUETOOTH BASED HOME AUTOMATION SYSTEM

7.5. Different key to on and off:-

In survey it is seen that there are two different key to turn n and off appliances. But if
in programming toggle of bit is done then more automation can be done in this project.

7.6. Restart power at every new pairing of device:-

In HV-05 Bluetooth module if a device is parried then this configuration is save. So at


every new device pairing needs restart of circuit power. This problem can be removed
if we use a feature of HC-05 Bluetooth i.e. key this a pin in Bluetooth that can
remove all paired detail when this pin high pulses. So connection of this pin with
micro controller can rest the pairing.

7.7. Large change in house wiring:-

In similar project the automation done by mobile only so all connection needs to
change in wiring and removal of button connection is needed

.So to avoid this circuit is so design as sown in problem 1 solution.

7.8. Security of hacking control:-

The Bluetooth connection kept open so other con connect and take control. so the
master user must connect to Bluetooth and removal of pair info must by master
controller by software control.
46 | P a g e BLUETOOTH BASED HOME AUTOMATION SYSTEM

8. Advantages & Disadvantages

8.1 Advantages

1. Wireless control:-

By using this project wireless control can be within the hands of user.

2. Monitoring:-

This circuit allow monitoring of all appliance within range of communication with
Bluetooth.

3. Status checking :-

When user doesnt know appliances is on off then user can only check the status only.

4. Confirmation of changing switch state:-

When switch is press ten two status will be shown on mobile phone i.e. old status and
new status

5. Manual control:-

Manual control is given so an unskilled user can be change the current status.

8.2. Disadvantages:-

1. Bluetooth range:-
47 | P a g e BLUETOOTH BASED HOME AUTOMATION SYSTEM

It is good to use Bluetooth for automation but automation is kept within a range 0f 10-30
metres. So control can be achieved from outside range.

2. Connection:-

Application must be connected after disconnection from Bluetooth.

3. configuration of application software:-

If new user want to connect then first download application software and then code must
be enter and more configuration must be done.

9. FUTURE SCOPE

This project can be further developed by integrating it with the internet to monitor your home
while sitting in a remote area. By doing this, one can keep an eye on his or her home through an
internet connected to the users mobile phone or PC or laptop. This will not only improve the
security of your home in this modern day world but will also assist in conservation of energy like
if you left any home appliance switched on by mistake, then you can check the status of the
appliance on the graphical interface made on your mobile and can switch it off using the internet
connectivity.
48 | P a g e BLUETOOTH BASED HOME AUTOMATION SYSTEM

10. CONCLUSION

In conclusion, this low cost system is designed to improve the standard living in

home. The remote control function by smart phone provides help and assistance

especially to disabled and elderly. In order to provide safety protection to the

user, a low voltage activating switches is replaced current electrical switches.

Moreover, implementation of wireless Bluetooth connection in control board

allows the system install in more simple way. The control board is directly

installed beside the electrical switches whereby the switching connection is

controlled by relay.

Furthermore, flexible types of connections are designed as backup connections to the system.
The connected GUIs are synchronized to the control board. They indicate the real-time switches
status. The system is designed in user-friendly interface. The easy to use interface on Window
and Android GUI provides simple control by the elderly and disabled people.

For future work, the Window GUI will be implemented with speech recognition voice
control. The android GUI will be implemented as a remote Bluetooth
49 | P a g e BLUETOOTH BASED HOME AUTOMATION SYSTEM

microphone to the Window GUI. All the voice signal inputs to the smart phone will be
transmitted to the Window GUI for signal processing. Also, the push buttons implemented in
low voltage activating switches will be replaced by capacitive sensing switches. All the future
work is expected without spend extra cost, even one cent from the current system.
REFERENCES

1. Electronics for you magine June 2013

Keil vision IDE, http://www.keil.com/uvision.

2. www.vp812.com

3. Serial Bluetooth Module, Tiny OS Electronics, http://www.tinyosshop.com

4. AT89s52 8 bit Microcontroller, ATMEL Corporations, http://www.atmel.com3.

5. The official Bluetooth website from Bluetooth SIG: http://www.bluetooth.com


50 | P a g e BLUETOOTH BASED HOME AUTOMATION SYSTEM

6. The 8051 microcontroller and embedded systems by Muhammad Ali Mazidi and Janice
Gillispie Mazidi.

You might also like