Bluetooth Based Home Automation
Bluetooth Based Home Automation
Bluetooth Based Home Automation
Table of Content
1. Overview of Project
1.1 Introduction
2.1 Microcontroller
2.1.1 ATMEGA 8
2.1.3 Features
Data Memory
2.1.8 Watchdog Timer
2.1.7.1 Specifications
2.3 Driver IC
ULN2003 Darlington Transistor Arrays
Simplified Schematics
Functional Block Diagram
Pin diagram
2.4 Switches
2.4.1Relay
2.5 Connector
3. Software Introduction
3.1 PROTEUS
3.2 KEIL
3.3 VP812
4.6.1The steps that 8051 goes through in transmitting a character via TxD
5. Program
5.1 PROGRAM CODE
5.2 Program detail
4 | P a g e BLUETOOTH BASED HOME AUTOMATION SYSTEM
7. Problem descriptions
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:
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
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. 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.3. Features
X. 512Bytes EEPROM
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
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.
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
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
2.2.1. Specifications
Hardware features
Typical -80dBm sensitivity.
PIO control.
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
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
BLUE LED = ACTIVE (Blinking 500ms period inactive connection, change 1seg with active
connection)
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
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.
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.
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.
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.
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.
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.
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.
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
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
9
DB2
10 DB3
11 DB4
12 DB5
13 DB6
14 DB7
3. Software
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:-
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
5. Program
sbit IN = P2^0;
sbit IN2 = P2^1;
void com3();
void com2();
void com1();
SCON=0x50;
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
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();
{
34 | P a g e BLUETOOTH BASED HOME AUTOMATION SYSTEM
SBUF=P2;
if(IN==0)
{ //check switch on
com2(); //send status
else
com1();
{
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
TI=0;
void com2()
for (z=0;z<8;z++) {
TI=0;
void com1()
for (z=0;z<8;z++) {
37 | P a g e BLUETOOTH BASED HOME AUTOMATION SYSTEM
TI=0;
unsigned int x, y;
for(x = 0; x<=ms;x++)
for(y=0;y<=1275;y++);
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
3 ULN2003 IC 3
4 5V relay 2
6 1K Resistor 1
10 7805 IC 2
11 12V battery 2
13 1N4007 diode 3
40 | P a g e BLUETOOTH BASED HOME AUTOMATION SYSTEM
7. Problem description
The various problems & FAQs associated with the project are:
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
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.
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.
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.
In similar project the automation done by mobile only so all connection needs to
change in wiring and removal of button connection is needed
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.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.
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:-
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
allows the system install in more simple way. The control board is directly
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
2. www.vp812.com
6. The 8051 microcontroller and embedded systems by Muhammad Ali Mazidi and Janice
Gillispie Mazidi.