Hello
I was doing a project using a GSM SIM900 and I want to extract only the phone number and the content of message. Here is what I received from the serial
+CMT: "+251xxxxxx89","","23/03/27,11:54:22+12"
Hi
And I only want the phone number and the message 'Hi'.
thank you
Check Arduino/reference for string manipulating functions.
ok now I can extract the phone number but how can I extract the received message?
textMessage = mySerial.readString();
CellNumtemp = textMessage.substring(textMessage.indexOf("+251"));
CellNum = CellNumtemp.substring(0,13);
Serial.println(CellNum);
delay(1000);
}
Is the last part of the header always: +12" ?
If so search for that in the same way that you searched for "+251".
You then need your substring to start at element 4 now instead of 0 (to omit +12" from the message).
You knew the length of the telephone number, but the length of the message will vary so use length() as the second parameter for the substring.
system
Closed
September 23, 2023, 12:02pm
7
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.