uday mehta
Advanced Member level 4
- Joined
- Dec 30, 2011
- Messages
- 104
- Helped
- 6
- Reputation
- 12
- Reaction score
- 6
- Trophy points
- 1,298
- Activity points
- 1,979
I have write a code for sending message form gsm300 using 8051.
but it is not working.
plz tell me where is the problem?
in the program or in ckt?
but it is not working.
plz tell me where is the problem?
in the program or in ckt?
Code:
#include<reg51.h>
#include<string.h>
#include<absacc.h>
#include<stdlib.h>
#include<ctype.h>
void delay(unsigned int i);
void tx0(unsigned char);
void SMSString(unsigned char*text) ;
void init();
void send_a_message();
//void call();
// Moblie no.of Owner
unsigned char code Mob_no[]= "+917792849639";
void delay(unsigned int i)
{
unsigned int k, l;
for(k=0;k<i;k++)
for(l=0;l<1000;l++);
}
void init()
{
P0=0x00;
TL1=0XFD; //9600 @ 11.0592
TH1=0xFD;
TMOD=0x20;
SCON=0x50;
TR1=1;
}
void SMSString(unsigned char* text) //function to send SMS using GSM modem
{
while (*text)
{
tx0(*text++);
}
}
void tx0(unsigned char x) //send data to serial port 0
{
EA=0;
SBUF=x;
while(TI==0);
TI=0;
EA=1;
}
void send_a_message()
{
SMSString( "AT+CMGF=1\r"); // select text mode for sms
delay(50);
SMSString("AT+CMGS=\"");
SMSString(Mob_no);
SMSString("\"\r");
delay(1);
SMSString("somebody entered incorrect password");
delay(100);
tx0(0x1A); // Ctrl+z
delay(10);
}
/*void call()
{
SMSString("ATD+917792849639;\r");
delay(1);
delay(10);
}
*/
void main ()
{
init();
SMSString("AT\r"); // AT commands to initialize gsm modem
delay(50);
SMSString( "ATe0\r"); // turn off echo
delay(50);
SMSString( "AT&W\r"); // save settings
delay(50);
send_a_message();
delay(200);
//call();
while(1);
}