I need some help in writing a code which will enable the 8051 to send a text sms using a GSM modem TR800 to any number. I have no clue as where to start. I have tried the following:

#include <reg51.h>
void SerTx(unsigned char);
void main(void){
int i =0;
TMOD=0x20; //use Timer 1, mode 2
TH1=0xFD; //9600 baud rate
TR1=1; //start timer
while (i<2) {
void SerTx(unsigned char x){
SBUF=x; //place value in buffer
while (TI==0); //wait until transmitted

Any help will be appreciated. Thanks!


Your code is trying to send an AT command, followed by a carriage return (CR). But you have coded the escape sequence for CR incorrectly. You should send 'A', 'T', and '\r'. The C compiler must see the backslash and the "r" side-by-side to make the conversion to CR. Your code sends literally "AT\r" to the module, which is incorrect.

Once that's working right, you'll need to write some code to accept the reply from the GSM module.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.