The objective of this project is to implement a low cost and reliable home automation system using an 8051 microcontroller which turns on and off the home appliances by sending ASCII value through a mobile app.
COMPONENTS REQUIRED :
Hardware Requirements:
8051 Microcontroller (AT89C51) To perform the objective
16 × 2 STN LCD Display To display that load is on or off
10KΩ Potentiometer To adjust the brightness of LCD
Bluetooth Module (HC – 05) To receive ASCII value
2 – 5V Relay Module To run loads on A.C. supply
Loads Like Light Bulb, Fan, etc
Power Supply 5v, 9v, 12v D.C
Voltage regulator IC 7805 To get constant 5v output
10µF Electrolytic Capacitor
2 x 33pF Ceramic Disc Capacitors
11.0592 MHz Quartz Crystal
Push Button For reset
1KΩ x 8 Resistor Pack To pull up port 0
Connecting wire
Software Requirements:
Keil µVision IDE For writing code
Proteus For Circuit Diagram and Simulation
BlueTooth Serial Controller APK (Playstore) To send ASCII value
Circuit :
FLOWCHART:
ORG 00H
RS EQU P2.5 ; assign pin p2.5 as RS of display
RW EQU P2.6 ; assign pin p2.6 as RW of display
E EQU P2.7 ; assign pin p2.5 as E of display
MOV TMOD,#20h ; timer 1 mode 2
MOV SCON,#50h ; mode 1 (9 bit UART with variable baud rate)
MOV TH1,#0FDH ;set baud rate as 9600
SETB TR1
Clr P2.3 ; clear pin p2.3 as (used as output 1)
Clr P2.4 ; clear pin p2.4 as output 2(used as output 2)
clr E ;LCD INITIALIZATION
again:
CLR RI ;clear Recieve pin
HERE4:
JNB RI, HERE4 ;check if RI pin is 1 or 0(if 0 then again check RI pin else goto next instruction)
MOV A,sbuf ;move contents of sbuf to accumulator
CJNE A,#'A' , checknext ; check if the recieved Ascii value is equal to Ascii value of A
SETB P2.3 ;turn led1 on
ACALL display ; to display 'light on'
sjmp again ; goto label again to recieve another Ascii value
checknext:
CJNE A,#'a' , checknext1 ;check if the recieved Ascii value is equal to Ascii value of a
CLR P2.3 ;turn led1 of
ACALL displayoff ; to display 'Light of
SJMP again ; goto label again to recieve another Ascii value
checknext1:
CJNE A,#'B' , checknext2 ;check if the recieved Ascii value is equal to Ascii value of B
SETB P2.4 ;turn led2 on
ACALL display1 ; to display 'Fan on'
SJMP again
checknext2:
CJNE A,#'b' , again
clr P2.4 ;turn led2 of
ACALL displayoff1 ; to display 'Fan on'
SJMP again
display:
MOV P0, #38H ;2 lines and 5x7 matrix
ACALL send_command
MOV P0, #0EH ;display on ,cursor blink
ACALL send_command
MOV P0, #80H ; FORCE CURSOR TO 1ST LINE
ACALL send_command ; call send_command function
MOV P0, #'L' ;move Ascii value of L to port 0
ACALL send_data
MOV P0, #'I' ;move Ascii value of I to port 0
ACALL send_data
MOV P0, #'G' ;move Ascii value of G to port 0
ACALL send_data
MOV P0, #'H' ;move Ascii value of H to port 0
ACALL send_data
MOV P0, #'T' ;move Ascii value of T to port 0
ACALL send_data
MOV P0, #14H ;Shift cursor position to right
ACALL send_command
MOV P0, #'O' ;move Ascii value of O to port 0
ACALL send_data
MOV P0, #'N' ;move Ascii value of N to port 0
ACALL send_data
ret
displayoff:
MOV P0, #80H ; FORCE CURSOR TO 1ST LINE
ACALL send_command
MOV P0, #'L' ;move Ascii value of L to port 0
ACALL send_data
MOV P0, #'I' ;move Ascii value of I to port 0
ACALL send_data
MOV P0, #'G' ;move Ascii value of G to port 0
ACALL send_data
MOV P0, #'H' ;move Ascii value of H to port 0
ACALL send_data
MOV P0, #'T' ;move Ascii value of T to port 0
ACALL send_data
MOV P0, #14H ;Shift cursor position to right
ACALL send_command
MOV P0, #'O' ;move Ascii value of O to port 0
ACALL send_data
MOV P0, #'F' ; move Ascii value of N to port 0
ACALL send_data
ret
display1:
MOV P0, #38H ;2 lines and 5x7 matrix
ACALL send_command
MOV P0, #0EH ;display on cursor blink
ACALL send_command
MOV P0, #0C0H ;Force cursor to beginning of 2nd line
ACALL send_command
MOV P0, #'F'
ACALL send_data
MOV P0, #'A'
ACALL send_data
MOV P0, #'N'
ACALL send_data
MOV P0, #14H
ACALL send_command
MOV P0, #'O'
ACALL send_data
MOV P0, #'N'
ACALL send_data
ret
displayoff1:
MOV P0, #0c0H ; Force cursor to beginning of 2nd line
ACALL send_command
MOV P0, #'F'
ACALL send_data
MOV P0, #'A'
ACALL send_data
MOV P0, #'N'
ACALL send_data
MOV P0, #14H
ACALL send_command
MOV P0, #'O'
ACALL send_data
MOV P0, #'F'
ACALL send_data
ret
send_command :
CLR RW ;clear Read/Write pin (RW=0 Write mode,RW=1 Read mode)
CLR RS ;clears Register Select Pin (RS=0 Command mode,RS=1 Data mode)
SETB E ;set enable pin
ACALL DELAY ; call delay function
CLR E ;clear enable pin to stop recieving data
RET
send_data :
CLR RW
SETB RS
SETB E
ACALL DELAY
CLR E
RET
;to create delay
DELAY :
MOV R0, #5
Here1 :
MOV R1, #255
Here :
DJNZ R1, here
DJNZ R0, here1
ret
;end of delay
END ;end of program
Mobile App Configured with corresponding ASCII Value for turning on and off the home appliances:
2) After that when I press ‘a’ controller compare received value with ‘A’ but it doesn’t match so it jump to label checknext which compares received value with Ascii value of ‘a’ and if it’s matches then pin p2.3 is cleared and led1 is turned off and ‘LIGHT OF’ is displayed.
3 ) After that when I press ‘B’ controller compare received value with ‘A’ but it doesn’t match so it jump to label checknext which compares received value with Ascii value of ‘a’ , but it doesn’t match so it jump to label checknext1 which compares received value with Ascii value of ‘B’ and it matches so pin p2.4 is set and led2 is turned on and ‘FAN ON’ is displayed.
4) After this when we press ‘b’ controller compare received value with ‘A’ but it doesn’t match so it jump to label checknext which compares received value with Ascii value of ‘a’ , but it doesn’t match so it jump to label checknext1 which compares received value with Ascii value of ‘B’, but again it doesn’t match so it jump to label checknext2 which compares received value with Ascii value of ‘b’ so pin p2.4 is cleared and led2 is turned of and ‘FAN OF’ is displayed.
Simulation:
Hardware Implementation :
Display not working due to wrong assignment of pins in program
Display worked after correction