Rohi231
Member level 2
Hello everyone.
Currently i am working on a gsm home automation system. I have sent and received messages through hyper terminal while connecting to gsm. But when i connected gsm to microcontroller (P89v51rd2) its not working. I have checked by connecting micro controller to pc. Its working fine. Have connected
2 nd pin(gsm modem) of db 9 connector to 3 rd pin of (micro controller) db 9 connector.
3 rd pin(gsm modem) of db 9 connector to 2 nd pin of (micro controller) db 9 connector.
5 th pin(gsm modem) of db 9 connector to 5 th pin of (micro controller) db 9 connector.
My program:
Help me out:roll:
Currently i am working on a gsm home automation system. I have sent and received messages through hyper terminal while connecting to gsm. But when i connected gsm to microcontroller (P89v51rd2) its not working. I have checked by connecting micro controller to pc. Its working fine. Have connected
2 nd pin(gsm modem) of db 9 connector to 3 rd pin of (micro controller) db 9 connector.
3 rd pin(gsm modem) of db 9 connector to 2 nd pin of (micro controller) db 9 connector.
5 th pin(gsm modem) of db 9 connector to 5 th pin of (micro controller) db 9 connector.
My program:
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 #include<P89V51RX2.h> // include at89x51 . h #include<stdio.h>// include stdio . h #include<stdlib.h>// include stdlib . h unsigned char Command_AT[]=" AT\r\n"; unsigned char Command_save[]="AT&W\r\n"; //save settings// unsigned char Command_CMGF[]="AT+CMGF=1\r\n"; // AT+CMGF for selecting Text Mode unsigned char Command_CMGS[]="AT+CMGS =\"919743338587\"\r\n"; // recepient mobile number unsigned char msg02[]="Hello!"; void initialize_serialcommunication(void) { SCON = 0x50; TMOD = 0x20; TH1 =-3; TL1 = 0xFD; TR1 = 1; TI = 1; } void delay2(void) { unsigned int i; for(i=0;i<65000;i++); } void gsmcmdsend(unsigned char *cmd) { while(*cmd!='\0') { SBUF=*cmd; while(TI==0); TI=0; cmd++; } } void gsminit(void) { // AT COMMANDS delay2(); delay2(); delay2(); delay2(); delay2(); delay2(); delay2(); gsmcmdsend(Command_AT); delay2(); gsmcmdsend(Command_save); delay2(); gsmcmdsend(Command_CMGF); delay2(); gsmcmdsend(Command_CMGS); delay2(); gsmcmdsend(msg02); delay2(); SBUF = 0x1A; while(TI==0); TI = 0; } void main (void) { initialize_serialcommunication(); gsminit(); while (1); }
Help me out:roll:
Last edited by a moderator: