Microcontroller › 8051 › how to read the received message/number from microcontroller › The GSM modem can be
The GSM modem can be configured like the following to response immediate when a SMS is received, the SMS’s details are immediately sent serially
AT+CMGF=1 | To format SMS as a TEXT message |
AT+CNMI=1,2,0,0,0 | Set how the modem will response when a SMS is received |
When a new SMS is received by the GSM modem serially send the following data
+CMT : “+91xxxxxxxxxx” , , “04/08/30,23:20:00+40”
This the text SMS message sent to the modem
If you take a close look, it can be found that the 8th character is the starting of the mobile number after a character ‘+’ has been received for the first time.
So just wait till the ‘+’ is received for the first time, then count the next 7 characters received, start storing from the 8 th charater onwards into an array till the 20 th character and you have the mobile number in that array, like +91xxxxxxxxxx