You are on page 1of 35

BLUETOOTH BASED HOME AUTOMATION USING ANDROID APPLICATION

CHAPTER I

INTRODUCTION

1.1 INTRODUCTION

Usually conventional wall switches are located in different parts of the house and often
require persons for their operations and, thus, manual pressing turn them ON and OFF . It
becomes very difficult for the elderly or physically handicapped people to operate them. This
system is enhanced to control the home applications through an Android application of smart
phones or tablet phones by entering the selected number for corresponding load.

The proposed system uses an Arduino board and a rectified power supply. A Bluetooth
is interfaced to the Arduino board using Rx and Tx pins for communication. The electrical
loads are controlled by the TRIAC device which is connected to the Arduino board through
opto-isolator. Opto-coupler is connected to trigger the back-to-back SCRs (TRIACS) with
isolation from the controlling section.

If an owner connects his/her Android application device to an Arduino system through


Bluetooth then he/she can send the control signals through the Bluetooth attached to the
Arduino system. He/she can enter the selected option in the Android application on the GUI
for corresponding loads and that data is sent to the Arduino system. The received data is
compared with the stored data in the Arduino and, if it matches, then the microcontroller will
perform the desired operation.

DEPARTMENT OF ECE, CMRCET Page 1


BLUETOOTH BASED HOME AUTOMATION USING ANDROID APPLICATION

1.2 AIM OF THE PROJECT

The main aim of the project is to control the home application remotely using android
OS smart phones with an Arduino board. This is an advanced technology in the home
automation, so houses are getting smarter.

1.3 DESIGN REQUIREMENTS


MICROCONTROLLER
RELAY
BLUETOOTH MODULE (HC-05)
LCD

1.4 METHODOLOGIES
In order to achieve the goals of this project the work has been divided as follows :

Study of ATMEL microcontroller


Study of Bluetooth Module
Study of LCD
Study of Relays

1.5 SOFTWARE REQUIREMENTS

ARDIUNO
EMBEDDED C LANGUAGE

CHAPTER 2

DEPARTMENT OF ECE, CMRCET Page 2


BLUETOOTH BASED HOME AUTOMATION USING ANDROID APPLICATION

DESIGN AND IMPLEMENTATION

2.1 BLOCK DIAGRAM

DEPARTMENT OF ECE, CMRCET Page 3


BLUETOOTH BASED HOME AUTOMATION USING ANDROID APPLICATION

Fig: 2.1 BLOCK DIAGRAM OF BLUETOOTH HOME AUTOMATION

2.1.1 EXPLANATION OF BLOCK DIAGRAM :


ATMEGA 328p

The Atmel 8-bit RISC-based microcontroller combines 32 kB ISP flash memory with
read-while-write capabilities, 1 kB EEPROM, 2 kB SRAM, 23 general purpose I/O lines, 32
general purpose working registers, three flexible timer/counters with compare modes, internal
and external interrupts, serial programmable USART, a byte-oriented 2-wire serial interface,
SPI serial port, 6-channel 10-bit A/D converter (8-channels in TQFP and QFN/MLF
packages), programmable watchdog timer with internal oscillator, and five software
selectable power saving modes. The device operates between 1.8-5.5 volts.

Fig 2.1.1:ATMEGA328P Microcontroller

POWER SUPPLY

All the digital circuits require regulated power supply. Here by using a step down
transformer , rectifier , filter capacitor and regulator we convert the 230V AC supply that we
get from the mains into a regulated DC voltage of 5V which we require to operate all the
components that we are using in our project.
DEPARTMENT OF ECE, CMRCET Page 4
BLUETOOTH BASED HOME AUTOMATION USING ANDROID APPLICATION

BLUETOOTH MODULE (HC-05)

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 Bluecore 04-External single chip Bluetooth system with CMOS
technology and with AFH(Adaptive Frequency Hopping Feature). It has the footprint as small
as 12.7mmx27mm. It will simplify your overall design/development cycle.

Fig 2.1.2: HC-05 Bluetooth


Module

LCD MODULE

Liquid Crystal Display also called as LCD is very helpful in


providing user interface as well as for debugging purpose. The most common type of LCD
controller is HITACHI 44780 which provides a simple interface between the controller and
an LCD. These LCDs are very simple to interface are simple to interface with the controller
as well as are cost effective.

DEPARTMENT OF ECE, CMRCET Page 5


BLUETOOTH BASED HOME AUTOMATION USING ANDROID APPLICATION

Fig 2.1.3: Liquid Crystal Display

RELAY

A relay is an electrically operated switch. Many relays use an electromagnet to mechanically


operate a switch, but other operating principles are also used, such as solid-state relays.
Relays are used where it is necessary to control a circuit by a low-power signal (with
complete electrical isolation between control and controlled circuits), or where several
circuits must be controlled by one signal. The first relays were used in long distance telegraph
circuits as amplifiers: they repeated the signal coming in from one circuit and re-transmitted
it on another circuit. Relays were used extensively in telephone exchanges and early
computers to perform logical operations.

A type of relay that can handle the high power required to directly control an electric motor
or other loads is called a contractor . Solid-state relays control power circuits with no moving
parts, instead using a semiconductor device to perform switching. Relays with calibrated
operating characteristics and sometimes multiple operating coils are used to protect electrical
circuits from overload or faults; in modern electric power systems these functions are
performed by digital instruments still called protective relays.

DEPARTMENT OF ECE, CMRCET Page 6


BLUETOOTH BASED HOME AUTOMATION USING ANDROID APPLICATION

Fig 2.1.4: Relay

CONNECTING WIRES

Cables made to connect to these pin headers are usually one of two types: individual wires
with crimp connectors on them or ribbon cables with insulation displacement connectors.
These can simply be clamped onto the end of a ribbon cable, which creates a connection to
each one of the conductors in the ribbon cable.

2.2 CIRCUIT DIAGRAM

DEPARTMENT OF ECE, CMRCET Page 7


BLUETOOTH BASED HOME AUTOMATION USING ANDROID APPLICATION

Fig 2.2 Circuit Diagram of the project

2.3 FLOW CHART


START

Initialize LCD, HC-05

DEPARTMENT OF ECE, CMRCET Page 8


BLUETOOTH BASED HOME AUTOMATION USING ANDROID APPLICATION

While
FALSE
serial.availabl
e
TRUE

If a==1; If a==2; If a==3;

Light Light Fan On


On Of

If If If a==6;
a==4;5; a==5;5;

Fan Of All On All Of

STOP

Fig 2.3.1: Flow chart

2.4 DESCRIPTION OF THE PROJECT

This project consists of a microcontroller, 16 x 2 alphanumeric LCD, two 5V relays,


two lamps , and Bluetooth module. Here ATMEGA 328p microcontroller is used.

DEPARTMENT OF ECE, CMRCET Page 9


BLUETOOTH BASED HOME AUTOMATION USING ANDROID APPLICATION

It is an 8 bit microcontroller and it requires supply voltage of 5V DC. Use 7805 power
supply circuit to provide 5V DC to the microcontroller. We can use 9V DC battery or 12V, 1A
adapter to provide the supply to the circuit In the above circuit LCD is used to indicate the
status of electrical loads and also used to display received data from Bluetooth. Here LCD is
interfaced to the microcontroller in 4 bit mode.

Bluetooth module TX and RX pins are connected to the RXD and TXD pins of
controller. Vcc pin is connected to the 5V and GND pin is connected to ground. Controller
communicates with Bluetooth module using serial communication (UART protocol). Use a
baud rate of 9600 to communicate with Bluetooth.

2.5 WORKING OF THE PROJECT

As soon as the application starts it asks to enable the Bluetooth of the phone , if user
presses NO , app ends , if user presses YES , it turns on the Bluetooth and automatically
search for nearby devices to connect with . When the user selects the device the phone
automatically pair with that device . The screen will have options for various devices . When
the desired option has been selected by the user , it is sent to the Bluetooth module which
further transmits it to the arduino board using serial com with a baud rate of 9600 . For
instance, if key1 is selected then the corresponding operation will occur.

CHAPTER 3

RESULT AND DISCUSSION

3.1 RESULT AND CASE STUDY


The project BLUETOOTH BASED HOME AUTOMATION USING ANDROID
APPLICATION has been successfully designed and tested. Integrating features of all the

DEPARTMENT OF ECE, CMRCET Page 10


BLUETOOTH BASED HOME AUTOMATION USING ANDROID APPLICATION

hardware components used have developed it .Presence of every module has been reasoned
and placed carefully thus contributing to the best working of the unit. Secondly using highly
advanced ICs and with the help of the growing technology the project has been successfully
implemented.

Fig 3.1 :Waiting for Command

In the above fig 3.1 we can find the arduino set up to be in a waiting
stage expecting an input from the Bluetooth module. Once the input is
given from the mobile device the appropriate action is performed.

DEPARTMENT OF ECE, CMRCET Page 11


BLUETOOTH BASED HOME AUTOMATION USING ANDROID APPLICATION

Fig 3.2 : Light ON

When LIGHTS ON input is given to the arduino kit from the mobile unit when it is in waiting
state, we observe from fig 3.2 that the light on and the arduino again returns to Waiting state.

Fig 3.3 : Light OFF

When LIGHTS OFF input is given to the arduino kit from the mobile unit when it is in
waiting state, we observe from fig 3.3 that the light is turned back off and the arduino again
returns to Waiting state.

DEPARTMENT OF ECE, CMRCET Page 12


BLUETOOTH BASED HOME AUTOMATION USING ANDROID APPLICATION

Fig 3.4 : Fan ON

When FAN ON input is given to the arduino kit from the mobile unit when it is in waiting
state, we observe from fig 3.4 that the fan tends to TURN ON and the arduino again returns
to Waiting state.

Fig 3.5 : Fan OFF

When FAN OFF input is given to the arduino kit from the mobile unit when
it is in waiting state, we observe from fig 3.5 that the fan which was
previously in ON state now gets Turned OFF and the arduino again returns
to Waiting state.

DEPARTMENT OF ECE, CMRCET Page 13


BLUETOOTH BASED HOME AUTOMATION USING ANDROID APPLICATION

Fig 3.6 : ALL ON

When ALL ON input is given to the arduino kit from the mobile unit when
it is in waiting state, we observe from fig 3.6 that the fan and light which
was previously in OFF state now gets Turned ON and the arduino again
returns to Waiting state.

Fig 3.7 : ALL OFF

When ALL OFF input is given to the arduino kit from the mobile unit when
it is in waiting state, we observe from fig 3.6 that the fan and light which

DEPARTMENT OF ECE, CMRCET Page 14


BLUETOOTH BASED HOME AUTOMATION USING ANDROID APPLICATION

was previously in ON state now gets Turned OFF and the arduino again
returns to Waiting state.

CHAPTER -4

CONCLUSION

4.1 CONCLUSION
In conclusion ,this low cost system is designed to improve the standards 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 are replaced by 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 where by 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 home automation system has been experimentally proven to work

satisfactorily by connecting sample appliances to it and the appliances were successfully

controlled from a wireless mobile device. The Bluetooth client was tested on different phones

from different manufacturers, thus proving its wide compatibility and portability. This project

will not only provide convenience to the common man but will be a boon for the old and

disabled.

DEPARTMENT OF ECE, CMRCET Page 15


BLUETOOTH BASED HOME AUTOMATION USING ANDROID APPLICATION

REFERENCES

[1] The official Bluetooth website from Bluetooth SIG: http://www.bluetooth.com

[2] J. Mander and D. Picopoulos, Bluetooth Piconet Applications, pp. 1-25.

[3] R. Piyare and M. Tazil, Bluetooth Based Home Automation System using Cell Phone,
in Consumer Electronics, 2011, pp. 192-195.

[4] Kailash Pati Dutta, Pankaj Rai and Vineet Shekher, Microcontroller Based Voice
Activated

Wireless Automation System:, VSRD-IJEECE, Vol. 2(8), 2012, 642-649

[5] Baris Yuksekkaya, A. Alper Kayalar, M. Bilgehan Tosun, M. Kaan Ozcan, and Ali Ziya

Alkar, A GSM, Internet and Speech Controlled Wireless Internet Home Automation
System, IEEE Transactions on Consumer Electronics,Vol. 52, No. 3, AUGUST 2006

[6] N. Sriskanthan and Tan Karande, Bluetooth Based Home Automation Systems, Journal
of Microprocessors and Microsystems, 2002, Vol. 26, pp. 281-289

[7] Kwang Yeol Lee & Jae Weon Choi, Remote-Controlled Home Automation System via

Bluetooth Home Network in SICE Annual Conference in Fukui, 2003, Vol. 3, pp. 2824-2829

[8] Wijetunge S.P., Wijetunge U.S., Peiris G.R.V,Aluthgedara C.S. & Samarasinghe A.T.L.K.,

Design and Implementation of a Bluetooth basedGeneral Purpose Controlling Module, in


IEEE, 2008, pp. 206-211

[9] Sandeep Kumar & Mohammed A Qadeer,Universal Digital Device Automation and

Control, in IEEE, 2009, pp. 490-494

[10] Hiroshi Kanma, Noboru Wakabayashi, Ritsuko Kanazawa & Hirimichi Ito, Home
Appliance Control System over Bluetooth with a Cellular Phone, in IEEE, 2003, pp. 1049-
1053

APPENDIX

DEPARTMENT OF ECE, CMRCET Page 16


BLUETOOTH BASED HOME AUTOMATION USING ANDROID APPLICATION

A.1 ATMEGA328P PIN DIAGRAM

Fig A.1: Pin diagram of ATMEGA328P

Atmels ATMega328P 8-Bit Processor in 28 pin DIP package. Its like the ATmega168, with
double the flash space. It has 32K of program space. 23 I/O lines , 6 of which are channels
for the 10-bit ADC and it runs up to 20MHz with external crystal . Package can be
programmed in circuit with an operating voltage of 1.8V to 5V

DEPARTMENT OF ECE, CMRCET Page 17


BLUETOOTH BASED HOME AUTOMATION USING ANDROID APPLICATION

A.1.1 Description Of ATMEGA328P Pin Diagram

VCC: Digital supply voltage.

GND: ground

Port B (PB7:0) 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:0) Port C is a 7-bit bi-directional I/O port with internal pull-up resistors
(selected for each bit). The PC5.0 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. 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.

Port D (PD7:0) 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. Th
Port D pins are tri-stated when a reset condition becomes active, even if the clock is
not running.

DEPARTMENT OF ECE, CMRCET Page 18


BLUETOOTH BASED HOME AUTOMATION USING ANDROID APPLICATION

A VCC is the supply voltage pin for the A/D Converter, PC3:0, and ADC7: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 PC6..4 use
digital supply voltage, VCC.

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.

A.2 Power supply

Introduction:

Power supply is a supply of electrical power. A device or system that


supplies electrical or other types of energy to an output load or group of loads is called a
power supply unit or PSU. The term is most commonly applied to electrical energy supplies,
less often to mechanical ones, and rarely to others. A power supply may include a power
distribution system as well as primary or secondary sources of energy such as

Conversion of one form of electrical power to another desired form and voltage,
typically involving converting AC line voltage to a well-regulated lower-
voltage DC for electronic devices.

Low voltage, low power DC power supply units are commonly integrated with the
devices they supply, such as computers and household electronics.

Batteries.

Chemical fuel cells and other forms of energy storage systems.

Fig A.2:
Regulated Power Supply

DEPARTMENT OF ECE, CMRCET Page 19


BLUETOOTH BASED HOME AUTOMATION USING ANDROID APPLICATION

The basic circuit diagram of a regulated power supply (DC O/P) with led connected as
load is shown in the below figure.

Fig A.2.1: Circuit diagram of Regulated Power Supply with Led connection

The components mainly used in above figure are

230v AC mains

Transformer

Bridge rectifier(diodes)

Capacitor

Voltage regulator(IC 7805)

Resistor

LED(light emitting diode)

A.2.1 Transformers:

A transformer is a device that transfers electrical energy from one circuit to another
through inductively coupled conductors without changing its frequency. A
varying current in the first or primary winding creates a varying magnetic flux in the
transformer's core, and thus a varying magnetic field through the secondary winding.

DEPARTMENT OF ECE, CMRCET Page 20


BLUETOOTH BASED HOME AUTOMATION USING ANDROID APPLICATION

A.2.2 Bridge full wave rectifier:

The Bridge rectifier circuit is shown in fig: 3, which converts an ac voltage to dc


voltage using both half cycles of the input ac voltage. The Bridge rectifier circuit is shown in
the figure. The circuit has four diodes connected to form a bridge. The ac input voltage is
applied to the diagonally opposite ends of the bridge. The load resistance is connected
between the other two ends of the bridge.

Fig A.2.2: Bridge full wave rectifier

A.2.3 Voltage Regulator:

A voltage regulator (also called a regulator) with only three terminals appears to be
a simple device, but it is in fact a very complex integrated circuit. It converts a varying input
voltage into a constant regulated output voltage. Voltage Regulators are available in a
variety of outputs like 5V, 6V, 9V, 12V and 15V. The LM78XX series of voltage regulators
are designed for positive input. For applications requiring negative input, the LM79XX series
is used. Using a pair of voltage-divider resistors can increase the output voltage of a
regulator circuit.

DEPARTMENT OF ECE, CMRCET Page 21


BLUETOOTH BASED HOME AUTOMATION USING ANDROID APPLICATION

Fig A.2.3: Voltage Regulator

It is not possible to obtain a voltage lower than the stated rating. You cannot use a
12V regulator to make a 5V power supply. Voltage regulators are very robust. These can
withstand over-current draw due to short circuits and also over-heating. In both cases, the
regulator will cut off before any damage occurs. The only way to destroy a regulator is to
apply reverse voltage to its input.

A.3 LCD MODULE

To display interactive messages we are using LCD module. We examine an Intelligent


LCD display of two lines, 16 characters per line that is interfaced to the Controllers. The
protocol

Fig A.3.1: LCD Display

(handshaking) for the display is as shown. Whereas D0 to D7th bit is the data lines, RS, RW
and En pins are the control pins and remaining pins are +5V,-5V and GND to provide supply.
Where RS is the register select, RW is the Read Write and EN is the Enable pin.To display
two internal byte wide registers one for commands (RS=0) and the second one for characters
to be displayed (RS=1). It also contains a user-programmed RAM area (the character RAM)
that can be programmed to generate any desired character that can be formed using a dot
matrix. To distinguish between those two data areas, the hex command Byte 80 will be used
to signify that the display RAM address is 00h will be choosen.port1 is used to furnish the
command or data type and ports 3.2 to 3.4 furnish register select at different read/write
levels.The display takes varying amounts of time to accomplish the functions as listed.LCD
bit 7 is monitored for logic high (busy) to ensure the display is overwritten. Liquid Crystal
Display also called as LCD is very helpful for providing user interface as well as for
debugging purpose. The most common type of LCD controller is HITACHI 44780 which
provides a simple interface between the controller & an LCD. These LCDs are very simple
to interface with the controller as well as cost effective.

DEPARTMENT OF ECE, CMRCET Page 22


BLUETOOTH BASED HOME AUTOMATION USING ANDROID APPLICATION

The most commonly used ALPHA NUMERIC displays are 1x16 (single Line & 16
characters), 2x16 (Double Line & 16 characters per line) & 4x20 (Four lines & twenty
characters per line).

The LCD requires 3 control lines (RS,R/W & EN)& 8 ( 0r 4) data lines. The number on
data lines depends on the mode of operation. If operated in 8-bit mode then 8 data lines +3
control lines i.e. 7 lines are required. How do we decide which mode to use? It simple if you
have sufficient data lines you can go for 8 bit mode & if there is a time constraint.

A.3.1 Pin Description Of LCD Display


Pin Symbol Function
1 Vss Ground
2 Vdd Supply voltage
3 Vo Contrast setting
4 Rs Register select
5 R/w Read/Write select
6 En Chip enable signal
Table A.3.1: Pin 7-14 DB0-DB7 Chip enable signal description of
LCD 15 A/Vee Gnd for backlight
16 K Vcc for backlight
When Rs is low (0), the data is to
be treated as a command. When RS is high (1),
The data being sent is considered as text data which should be displayed on the screen.
When R/w is low (0), the information on the data bus is being written to the LCD.
When R/W is high (1), the program is effectively reading from the LCD. Most of the times
there is no need to read from the LCD so this line can directly be connected to Gnd thus
saving one controller line .
The ENABLE pin is used to latch the data present on the data pins. A HIGH-LOW
signal is required to latch the data. The LCD interrupts and executes our command at the
instant the EN line is brought low. If you never bring EN low, your instruction will never be
executed.

A.3.2 LCD SCREEN:

LCD screen consists of two lines with 16 characters each. Each character consists of
5x7 dot matrix. Contrast on display depends on the power supply voltage and whether
messages are displayed in one or two lines. For that reason, variable voltage 0-Vdd is applied
on pin marked as Vee. Trimmer potentiometer is usually used for that purpose. Some versions

DEPARTMENT OF ECE, CMRCET Page 23


BLUETOOTH BASED HOME AUTOMATION USING ANDROID APPLICATION

of displays have built in backlight (blue or green diodes). When used during operating, a
resistor for current limitation should be used (like with any LE diode).

A.3.3 COMMANDS USED IN LCD

No. Instruction Hex Decimal


1 Function set:8-bit,1-line,5x7 dots 0X30 48
2 Function set:8-bit,2-line,5x7dots 0X38 56
3 Function set:4-bit,1-line,5x7dots 0X20 32
4 Function set:4-bit,2-line,5X7dots 0X28 40
5 Entry mode 0X06 6
6 Display off the cursor off 0X08 8
7 Display on cursor on 0X0E 14
8 Display on cursor off 0X0C 12
9 Display on cursor blinking 0X0F 15
10 Shift entire display left 0X18 24
11 Shift entire display right 0X1C 30
12 Move cursor left by one character 0X10 16
13 Move cursor right by one character 0X14 20
14 Clear display 0X01 1

A.3.4 LCD CONNECTION

Depending on how many lines are used for connection to the microcontroller, there

are 8-bit and 4-bit LCD modes. The appropriate mode is determined at the beginning of the

process in a phase called initialization. In the first case, the data are transferred through

outputs D0-D7 as it has been already explained. In case of 4-bit LED mode, for the sake of

saving valuable I/O pins of the microcontroller, there are only 4 higher bits (D4-D7) used for

communication, while other may be left unconnected.

Consequently, each data is sent to LCD in two steps: four higher bits are sent first (that

normally would be sent through lines D4-D7), four lower bits are sent afterwards. With the

help of initialization, LCD will correctly connect and interpret each data received. Besides,

with regards to the fact that data are rarely read from LCD (data mainly are transferred from

microcontroller to LCD) one more I/O pin may be saved by simple connecting R/W pin to

the Ground.

DEPARTMENT OF ECE, CMRCET Page 24


BLUETOOTH BASED HOME AUTOMATION USING ANDROID APPLICATION

A.4 RELAY :
A relay is usually an electromechanical device that is actuated by an electrical current.
The current flowing in one circuit causes the opening or closing of another circuit. Relays are
like remote-control switches and are used in many applications because of their relative
simplicity, long life, and proven high reliability. Relays are used in a wide variety of
applications throughout industry, such as in telephone exchanges, digital computers and
automation systems. Highly sophisticated relays are utilized to protect electric power
systems against trouble and power blackouts as well as to regulate and control the generation
and distribution of power. In the home, relays are used in refrigerators, washing machines
and dishwashers, and heating and air-conditioning controls. Although relays are generally
associated with electrical circuitry, there are many other types, such as pneu-matic and
hydraulic. Input may be electrical and output directly mechanical, or vice versa.

How do relays work?

All relays contain a sensing unit, the electric coil, which is powered by AC or DC
current. When the applied current or voltage exceeds a threshold value, the coil activates the
armature, which operates either to close the open contacts or to open the closed contacts.
When a power is supplied to the coil, it generates a magnetic force that actuates the switch
mechanism. The magnetic force is, in effect, relaying the action from one circuit to another.
The first circuit is called the control circuit; the second is called the load circuit.

A.5 BLUETOOTH MODULE

HC serial Bluetooth products consist of Bluetooth serial interface module and


Bluetooth adapter, such as:
(1) Bluetooth serial interface module:
Industrial level: HC-03, HC-04(HC-04-M, HC-04-S)
Civil level: HC-05, HC-06(HC-06-M, HC-06-S)

HC-05-D, HC-06-D (with baseboard, for test and evaluation)

(2) Bluetooth Adapter : HC-M4, HC-M6:


This document mainly introduces Bluetooth serial module. Bluetooth serial module is

DEPARTMENT OF ECE, CMRCET Page 25


BLUETOOTH BASED HOME AUTOMATION USING ANDROID APPLICATION

used for converting serial port to Bluetooth. These modules have two modes: master and
slaver device. The device named after even number is defined to be master or slaver when out
of factory and cant be changed to the other mode. But for the device named after odd
number, users can set the work mode (master or slaver) of the device by AT commands.
HC-04 specifically includes:
Master device: HC-04-M, M=master
Slave device: HC-04-S, S=slaver
The default situation of HC-04 is slave mode. If you need master mode, please state it
clearly or place an order for HC-O4-M directly.The naming rule of HC-06 is same.
When HC-03 and HC-05 are out of factory, one part of parameters are set for activating
the device.

The work mode is not set, since user can set the mode of HC-03, HC-05 as they want.
The main function of Bluetooth serial module is replacing the serial port line, such as:
1. There are two MCUs want to communicate with each other. One connects to

Bluetooth master device while the other one connects to slave device. Their connection can

be built once the pair is made. This Bluetooth connection is equivalently liked to a serial port

line connection including RXD, TX

signals. And they can use the Bluetooth serial module to communicate with each other.
2. When MCU has Bluetooth salve module, it can communicate with Bluetooth adapter of
computers and smart phones. Then there is a virtual communicable serial port line between
MCU and computer or smart phone.
3. The Bluetooth devices in the market mostly are salve devices, such as Bluetooth printer,
Bluetooth GPS. So, we can use master module to make pair and communicate with them.
Bluetooth Serial modules operation doesnt need drive, and can communicate with the
other Bluetooth device who 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

DEPARTMENT OF ECE, CMRCET Page 26


BLUETOOTH BASED HOME AUTOMATION USING ANDROID APPLICATION

Besides, with regards to the fact that data are rarely read from LCD (data mainly are
transferred from microcontroller to LCD) one more I/O pin may be saved by simple
connecting R/W pin to the Ground 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 Bluecore 04-
External single chip Bluetooth system with CMOS technology and with AFH(Adaptive
Frequency Hopping Feature). It has the footprint as small as 12.7mmx27mm.

Specifications

Hardware features

Typical -80dBm sensitivity

Up to +4dBm RF transmit power

Low Power 1.8V Operation ,1.8 to 3.6V I/O

PIO control

UART interface with programmable baud rate

With integrated antenna

With edge connector

Software features

Default Baud rate: 38400, Data bits:8, Stop bit:1,Parity:No parity, Data control: has.

Supported baud rate: 9600,19200,38400,57600,115200,230400,460800.

Given a rising pulse in PIO0, device will be disconnected.

PIO10 and PIO11 can be connected to red and blue led separately.

Auto-connect to the last device on power as default.

DEPARTMENT OF ECE, CMRCET Page 27


BLUETOOTH BASED HOME AUTOMATION USING ANDROID APPLICATION

Auto-pairing PINCODE:0000 as default

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

connection.

B .Software Developments

B.1. Arduino Uno

Introduction to the Arduino Board

DEPARTMENT OF ECE, CMRCET Page 28


BLUETOOTH BASED HOME AUTOMATION USING ANDROID APPLICATION

The Arduino is a family of microcontroller boards to simplify electronic design,


prototyping and experimenting for artists, hackers, hobbyists, but also many professionals.
People use it as brains for their robots, to build new digital music instruments, or to build a
system that lets your house plants tweet you when theyre dry. Arduinos (we use the standard
Arduino Uno) are built around an ATMEGA microcontroller essentially a complete
computer with CPU, RAM, Flash memory, and input/output pins, all on a single chip. Unlike,
say, a Raspberry Pi, its designed to attach all kinds of sensors, LEDs, small motors and
speakers, servos, etc. directly to these pins, which can read in or output digital or analog
voltages between 0 and 5 volts. The Arduino connects to your computer via USB, where you
program it in a simple language (C/C++, similar to Java) from inside the free Arduino IDE by
uploading your compiled code to the board. Once programmed, the Arduino can run with the
USB link back to your computer, or stand-alone without it no keyboard or screen needed,
just power.

Fig B.1.1 Structure of Arduino Board


Looking at the board from the top down, this is an outline of what you will see (parts
of the board you might interact with in the course of normal use are highlighted).

DEPARTMENT OF ECE, CMRCET Page 29


BLUETOOTH BASED HOME AUTOMATION USING ANDROID APPLICATION

Fig.B.1.2:Arduino Board
Starting clockwise from the top center:
Analog Reference pin (orange)

Digital Ground (light green)

Digital Pins 2-13 (green)

Digital Pins 0-1/Serial In/Out - TX/RX (dark green) - These pins cannot be used for
digital i/o (Digital Read and Digital Write) if you are also using serial communication
(e.g. Serial.begin).

Reset Button - S1 (dark blue)

In-circuit Serial Programmer (blue-green)

Analog In Pins 0-5 (light blue)

Power and Ground Pins (power: orange, grounds: light orange)

External Power Supply In (9-12VDC) - X1 (pink)

Toggles External Power and USB Power (place jumper on two pins closest to desired
supply) - SV1 (purple)

USB (used for uploading sketches to the board and for serial communication between
the board and the computer; can be used to power the board) (yellow)

DEPARTMENT OF ECE, CMRCET Page 30


BLUETOOTH BASED HOME AUTOMATION USING ANDROID APPLICATION

Digital Pins

In addition to the specific functions listed below, the digital pins on an Arduino board
can be used for general purpose input and output via the pin Mode(), Digital Read(), and
Digital Write() commands. Each pin has an internal pull-up resistor which can be turned on
and off using digital Write() (w/ a value of HIGH or LOW, respectively) when the pin is
configured as an input. The maximum current per pin is 40mA.

Serial: 0 (RX) and 1 (TX). Used to receive (RX) and transmit (TX) TTL serial data.
On the Arduino Diecimila, these pins are connected to the corresponding pins of the
FTDI USB-to-TTL Serial chip. On the Arduino BT, they are connected to the
corresponding pins of the WT11 Bluetooth module. On the Arduino Mini and LilyPad
Arduino, they are intended for use with an external TTL serial module (e.g. the Mini-
USB Adapter).

External Interrupts: 2 and 3. These pins can be configured to trigger an interrupt on


a low value, a rising or falling edge, or a change in value. See the attach Interrupt()
function for details.

PWM: 3, 5, 6, 9, 10, and 11 Provide 8-bit PWM output with the analog Write()
function. On boards with an ATmega8, PWM output is available only on pins 9, 10,
and 11.

BT Reset: 7. (Arduino BT-only) Connected to the reset line of the bluetooth module.

SPI: 10 (SS), 11 (MOSI), 12 (MISO), 13 (SCK). These pins support SPI


communication, which, although provided by the underlying hardware, is not
currently included in the Arduino language.

LED: 13. On the Diecimila and LilyPad, there is a built-in LED connected to digital
pin 13. When the pin is HIGH value, the LED is on, when the pin is LOW, it's off.
Analog Pins

In addition to the specific functions listed below, the analog input pins support 10-bit
analog-to-digital conversion (ADC) using the analog Read() function. Most of the analog

DEPARTMENT OF ECE, CMRCET Page 31


BLUETOOTH BASED HOME AUTOMATION USING ANDROID APPLICATION

inputs can also be used as digital pins: analog input 0 as digital pin 14 through analog input 5
as digital pin 19. Analog inputs 6 and 7 (present on the Mini and BT) cannot be used as
digital pins.

I2C: 4 (SDA) and 5 (SCL). Support I2C (TWI) communication using the Wire library
(documentation on the Wiring website).
Power Pins
VIN (sometimes labeled "9V"): The input voltage to the Arduino board when it's
using an external power source (as opposed to 5 volts from the USB connection or
other regulated power source). You can supply voltage through this pin, or, if
supplying voltage via the power jack, access it through this pin. Also note that the
Lily Pad has no VIN pin and accepts only a regulated input.
5V: The regulated power supply used to power the microcontroller and other
components on the board. This can come either from VIN via an on-board regulator,
or be supplied by USB or another regulated 5V supply.
3V3 (Diecimila-only) : A 3.3 volt supply generated by the on-board FTDI chip.
GND: Ground pins.
Other Pins
AREF: Reference voltage for the analog inputs. Used with analog Reference().
Reset: (Diecimila-only) Bring this line LOW to reset the microcontroller. Typically
used to add a reset button to shields which block the one on the board.

DEPARTMENT OF ECE, CMRCET Page 32


BLUETOOTH BASED HOME AUTOMATION USING ANDROID APPLICATION

B.2.Source Code

#include<LiquidCrystal.h>

LiquidCrystal lcd(8,9,10,11,12,13);

int light=2;
int fan=3;
char a;

void setup() {
// put your setup code here, to run once:
pinMode(light,OUTPUT);
pinMode(fan,OUTPUT);
digitalWrite(light,LOW);
digitalWrite(light,LOW);
Serial.begin(9600);
lcd.begin(16,2);
lcd.setCursor(0,0);
lcd.print("Bluetooth Based ");
lcd.setCursor(0,1);
lcd.print("Home Automation ");
delay(5000);
lcd.clear();
}
void loop() {
// put your main code here, to run repeatedly:

DEPARTMENT OF ECE, CMRCET Page 33


BLUETOOTH BASED HOME AUTOMATION USING ANDROID APPLICATION

lcd.clear();
lcd.setCursor(0,0);
lcd.print("Waiting for cmd:");
while(!Serial.available());
a=Serial.read();
if(a=='1')
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Light ON");
digitalWrite(light,HIGH);
delay(3000);
}
if(a=='2')
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Light OFF");
digitalWrite(light,LOW);
delay(3000);
}
if(a=='3')
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Fan on");
digitalWrite(fan,HIGH);
delay(3000);
}
if(a=='4')
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Fan OFF");
digitalWrite(fan,LOW);
delay(3000);
}
if(a=='5')
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print("All on");
digitalWrite(light,HIGH);
digitalWrite(fan,HIGH);

DEPARTMENT OF ECE, CMRCET Page 34


BLUETOOTH BASED HOME AUTOMATION USING ANDROID APPLICATION

delay(3000);
}
if(a=='6')
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print("All OFF");
digitalWrite(light,LOW);
digitalWrite(fan,LOW);
delay(3000); } }

DEPARTMENT OF ECE, CMRCET Page 35

You might also like