This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Pls Help me to send AT cmds to GSM modem frm 8051

I m able to send the msg from hyperterminal with following commands.

AT
AT+CMGF=1
AT+CMGS=+91..MOBILE NO
SMS TEXT
ctrl+z

and when i wrote the following c-code to send the same text msg using 8051 serial port i m not able to send the text. code is as below;

#include <REG52.H>
void Send(unsigned char);
void MSDelay (unsigned int);
unsigned int i;
unsigned char msg1[]="AT";
unsigned char msg2[]="AT+CMGF=1";
unsigned char msg3[]="AT+CMGS=+91..mobile no";
unsigned char msg4[]="TEMPERATURE";

void main()
{

//*************serial communication initialization**********// P1 = 0x00; //Set port 1 as output TMOD = 0x20; //timer 1,mode 2(auto-reload) TH1 = -3; //9600 baud rate SCON = 0x50; //8-bit,1 stop, REN enabled TR1 = 1; //start timer 1

for(i=0;msg1[i]!='\0';i++) Send(msg1[i]); Send(0x0D); Send(0x0A); MSDelay(100);

for(i=0;msg2[i]!='\0';i++) Send(msg2[i]); Send(0x0D); Send(0x0A); MSDelay(100);

for(i=0;msg3[i]!='\0';i++) Send(msg3[i]); Send(0x0D); Send(0x0A); MSDelay(100);

for(i=0;msg4[i]!='\0';i++) Send(msg4[i]); Send(0x1A); while(1);
}

void Send(unsigned char x)
{ SBUF = x; while (TI==0); TI=0;
} void MSDelay (unsigned int value)// Delay routine { unsigned int x,y; for (x=0;x<3500;x++) for (y=0;y<value;y++);

}

------------------------------------------------------
i Have my project submission in 5 days.. pls pls help me out!!!!! Thanks in adwance...

Parents
  • No, that is not "accounting" for the responses - that is simply ignoring them!

    You need to read the responses, and handle them appropriately.

    "Can i observe the response by any means?"

    It's your program that needs to read & interpret them.

    It is simply a matter of receiving serial data.

    "is there any specific time delay to be provided?"

    No, but it is wise to have a timeout so that your program doesn't get stuck indefinitely if the response is missed or corrupted, etc...

Reply
  • No, that is not "accounting" for the responses - that is simply ignoring them!

    You need to read the responses, and handle them appropriately.

    "Can i observe the response by any means?"

    It's your program that needs to read & interpret them.

    It is simply a matter of receiving serial data.

    "is there any specific time delay to be provided?"

    No, but it is wise to have a timeout so that your program doesn't get stuck indefinitely if the response is missed or corrupted, etc...

Children
No data