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.

Receiving sms using pic

Status
Not open for further replies.

abishekmudalur

Member level 1
Joined
Aug 1, 2008
Messages
36
Helped
2
Reputation
4
Reaction score
2
Trophy points
1,288
Location
coimbatore,india
Activity points
1,519
hi
i m using pic16f877a & sim300 gsm modem
now i can send sms successfully from pic through gsm modem...
my problem is tat i dont know how to receive a msg and how to access the msg..
can anyone help me....
 

When a new message is received modem get at+CNMI indication (New Message Indication). You can Write program to send AT+CNMI and get response. when getting responseget it means new message is received. which will be stored in SIM, read the particular location.
If you dont know the location then clear the SIM messages then all incoming messages are stored in location 0. you can read that location and delete it so that all messages are stored in same location.

refer AT commands PDF for more details
 
thanx...
but i m getting some more details along with the msg....
i need to access the sender number & body of the msg....
how to do tat....
 

When you get sms, in your code discard all messages till you get 1st character as '+' which will be followed by 12 digit phone number. e.g.+91xxxxxxxxxx.

So you read the sender phone number.
Next you can read the message content, by storing it in array or directly read as a string
 
hi
i m using pic16f877a & sim300 gsm modem
now i can send sms successfully from pic through gsm modem...
my problem is tat i dont know how to receive a msg and how to access the msg..
can anyone help me....

first of all u should know how the sms are stored in the memory

sms are stored in the index form
first sms in 1st index, 2nd on 2nd so on...................
if u want to read the 1st sms
then write the code as
AT+CMGR=1

wher 1 is for index no 1
 

Every message will have 160 characters. so it depends on how you define the size of array and read it. but when you give AT+CMGR it read 1 full location. so if message is big then you need to read and increment the memory location
 

    moh252

    Points: 2
    Helpful Answer Positive Rating

    halimdk007

    Points: 2
    Helpful Answer Positive Rating
    V

    Points: 2
    Helpful Answer Positive Rating
hi
i m using pic16f877a & sim300 gsm modem
now i can send sms successfully from pic through gsm modem...
my problem is tat i dont know how to receive a msg and how to access the msg..
can anyone help me....

i hope it will help you more
 

Attachments

  • quick start of GSM communication.rar
    1.4 KB · Views: 285
If you were able to read SMS ,please give me a idea of the program?
 

/************************* HEADER FILE *************************************/

#include<function.h>

/************************* MAIN FUNCTION **********************************/
void main()
{

unsigned char i,msg[50];

uartinit();
lcd_init();

while(1)
{
cmd(0x01);
lcd_datawrt("WAITING FOR MSG");//wait
while((getdat())!=':');
while((getdat())!='+');
while(getdat()!='\n');
for(i=0;i<20;i++)
{
msg=getdat();
if(msg=='\r')
break;
}
msg='\0';
lcd_datawrt(msg);
}
}

/***************************** END *************************************/


/************************* HEADER FILE *************************************/
#include<reg51.h>
#include<function.h>

/************************* LCD_PINS ***************************************/

sbit RS=P1^0;
sbit EN=P1^1;

/************************* FUNCTIONS *************************************/
void cmd(unsigned char cd)
{
unsigned int a,x;
a=(cd&0xF0)>>2;
RS=0;
P1=a;
RS=0;
EN=1;
delay(5);
EN=0;
P1=0X0;
delay(5);
x=((cd&0x0F)<<2);
P1=x;
RS=0;
EN=1;
delay(5);
EN=0;
P1=0X0;
//return;
}
void dat(unsigned char dt)
{
unsigned int a1,x1;
a1=(dt&0xF0)>>2;
P1=a1;
RS=1;
EN=1;
delay(5);
EN=0;
P1=0X0;
delay(5);
x1=((dt&0x0F)<<2);
P1=x1;
RS=1;
EN=1;
delay(5);
EN=0;
P1=0X0;

}
void lcd_datawrt(unsigned char *msg)
{
unsigned char count=0;
for(;*msg; msg++)
{
if(count>15)
cmd(0xc0);
if(count>31)
cmd(0x18);
dat(*msg);
count++;
}
}
void lcd_init()
{
unsigned char cmdarray[]={0x28,0x0C,0x01,0x06,0x80},t=0;

for (t=0;t<5;t++)
{
cmd(cmdarray[t]);
delay(10);
}
}
void uartinit(void) //uart initialising
{
TMOD=0x20;
TH1=0x0FD;//9600 baud rate
SCON=0x50;
TR1=1;
}
unsigned char getdat(void) //receive gps data serially
{
unsigned char a;
while(RI==0);
a=SBUF;
RI=0;
return(a);
}
void delay (unsigned int t)
{
unsigned int i,j;
for(i=0;i<t;i++)
for(j=0;j<2000;j++);
return;
}

/***************************** END *************************************/
 
Thanks a lot . Me too have a similar program,but I cant get the data from my GSM modem to controller.My modem is Sim300.
I am able to send sms but cant read it . I am able to get the data on hyper terminal of PC. Any idea?
 

ya I tried the program. But no response. I thinkthere is some problem regarding the communication between Controller and GSM modem.I am jsut connecting RX toTX and vice versa along with ground.
Is there any more connection required?
 

ya I am using separate power for the controller and modem
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top