Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

SIM300 interfacing with AT89S52 problem urgent help

Status
Not open for further replies.

indrananu

Newbie level 5
Newbie level 5
Joined
Apr 9, 2013
Messages
10
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Visit site
Activity points
1,433
I have written the following code for a SIM300 interfaced with AT8952 but I'm unable to get the sms to my mobile what might be my error in the program. I don't want any reply from the sim300 like 'OK' so waht changes do I need to do?
I,m using keil ang proteus.

void delay(void)

{
unsigned int a;
for(a=0;a<25000;a++);
}


// Serial Communication

void initialize();
void sendsms1();
void sendsms2();
unsigned char command_AT[] = "AT\r";
unsigned char command_CMGF[] = "AT+CMGF=1\r";
unsigned char command_CMGS[] = "AT+CMGS=+918270895828\r";
unsigned char message1[] = "INTRUDER ALERT AT FACILITY";
unsigned char message2[] = "DOOR UNLOCKED AT FACILITY";
unsigned char CTRLZ = 0x1A;


void initialize()
{
SCON = 0x50; /*SCON: mode 1, 8-bit UART, enable receive */
TMOD = 0x20; /*TMOD: timer 1, mode 2, 8-bit */
TH1 = 0xFD; /*TH1: for 9600 baud */
TR1 = 1; /*TR1: timer 1 run */
TL1 = 0xFD;
TI = 1;
}

void sendsms1()
{
delay();
puts(command_CMGS);
delay();
puts(message1);
delay();
while(!TI);TI=0;SBUF=0x1A;
}

void sendsms2()
{
delay();
puts(command_CMGS);
delay();
puts(message1);
delay();
while(!TI);TI=0;SBUF=0x1A;
}


// Motor function to run it
sbit L293D_A = P2^0; //Positive of motor
sbit L293D_B = P2^1; //Negative of motor
sbit L293D_E = P2^2; //Enable of L293D
int i; // Counter for delay

void motor(void)
{
// Run forward
L293D_A = 1; //Make positive of motor 1
L293D_B = 0; //Make negative of motor 0
L293D_E = 1; //Enable L293D

// Delay for 3.5 sec
for(i=0;i<14;i++)
delayms(250);

// Stop
L293D_A = 0; //Make positive of motor 0
L293D_B = 0; //Make negative of motor 0
L293D_E = 0; //Disable L293D

// Delay for 2 sec
for(i=0;i<8;i++)
delayms(250);

// Run reverse
L293D_A = 0; //Make positive of motor 0
L293D_B = 1; //Make negative of motor 1
L293D_E = 1; //Enable L293D

// Delay for 3.5 sec
for(i=0;i<14;i++)
delayms(250);

// Stop
L293D_A = 0; //Make positive of motor 0
L293D_B = 0; //Make negative of motor 0
L293D_E = 0; //Disable L293D
}

// main function with gsm code and motor control function & LCD message

sbit LCKPIN = P0^0; // Lock pin
sbit IRSNS = P0^1; // IR sensor
sbit ALARM = P1^6; // Alarm pin
sbit MOTORSWT = P2^3; // Motor switch
int ulk;
unsigned char str[5];
void main()
{
ulk = 0; // First time Unlock check
ALARM = 0; // inicially alarm is off
initialize(); // UART initialise
lcd_init(); // LCD initialise
lcd_cmd(LCD_CLS);
lcd_str("WELCOME");
delay();
puts(command_AT);
delay();
puts(command_CMGF);
//Deay 2 sec
for(i=0;i<8;i++)
delayms(250);
lcd_cmd(LCD_CLS);
lcd_str("Security System");
lcd_cmd(0xC0);
lcd_str(" Active");
while(1)
{
if(LCKPIN == 1 && ulk == 1)
{
lcd_cmd(LCD_CLS);
lcd_str("Security System");
lcd_cmd(0xC0);
lcd_str(" Active");
}

if( LCKPIN == 1 ) // Locked Status LCKPIN = 1
{
ulk = 0;
if( IRSNS == 1 )
{
sendsms1();
lcd_cmd(LCD_CLS);
lcd_str(" Intruder Alert");
lcd_cmd(0xC0);
lcd_str(" Message Sent");

// Delay for 2 sec
for(i=0;i<8;i++)
delayms(250);

lcd_cmd(LCD_CLS);
lcd_str(" ALARM ON");
lcd_cmd(0xC0);
lcd_str(" INTRUDER ALERT");

while(LCKPIN != 0)
{
ALARM = 1;
}
}
}
else
{
if( ulk == 0 )
{
sendsms2();
lcd_cmd(LCD_CLS);
lcd_str("Door Unlocked");
lcd_cmd(0xC0);
lcd_str("Message Sent");
ulk = 1;

// Delay for 3 sec
for(i=0;i<12;i++)
delayms(250);

lcd_cmd(LCD_CLS);
lcd_str("Security System");
lcd_cmd(0xC0);
lcd_str(" Deactive");
}
if(MOTORSWT == 0)
motor();
}
}
}
 

Attachments

  • ckt diagrm.bmp
    88.9 KB · Views: 86

i think there is a command to turn off the reply given by gsm. Plz chk the datasheet. Something ATE0.
 

I haven't tried it yet. Try it both ways.If working tell me too.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top