Microcontroller › 8051 › GSM based smart information system for lost cards › hiiiii…..i made a c code to
hiiiii…..
i made a c code to send a msg through gsm module. but i did not get desired result. plz check the code and help…
#include<reg51.h>
#define FREQ 12000000
#define baud 9600
#define spbrg_value (((FREQ/64)/baud)-1)
sbit gas=P2^0;
sbit pir=P2^1;
sbit fire=P2^2;
int i=0,j,k,temp;
unsigned char *sms_service=”AT+CSMS=1″;
unsigned char *sms_format=”AT+CMGF=1″;
unsigned char *sms_write=”AT+CMGS=”7520487033″”; // 10-Digit Mobile Number
unsigned char *sms=”gas leakage”;
unsigned char *smss=”moving body”;
unsigned char *smsss=”fire”;
unsigned char *sms_report=”SMS Sent…”;
unsigned char sms_terminate=0x1A;
unsigned char enter=0x0D;
void delay(unsigned int msec) // Function for delay
{
int i,j;
for(i=0;i<msec;i++)
for(j=0; j<1275; j++);
}
void init_serial() // Initialize serial port
{
TMOD=0x20; // Mode2
TH1=0xFD; //buad rate
SCON=0x50; // Serial mode=1 ,8-Bit data,1 Stop bit ,1 Start bit, Receiving on
TR1=1; // Start timer
}
void tx_data(unsigned char str) // Transmit data function
{
SBUF=str; //Store data in SBUF
while(TI==0); //Wait till data transmits
TI=0;
}
void gsm_cmd(unsigned char *string)
{
i=0;j=0;
while(string!=’