Vous êtes sur la page 1sur 15

Bluetooth Based Home Automation

Bluetooth based Home Automation


A bluetooth chip is designed to replace cables by taking the information normally carried by the cable and transmitting it at a special frequency to a receiver bluetooth chip, which will then give the information received to the computer, phone whatever. This Bluetooth wireless technology is set to revolutionize the way people perceive digital devices in homes and office environment. This technology is especially useful in home environment, where hardly any infrastructure exist to interconnect intelligent appliances. Bluetooth based home automation system provides a great advantage to switch on/off the devices from anywhere within the bluetooth range. So there is no need to go to the switch and start/stop the appliance. Only connect it with the bluetooth of your cell phone and sending the letters. If you press A then 1st appliance will turn ON then press B to OFF it. Similarly for the 2nd appliance press C to ON & press D to OFF and so on. The cell phone having the Android application platform is only used for building the connection. First of all download software TERMINAL which has capability to connect to the bluetooth module. Some persons who are unable to walk to switch board, also who are old persons need this type of project because they can switch on/off the load with cell phone without moving away from their place.

Block Diagram:
Fig1 shows the flow of design in the form of blocks. The Bluetooth signal from cell phone having Android application platform is received by the bluetooth module. The android application software TERMINAL has a keypad which shows the alphabets. These alphabets are used as input to operate the appliances. Bluetooth module transmits these signals which can be received by kick start board. The kick start board has microcontroller and 7805IC for +5V power supply assembled on it. Adaptor is used for providing +12V supply to kick start board & relay driver module. Relays are then connected to the appliances as switching device. According to the microcontroller programming the output goes to the input of relay driver module and LCD. The red indication of LED at relay driver section show on/off of a particular relay as four relays are connected to this section. The microcontroller also interfaced with LCD which displays the output of microcontroller that which relay is on/off.

Circuit Description of Kick Start Board:


Fig2 shows the circuit of kick start board. The 1st circuit is +5V power supply section. This circuit will provide a regulated voltage to microcontroller. The circuit comprises of mainly 7805 voltage regulator IC (IC4). +12V supply given as input to 7805IC through dc jack. The capacitor C10 must have high voltage rating to safely handle the input voltage feed to circuit. +5V output of 7805IC results the red LED to glow which refers as a Power ON Indication.

MAX232 IC (IC3) is used as logic convertor to make the serial communication signal; received through db9 connector; compatible with microcontroller. Its pin no 13 & 14 is connected to the pin 3 & 2 of db9 connector respectively to receive the signal. Similarly its pin no 11 & 12 are connected to 11 & 12 of microcontroller to transmit the converted signal. It requires 4 capacitors i.e. C4, C6, C7 & C8 of 10uf. The heart of the kick start board is microcontroller P89V51RD2. it is a 40 pin 8051-based microcontroller with 64K+8K kB Flash and 1024 bytes of data RAM32 I/O lines, 3 Timers/Counters, 9 Interrupts/4 priority levels, SPI, Dual Data Pointers, WDT, 5-channel PCA. 4 jumpers of 10 pins JP1 to JP4 are used to connect the ports of microcontroller and remaining two pins of jumpers are assigned as +5V and gnd. Resistor array is used at port 0. The reset circuit connected at pin9 and crystal oscillator at pin18 & 19. +12V supply is given to the Pushto-on switch JP7 to start the board.

Circuit description of Relay driver module:


Fig5 shows the circuit of relay driver module. It is build around the PNP transistors which works in the saturation mode. The input pins 4 through 1 are connected to the bases of the transistor T1 through T4, respectively. Input pin4 of JP1 goes high to drive transistor T1 into saturation and drives the relay1 and LED1 connected to it. Similarly pin3 through pin1 goes high to drive transistor T2 through T4 into saturation respectively and drive the connected relay and LED. Depending on the logic, the relay gets through transistors; the relay circuit becomes short or open to ON or OFF the connected load respectively. Diode D1 to D4 and resistor R10 to R13 maintains the LED from burning. Diode D5 to D8 blocks the back EMF from transistor if occurs and Resistors R2 to R5 limits the current to maintain the transistor from any damage. The supply of +12V for the circuit is provided by the kick start board.

Circuit description:
Fig8 shows the circuit diagram of Bluetooth controlled home automation system comprising Bluetooth module, Kick start board, LCD and Relays. Here only 1 appliance is connected to relay to show the connections. More than one appliance can be connected to it. Bluetooth module is used to connect the device with cell phone bluetooth, so whenever ground & +5V supply is given to this module; it starts and detect the available bluetooth device within 12 seconds maximum. The red LED blinks when it starts detecting the device. This bluetooth module receives the signal from the cell phone and then transmits them to microcontroller for further processing. The communication between bluetooth module and microcontroller is done through db9 connector cable. Bluetooth module and kick start board has db9 connector which acts as transmitter & receiver respectively.

The P89V51RD2 microcontroller also act as the heart of the system as it receives the signal, programmed it and then gives the output to Relay driver module to operate the relays for controlling the ON/OFF action of appliances. The kick start board output at port P2.0, P2.1, P2.2, P2.3 is connected to the input pins IN4, IN3, IN2, IN1 of relay driver module as Port2 of microcontroller is bidirectional port. Here it is used as output port for microcontroller. Adaptor provides the +12v supply to kick start board for 7805IC assembled on it and also to Relay driver module to drive relays. Input on Relay driver module also drives relay through transistor. The red LED indication on Relay driven board tells us that the operation of ON/OFF is done on the appliance which is connected to this relay. Now how to connect the appliance? Relay is used as switching device in the path of appliance to AC Mains. Rather than connecting an appliance directly to ac main power, connect its one terminal to relay and other one to supply. Similarly one end of relay to power supply. Thus relay is connected between the main supply and appliance. Switching action of relay is responsible for the required operation and appliance ON/OFF according to the instruction given by the cell phone bluetooth operator. Also an LCD is interfaced with microcontroller to display the output of microcontroller. For interfacing, port0 is used to give output to data pins of LCD i.e. pin7-14. Pin5 is grounded for write operation. Connect pin4 & pin6 to microcontroller port P3.4 & P3.6 respectively. +5V supply is given by the kick start board.

Construction:
The Actual-size, single-side PCB for the kick start board and relay driver module is shown in fig3 & fig6 respectively. Its component layout in fig4 & fig7 respectively. The wired connections for Bluetooth based Home Automation are shown in the fig7. Assemble the PCBs with various components along with the IC bases. Arrange all modules. Connect them as shown in fig7. Start bluetooth module and bluetooth of Cell phone. Connect it and test it by pressing the alphabets. The operation displays on the LCD and the appliance works according to the pressed alphabets.

Software:
The software is written in Embedded C language. Compile it to obtain hex code. Burn the generated hex code into the microcontroller. The software is well commented and easy to understand. PARTS LIST: Bluetooth Module 16x2 alphanumeric LCD Kick start Board Semiconductor:

IC1 IC4 IC3 D1 Capacitors: C1, C2 C3, C4, C6, C7, C8 C10 Resistors: R1 R10 Miscellaneous: Q1 X9 J1 RN2 JP1, JP3, JP5, JP6 JP7 H1, H2, H3, H4 3mm LED Vertical jumper 40-pin IC Base 14-pin IC Base 3-pin IC Base Tactile Switch Relay driver Module:

- P89V51RD2 microcontroller - 7805, 5V regulator - MAX232N - 1N4007 rectifier Diode - 33pf ceramic - 10uf, 25V electrolytic - 100uf, 25V electrolytic - 10-kilo-ohm - 220-ohm - KDS110592 Crystal oscillator - db9 Connector - DC Jack - 8-pin Resistor Array - pin heads - Push-to-on Switch - Mount-pad

Semiconductor: D1, D2, D3, D4, D5, D6, D7, D8 T1, T2, T3, T4 Resistors: R10, R11, R12, R13, R41 R2, R3, R4, R5 Miscellaneous: X3, X4, X5, X6 ` Relay1, Relay2, Relay3, Relay4 H3, H4 4 SMD resistors LED 3mm REDs Pin heads

- 1N4007 Diode - BC547 transistors - 1-kilo-ohm - 10-kilo-ohm - 3 pin terminal block - 12V, Q3F-1Z relay - mount-pad

Cell phone Bluetooth Tx Adaptor (12V Supply)

Rx Bluetooth module Tx

Kick start board (Assembled microcontroller & other components)

LCD

Relay Driver module

Rx

12V supply

Relays
Relay 1 Home appliances Relay 2 Relay 3 Relay 4
Fig1: Block diagram

Fig2: Circuit diagram of Kick start board

Fig3: Actual-size, single-side PCB for Kick start board

Fig4: Component layout for Kick start board

Fig5: Circuit diagram of Relay driver module

Fig6: Actual-size, single-side PCB for Relay driver module

Fig7: Component layout for Relay driver module

Fig8: Circuit diagram of Bluetooth based Home Automation

//Final Bluetooth Based Home Automation code


#include<reg51.h> #include<stdio.h> //Header file for 8051 registor //Header file for LCD

//Data and Command port Selection //LCD #define LCDdata P0 sbit LCDrs = P3^4; sbit LCDen = P3^6; // Motor sbit LM1P=P2^0; sbit LM1N=P2^1; sbit RM1P=P2^2; sbit RM1N=P2^3; //Declaring LCDdata //The Register select Pin //The Enable Pin //left motor +ve //left motor -ve //Right motor +ve //Right motor ve

/* Prototype: void MSdelay(unsigned int); Return Type: void Arguments: unsigned int Description: Generates time delay in milliseconds */ void delay(unsigned int rtime) { unsigned int r,s; for(r=0;r<rtime;r++) for(s=0;s<1275;s++); }

/* Prototype: void lcdcmd (unsigned char); Return Type: void Arguments: unsigned char Description: Issue commands to LCD */

void lcdcmd(unsigned char DATA) { LCDrs=0; LCDen=1; //Strobe the enable pin LCDdata = DATA; //Put the value on the pins LCDrs=0; LCDen=0; }

/* Prototype: void initialize (void); Return Type: void Arguments: None Description: Initialize LCD */ void initialize(void) { lcdcmd(0x30); delay(1); lcdcmd(0x38); delay(1); lcdcmd(0x0c); delay(1); lcdcmd(0x01); delay(1); lcdcmd(0x06); delay(1); }

//1 line and 5x7 matrix

//2 line and 5x7 matrix

//Display on, cursor off //Clear display Screen

//shift cursor to right

/* Prototype: void lcddat (unsigned int) Return Type: void Arguments: unsigned int Description: Display data on LCD */

void lcddat(unsigned int DATA) { LCDrs = 1; // for data LCDen = 1; //Strobe the enable pin LCDdata = DATA; //Put the value on the pins LCDrs = 1; LCDen = 0; } /* Prototype: void display_lcd (unsigned char,unsigned char) Return Type: void Arguments: unsigned char & unsigned char* Description: Diplay the argument character string on given location using lcddat(unsigned int) */ void display_lcd(unsigned char location, unsigned char *d) { lcdcmd(0x80 | location); delay(1); //10mS delay generation while(*d) { lcddat(*d++); delay(1); } } int serial_rec(void) { int AA; while(RI==0); AA=SBUF; RI=0; return AA; } void main() { char rec; P2=0x00; P1=0x00

//10mS delay generation

initialize (); TMOD=0x20; TH1=0xFD; SCON=0X50; TR1=1; display_lcd(0x00, "Bluetooth Based"); display_lcd(0x40, "Home Automation"); delay(200); while(1) { rec=serial_rec(); if(rec=='a') { display_lcd(0x00, " 1st Relay "); display_lcd(0x40, " on "); LM1P=1; LM1N=0; RM1P=0; RM1N=0; } // Light on

if(rec=='b') { display_lcd(0x00," 1st Relay "); display_lcd(0x40," off "); LM1P=0; LM1N=0; RM1P=0; RM1N=0; } // Light off

if(rec=='c') { display_lcd(0x00," 2nd Relay "); display_lcd(0x40," on "); LM1P=0; LM1N=1; RM1P=0; RM1N=0; }

// Fan on

if(rec=='d') { display_lcd(0x00," 2nd Relay "); display_lcd(0x40," off "); LM1P=0; LM1N=0; RM1P=0; RM1N=0; }

// Fan off

if(rec=='e') { display_lcd(0x00," 3rd Relay "); display_lcd(0x40," on "); LM1N=0; LM1P=0; RM1P=1; RM1N=0; }

// Computer on

if(rec=='f') { display_lcd(0x00," 3rd Relay "); display_lcd(0x40," off "); LM1P=0; LM1N=0; RM1P=0; RM1N=0; }

// Computer off

if(rec=='g') { display_lcd(0x00, " 4th Relay "); display_lcd(0x40, " on "); LM1P=0; LM1N=0; RM1P=0; RM1N=1; }

// A.C. ON

if(rec=='h') { display_lcd(0x00, " 4th Relay "); display_lcd(0x40, " off "); LM1P=0; LM1N=0; RM1P=0; RM1N=0; }

//A.C. Off

if(rec=='i') { display_lcd(0x00," All Relay "); display_lcd(0x40," on "); LM1P=1; LM1N=1; RM1P=1; RM1N=1; } // // // // Light on Fan on Computer on A.C. ON

//

All Relay on

if(rec=='j') { display_lcd(0x00," All Relay "); display_lcd(0x40," off "); LM1P=0; LM1N=0; RM1P=0; RM1N=0; } } } // Light off // Fan off // Computer off //A.C.ON

//

All relay off