last day (23 days later) » 

1:24 PM
1
Q: Error getting data from GSM SIM900

anna carolinaI am interfacing with GSM SIM900. I wrote a program so that I can read the SMS in SIM900. I have made a function to transmit and receive. Whenever msg comes, GSM responds with +CMT along with slot number.I am trying to extract that slot number which is in digits, but I am getting garbage values ...

 
If I remeber correctly your serial_TX functions expects a string (char*) as param but I suppose k is a single char variable, try with the uart_put function. You should have got a warning about this when you have built the code.
 
@BenceKaulics Hey I have made few changes in the code. I have removed the second for loop and included the isdigit function in first loop. I am getting enter on output that means control is entering my isdigit function and has found that digit but serial_Tx(data1[i]) is not running. Can you tell me whats wrong in this.?
 
You get the "enter" but nothing else?
 
@BenceKaulics yeah and even i checked it further by putting it in a if condition like if (data[i] >=5) {serial_Tx("match");else (serial_Tx("NO MATCH"), so I was getting match on output. I used >=5 because I didnt know the exact number and I assumed it to be greater than 5 because i know it may be 7 or 8
 
Okey so you should definetly read about Strings, chars, and char array, char pointers in C. Serial_TX is for sending a string like "enter" or "match" but k and data[i] is a single char like 'a', 'b', 'c'. Try with uart_put(data[i]).
 
1:24 PM
@BenceKaulics yes i read about strings and thnks to you for motivating me. Well I have used Uart_Put also but not getting data. For the change i used uart_put to transmit something else like only 'T' and its working but not for data[i]. I have attached my output
@BenceKaulics Hey I am getting the data properly but it is like 18181818181 where it should be 18 only. is this becuase of loops i am using?
 
Yes, probably it is because of the loop.
 
yeah it was because of loop. Now i have used it out of the loop and I am getting the number
and really thankyou for your help
hey can you tell me that this carriage return and line feed are one one characters or two
I mean this \r or \n is one char or two because as now I have got the slot number. I will try to read the message using this slot number and message command. so when i'll read i'll have two use some for loops to to actually read the content and ignore the other details before the message content
 
Both \r and \n is 1 character
 
\ indicates that it is not a letter r or n but carrige return and new line characters
you are using uart_put function now?
 
1:30 PM
yes
:)
 
okey, so probably that was the problem
 
yes
can you guide me how can I read the message content
 
1:42 PM
First, I think you should edit your question and reposition the image to end because not it is just messing up the text at the top, add something like "Output of the code:".
I do not have much time now but I later I will give a couple of ideas if I can. No promises though. :)
 
yeah sure :)
 
 
3 hours later…
5:08 PM
here are two links one is about read SMS command developershome.com/sms/cmgrCommand.asp the other is a code about sending and receiving SMS using a similar GSM module and AVR
 

  last day (23 days later) »