0% found this document useful (0 votes)
25 views

Appendices: Sms Based Home Automation

1. The document describes a program for SMS based home automation using an Arduino and GSM module. 2. The program initializes the GSM modem by sending AT commands and sets the message format. 3. It then deletes any existing SMS from location 01, waits for a new SMS, reads the new SMS from location 01 and displays it on an LCD.

Uploaded by

arunkv2020
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views

Appendices: Sms Based Home Automation

1. The document describes a program for SMS based home automation using an Arduino and GSM module. 2. The program initializes the GSM modem by sending AT commands and sets the message format. 3. It then deletes any existing SMS from location 01, waits for a new SMS, reads the new SMS from location 01 and displays it on an LCD.

Uploaded by

arunkv2020
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 12

SMS BASED HOME AUTOMATION

APPENDICES

Dept. of ECE 25

MBITS

APPENDIX -2 PROGRAM
; PROGRAM FOR GSM BASED AUTOMATION LCD EQU P0 RS EQU P1.1 E EQU P1.0 DEVICE_1 DEVICE_2 MSG_LOC EQU P2.1 EQU P2.7 EQU 40H

ORG 00H SJMP MAIN ; =================================WELCOME ON LCD_START HERE=========================================== ORG 80H MAIN: MOV DPTR,#LCD_CMND recmnd: ACALL take ACALL comwrt
CJNE A,#00H,recmnd MOV DPTR,#WELCOME ACALL take CJNE A,#00H,LOOOP SJMP MAIN1

REDATA:

LOOOP:

ACALL datawrt CJNE A,#00H,REDATA ; ===================================WELCOME ON LCD_END HERE============================================

; ============================WAIT FOR CALL READY ON LCD_START HERE===================================== MAIN1: MOV SCON,#50H MOV TMOD,#20H MOV TH1,#0FDH SETB TR1 CHECK_RI:

rxng:

MOV R0,#51 MOV R1,#40H JNB RI,rxng MOV A,SBUF CLR RI MOV @R1,A INC R1 DJNZ R0,rxng CLR P2.0 MOV A,#01H ACALL COMWRT MOV A,69H ACALL DATAWRT MOV A,6AH ACALL DATAWRT MOV A,6BH ACALL DATAWRT MOV A,6CH ACALL DATAWRT MOV A,6DH ACALL DATAWRT MOV A,6EH ACALL DATAWRT MOV A,6FH ACALL DATAWRT MOV A,70H ACALL DATAWRT MOV A,71H ACALL DATAWRT MOV A,72H ACALL DATAWRT ;FOR CHECK PROGRAM IN PROTEUS

;=========================WAIT FOR CALL READY ON LCD_END HERE========================================= ACALL LDELAY ;================================INITIALIZE GSM MODEM================================================= MOV DPTR,#AT_CMD ACALL TAKE CJNE A,00H,TRANSMIT CLR TI SJMP COMMAND1 CLR TI MOV SBUF,A ACALL SDELAY NB TI,WAIT

NEXT:

TRANSMIT:

WAIT:

CLR TI SJMP NEXT ;========================================================================== ===== ;========================================================================== ===== COMMAND1: ACALL LDELAY MOV DPTR,#AT_CMGF ACALL TAKE CJNE A,00H,TRANSMIT1 CLR TI SJMP DELETE_SMS_01 CLR TI MOV SBUF,A JNB TI,WAIT1 CLR TI SJMP NEXT1

NEXT1:

TRANSMIT1:

WAIT1:

;=========================INITIALIZE GSM MODEM ENDS HERE============================================== ;=======================DELETE SMS FROM 01 LOCATION_START HERE======================================== DELETE_SMS_01: ACALL LDELAY MOV DPTR,#COMND_DELETE_SMS ACALL TAKE CJNE A,00H,TRANSMIT2 CLR TI SJMP WAIT_NEXT_SMS CLR TI MOV SBUF,A JNB TI,WAIT2 CLR TI SJMP NEXT2

NEXT2:

TRANSMIT2:

WAIT2:

;=======================DELETE SMS FROM 01 LOCATION_END HERE==========================================

;============================WAIT FOR NEW SMS_START HERE============================================== WAIT_NEXT_SMS:

MOV R0,#15 MOV R1,#40H rxng2: JNB RI,rxng2 MOV A,SBUF CLR RI MOV @R1,A INC R1 DJNZ R0,rxng2 MOV A,#01H ACALL COMWRT MOV A,40H ACALL DATAWRT MOV A,41H ACALL DATAWRT MOV A,42H ACALL DATAWRT MOV A,43H ACALL DATAWRT MOV A,44H ACALL DATAWRT MOV A,45H ACALL DATAWRT MOV A,46H ACALL DATAWRT MOV A,47H ACALL DATAWRT MOV A,48H ACALL DATAWRT MOV A,49H ACALL DATAWRT MOV A,4AH ACALL DATAWRT MOV A,4BH ACALL DATAWRT MOV A,4CH ACALL DATAWRT

MOV A,4DH ACALL DATAWRT MOV A,4EH ACALL DATAWRT MOV A,4FH ACALL DATAWRT MOV A,#0C0H ACALL COMWRT MOV A,50H ACALL DATAWRT MOV A,51H ACALL DATAWRT MOV A,52H ACALL DATAWRT MOV A,53H ACALL DATAWRT MOV A,54H ACALL DATAWRT MOV A,55H ACALL DATAWRT MOV A,56H ACALL DATAWRT MOV A,57H ACALL DATAWRT MOV A,58H ACALL DATAWRT MOV A,59H ACALL DATAWRT MOV A,5AH ACALL DATAWRT MOV A,5BH ACALL DATAWRT MOV A,5CH ACALL DATAWRT MOV A,5DH ACALL DATAWRT MOV A,5EH ACALL DATAWRT MOV A,5FH ACALL DATAWRT ACALL LDELAY ACALL LDELAY

;============================WAIT FOR NEW SMS_END HERE===============================================

;==================COMMAND FOR READ SMS FROM 01 LOCATION_START HERE=================================== READ_SMS_01: ACALL LDELAY MOV DPTR,#READ_SMS_COMND ACALL TAKE CJNE A,00H,TRANSMIT3 CLR TI SJMP STORE_SMS CLR TI MOV SBUF,A JNB TI,WAIT3 CLR TI SJMP NEXT3

NEXT3:

TRANSMIT3:

WAIT3:

;==================COMMAND FOR READ SMS FROM 01 LOCATION_END HERE=====================================

STORE_SMS: MOV R0,#64 MOV R1,#40H rxng1: JNB RI,rxng1 MOV A,SBUF CLR RI ; CJNE A,'*',rxng1 MOV @R1,A INC R1 DJNZ R0,rxng1

CLR P3.0 MOV A,#01H

;FOR CHECK PROGRAM IN PROTEUS

ACALL COMWRT MOV A,40H ACALL DATAWRT MOV A,41H ACALL DATAWRT MOV A,42H ACALL DATAWRT MOV A,43H ACALL DATAWRT MOV A,44H ACALL DATAWRT MOV A,45H ACALL DATAWRT MOV A,46H ACALL DATAWRT MOV A,47H ACALL DATAWRT MOV A,48H ACALL DATAWRT MOV A,49H ACALL DATAWRT MOV A,4AH ACALL DATAWRT MOV A,4BH ACALL DATAWRT MOV A,4CH ACALL DATAWRT MOV A,4DH ACALL DATAWRT MOV A,4EH ACALL DATAWRT MOV A,4FH ACALL DATAWRT MOV A,#0C0H ACALL COMWRT MOV A,50H ACALL DATAWRT MOV A,51H ACALL DATAWRT MOV A,52H ACALL DATAWRT MOV A,53H ACALL DATAWRT MOV A,54H ACALL DATAWRT

MOV A,55H ACALL DATAWRT MOV A,56H ACALL DATAWRT MOV A,57H ACALL DATAWRT MOV A,58H ACALL DATAWRT MOV A,59H ACALL DATAWRT MOV A,5AH ACALL DATAWRT MOV A,5BH ACALL DATAWRT MOV A,5CH ACALL DATAWRT MOV A,5DH ACALL DATAWRT MOV A,5EH ACALL DATAWRT MOV A,5FH ACALL DATAWRT ACALL LDELAY ACALL LDELAY

MOV A,#01H ACALL COMWRT MOV A,60H ACALL DATAWRT MOV A,61H ACALL DATAWRT MOV A,62H ACALL DATAWRT MOV A,63H ACALL DATAWRT MOV A,64H ACALL DATAWRT MOV A,65H ACALL DATAWRT MOV A,66H ACALL DATAWRT MOV A,67H ACALL DATAWRT MOV A,68H

ACALL DATAWRT MOV A,69H ACALL DATAWRT MOV A,6AH ACALL DATAWRT MOV A,6BH ACALL DATAWRT MOV A,6CH ACALL DATAWRT MOV A,6DH ACALL DATAWRT MOV A,6EH ACALL DATAWRT MOV A,6FH ACALL DATAWRT MOV A,#0C0H ACALL COMWRT MOV A,70H ACALL DATAWRT MOV A,71H ACALL DATAWRT MOV A,72H ACALL DATAWRT MOV A,73H ACALL DATAWRT MOV A,74H ACALL DATAWRT MOV A,75H ACALL DATAWRT MOV A,76H ACALL DATAWRT MOV A,77H ACALL DATAWRT MOV A,78H ACALL DATAWRT MOV A,79H ACALL DATAWRT MOV A,7AH ACALL DATAWRT MOV A,7BH ACALL DATAWRT MOV A,7CH ACALL DATAWRT MOV A,7DH ACALL DATAWRT

MOV A,7EH ACALL DATAWRT MOV A,7FH ACALL DATAWRT ACALL LDELAY ACALL LDELAY ACALL LDELAY LJMP READ_SMS_01

;==============================COMMON LOOP START HERE================================================= TAKE: CLR A MOVC A,@A+DPTR INC DPTR RET ;-----------------------command SR---------------------comwrt: MOV LCD,A CLR RS SETB E ACALL sdelay CLR E ACALL sdelay RET ;-----------------------data SR-----------------------datawrt:MOV LCD,A SETB RS SETB E ACALL sdelay CLR E ACALL sdelay RET ;----------------------small delay--------------------sdelay: MOV R3,#255 sh1: MOV R4,#50 sh2: DJNZ R4,sh2 DJNZ R3,sh1 RET ;----------------------long delay---------------------ldelay: MOV R3,#255 lh3: MOV R4,#255 lh2: MOV R5,#8 lh1: DJNZ R5,lh1

DJNZ R4,lh2 DJNZ R3,lh3 RET

LCD_CMND: WELCOME: AT_CMD AT_CMGF COMND_DELETE_SMS READ_SMS_COMND

DB 38H,0CH,01H,80H,00H DB " TURN ON GSM",00H :DB "AT",0DH,0AH,00H :DB "AT+CMGF=1",0DH,0AH,00H :DB "AT+CMGD=01",0DH,0AH,00H :DB "AT+CMGR=01",0DH,0AH,00H

END

You might also like