- This topic has 4 replies, 2 voices, and was last updated 11 years, 8 months ago by .
Viewing 5 posts - 1 through 5 (of 5 total)
Viewing 5 posts - 1 through 5 (of 5 total)
- You must be logged in to reply to this topic.
|
Microcontroller › AVR › read and comapare message in ATmega16
how to read and compare a message recived in gsm module? can any one give me a sample program?
i don’t have a program for atmega16. actually i wrote one for RD2 uC and it worked great for me. the logic remains same.
set up usart (check atmeg16 usart tutorial) with 9600 baud rate.
write serial send and serial receive function.
the next thing is to set your modem in text mode format.
the command to do so is AT+CMGF=1
now whenever a new sms is received u’ll recv this string
+CMTI: “SM”,1
where SM indicates sim card and 1 is the memory location.
you have to collect these bytes in charecter array one by one.
then to read sms send this command AT+CMGR=1
after executing this command you will get your sms charecters 1 by 1.
study the message format in some terminals (like senders no and newline blah blah). i used putty. extract the string and then write/use function strcmp function.
Hope you are good at writing c codes. check out ur modem datasheet.
all the best.
thank you sagar bhai….
actually I am a beginner in C.
how does the mcu will know that msg string is going to end? is the last bit of recived string is a null char ( )?
please tell me….
if there is a sample prog for atmega16 it will be a great helpfull for me.
no you won’t find null character at the end.
if u study the formatted data you are receiving from gsm modem u will find that for every command executed successfully, the last few data bytes are OKrn and for those having errors like say i am reading message from sim memory location 1 and message does not exist there
AT+CMGR=1
+CMS ERROR: 517rn
thats what you have to wait for (OKrn or error messages depending on AT commands u used).
you may need to manually put the null character for string comparision. (depends on your programming)
Happy Programming