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.

sms recieving problem with SIM300

Status
Not open for further replies.

Jestin Kuriakose

Newbie level 6
Joined
Dec 21, 2013
Messages
13
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
97
I am working on a embedded project using GSM SIM300.i am using Atmel at89s52, GSM module ,temperature sensor LM35.

Working of project- Temp sensor will sense the temperature and sent a message to my cell phone only if the temperature is above 30^c,,and if i sent a SMS to the cell phone(for eg-OK),the relay connected to the microcontroller should turn ON.My code is as follows-

Code:
#include<reg51.h>
#include<stdio.h>
#define MYDATA P1;
sbit ALE=P2^4;
sbit OE=P2^5;
sbit SC=P2^6;
sbit EOC=P2^7;
sbit ADDR_A=P2^0;
sbit ADDR_B=P2^1;



sbit MOTOR=P2^2;
unsigned char rx[20],msg[6];
unsigned char sensor1,adc1,r;

void clear(void)
{
unsigned char r;
for(r=0;r<100;r++)
rx[r]=0x00;
}


void clear1(void)   //user msg
{
unsigned char n;
for(n=0;n<=5;n++)
msg[n]=0x00;
}

void serialcomm()
{

 TMOD=0x20;        // Mode=2
 TH1=0xfd;         // 9600 baud
 SCON=0x50;        // Serial mode=1 ,8-Bit data,1 Stop bit ,1 Start bit  , Receiving on
 TR1=1;           // Start timer
  
}
void delay(unsigned int value)
   {
     unsigned int i,j;
     for(i=0;i<value;i++)      
     for(j=0;j<1275;j++);
   }

void serial(unsigned char x)
{
	SBUF=x;
	while(TI==0);
	TI=0;
}

void Send2Gsm(char *aaa)
{
     while(*aaa!='\0')
		 {
			 serial(*aaa);
			 aaa++;
     }
}



unsigned char convert(void)
{	unsigned char value;
	delay(1);
	ALE=1;
	delay(1);
	SC=1;
	delay(1);
	ALE=0;
	SC=0;
	while(EOC==1);
	while(EOC==0);
	OE=1;
	delay(1);
	value=MYDATA;
	OE=0;
	return(value);
}


void receive_data()  interrupt 4     // Function to recieve data serialy from RS232 into uc               
 {
 unsigned char r;
  rx[r]=SBUF;                       // Read sbuf
  RI=0;
  
 }
void main()
{
	char string1[10};
	int temp;
  serialcomm();
  Send2Gsm("AT\r\n");
  delay(2);
  Send2Gsm("AT+CMGF=1\r\n");
  delay(2);
  Send2Gsm("AT+CMGS= +918762357075\r\n");  
  delay(2);
  Send2Gsm("hello");
  serial(0x1a);

  while(1)
  {
  ADDR_B=0;
	ADDR_A=0;
	sensor1=convert();
	
	if(sensor1>60 )
	{
		temp=(adc1*0.489);
		sprintf(string1,"%d",temp);
		
                delay(500);
		Send2Gsm("Temperature=");
		Send2Gsm(string1);
		Send2Gsm("*c");
                delay(500);
		
		serial(0x1A);
		delay(500);
		IE=0x90;
		while(rx[r]=='?')
   {
     IE=0x00;   //disable interrupt
     

     if(rx[0]=='*' && rx[1]=='O' && rx[2]=='N' )
    {
     
     MOTOR=1;     
     clear();
     clear1();
     
    }
 
   else if(rx[0]=='*' && rx[1]=='O' && rx[2]=='F')
    {
    
       MOTOR=0;     
       clear();
       clear1();
     
    }
    }

		
}
}
}

i am not getting output with this code.i am having doubt with the recieving sms to the gsm modem.can anyone point out the mistakes in my code ??
 

you appear to send CTRL/Z
Code:
  serial(0x1a);
before the Temperature, etc which would terminate the message

do you received the "hello" part of the message
 

should the phone number have " marks?, e.g.
Code:
  Send2Gsm("AT+CMGS=\"+918762357075\"\r\n");
 

Try this
PHP:
  Send2Gsm("AT\r");
  delay(2);
  Send2Gsm("AT+CMGF=1\r");
  delay(2);
  Send2Gsm("AT+CMGS=\"+918762357075\"\r");  
  delay(2);
I have used this in my program and it'sworkimg for sending msg
 

still not working.should we give at command ATE0 at the beginning to avoid echo from the gsm.

Also,should we connect the ground of gsm modem to ground of microcontroller (my friend told me this). i have given supply to gsm modem.so, no need to do it right ?
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top