Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

reading SMS from Gsm phone

Status
Not open for further replies.
Hi, i've managed to use AT commands to send an sms to a cell phone, i wanna read the first message , i know the command its AT+CMGR=0; for index 0 , but at hyperterminal there are many strings have been outputed that includes the phone number , time ..etc and finally the SMS , i dont know how to extract the sms from all these things ?

also , the phone worked only when i tired CTR to 5V and RTS to GND , is this correct ?? im not sure how the AT command for sending SMS worked then ...
 
You'll have to decode the SMS header that the phone is sending to you, it's going to have a set format.

Does this help?
**broken link removed**

Google is your friend =)
 
Last edited:
I'm not sure what problem you're having, parse the text you receive and drop the information you don't want.
 
So what's the problem?
The text message itself is on it's own line, it's sitting right there ready for you to pick it out =) After you send the AT command ignore up until the first carriage return (or CR/LF depending on what's being sent) and then save up until the next line.
 
Well it depends on what other responses you might get back from the AT command, for example what happens if there is no text message to retrieve from the index specified, also how do you determine if this is a new SMS message or an old one? Are there any other error messages that could occur?

If you're sure that your AT comand is going to result in a valid SMS message not some other error message then simply ignore everything received up until the first CR/LF and then save everything into a buffer until the next CR/LF that will be your SMS message. You could buffer the whole thing and strcomp that.
 
I would use a terminal program such as bray's terminal which allows you to look at the data that's coming in in hex/dec/binary as well as show it in ascii, that way you can see if each line is a CR or CR/LF As soon a the CR or CR/LF pair was received do your comparison then.
 
You should also anticipate an errors if there are no SMS to read. Try clearing the phone's inbox and read the message. The phone should reply an error message and your software should recognize this. If there is no error, the message is on the second line after the cr/lf.

If you have several messages in the inbox, try using AT+CMGR=1 to read the first message in the inbox. AT+CMGR=2 for the second, and so on.

You can use AT+CMGL to read new messages that were not read yet. It will be helpful if you empty the inbox after reading so your inbox will not get full with an AT+CMGD=1 command to delete the message in memory1.
 
Guys i'm working on Final year project this year and my project is using phone just as a modem to receive and send SMS control by using PC and the PIC microcontroller is use to control the house system, the problem i face for this moment is i do not know what type of phone should i use and the program should i take.
The only mobile phone i got for this moment is Iphone 1st generation, Nokia E65,Sonic ericsson K700 and W850
Can anyone help me on this?
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top