Microcontroller › 8051 › Help about GSM interfacing with 8051
- This topic has 1 reply, 2 voices, and was last updated 8 years, 5 months ago by Anonymous.
-
AuthorPosts
-
June 23, 2016 at 5:36 pm #4494juliusParticipant
I was interfacing GSM modem with AT89S52 microcontroller to send SMS to a mobile number. I tried sending the sms using hyperterminal from PC and the SMS get sent properly. But if i send the SMS using microcontroller and GSM, then the SMS does not get sent. Please help me in fixing the issue. I use DB9 serial cable to connect at89s52 and GSM modem.
Below is the embedded c code:
#include<reg51.h>sbit swtch=P0^0;sbit led=P0^1;unsigned char test[]="AT";unsigned char textmode[]="AT+CMGF=1";unsigned char mobno[]="AT+CMGS="8308941641"";unsigned char message[]="$GPRMC,0600100.000,A,15234.678,N,1324.987,E";void delay(unsigned int x){unsigned int i;for(i=0;i<x;i++){;}}void uart_init() // INITIALIZE SERIAL PORT{TMOD=0x20; // Timer 1 IN MODE 2-AUTO RELOAD TO GENERATE BAUD RATETH1=0xFD; // LOAD BAUDRATE TO TIMER REGISTERSCON=0x50; // SERIAL MODE 1, 8-DATA BIT 1-START BIT, 1-STOP BIT, REN ENABLEDTR1=1; // START TIMERTI=1;}void tx_data(unsigned char serialdata){while(TI!=1){;}TI=0;SBUF = serialdata; // LOAD DATA TO SERIAL BUFFER REGISTER}void tx_string(unsigned char a[],unsigned int len){unsigned int z;for(z=0;z<len;z++){tx_data(a[z]);}}void main(void){swtch=1;led=0;uart_init();while(1){s:if(swtch!=0){goto s;}else{tx_string(test,2);tx_data(0x0D);tx_data(0x0A);//delay(50000);tx_string(textmode,6);tx_data(0x0D);tx_data(0x0A);//delay(50000);tx_string(mobno,20);tx_data(0x0D);tx_data(0x0A);//delay(50000);tx_string(message,43);tx_data(0x1A);led=1;delay(200000);}}}June 25, 2016 at 5:16 pm #13992AnonymousGuestRefering to the command 4.2.5:AT+CMGS from SIM900 AT command set I hope:
In the else loop,after transmitting the mobile number it is sufficient to send 0X0D.Not necessary to send 0X0A.
And also try without using ’’ before and after the number.
I have used the following code pattern for entering the mobile number:
AT+CMGS=”1234567890”
After sending this line just send ‘r’ i.e..,0X0D.But 0X0A is not necessary.
A delay of 300ms worked for me to transmit the text after transmitting number.
And also try without using ’’ before and after the number.
The below code pattern worked for may work for you:
char mobno[]="AT+CMGS="8308941641"";
tx_data(0x0D);
delay(50000); //uncomment this delay to about 300ms. it is necessary while interfacing with uC
tx_string(message,43);
tx_data(0x1A);
The rest of the code is same.
-
AuthorPosts
- You must be logged in to reply to this topic.