Hello good day everyone. I seem to be having some problems. i am using an arduino mega 2560 and connected to it i have a gsm module sm5001-B module. I am able to send text messages but recieving is a bit more tricky. I have the following code below:
char character=0;
void setup()
{
Serial.begin(9600);
Serial1.begin(9600);
delay(60000);
}
void loop()
{
int j=0;
char incoming_let=0;
char incoming_char[500]=" ";
String buff1 = String(500);
Serial1.println("AT+CMGF=1");
delay(1500);
Serial1.print("AT+CMGL=");
Serial1.write((byte)34);
Serial1.print("ALL");
Serial1.write((byte)34);
Serial1.println();
delay(1000);
while(Serial.available())
{
character = Serial.read();
Serial1.print(character);
}
while(Serial1.available())
{
character = Serial1.read();
Serial.print(character);
}
}
Output:
+SIND: 11
+SIND: 3
+SIND: 4
OK
+CMGL: 1,0,"REC READ
OK
+CMGL: 1,0,"REC READ","+18687914655","13/03/21,20:39:00+0
OK
+CMGL: 1,0,"REC READ","+18687914655","13/03/21,20:39:00+0
OK
+CMGL: 1,0,"REC READ","+18687914655","13/03/21,20:39:00+0
OK
+CMGL: 1,0,"REC READ","+18687914655","13/03/21,20:39:00+0
OK
+CMGL: 1,0,"REC READ","+18687914655","13/03/21,20:39:00+0
But following the same code on the terminal gives this output:
as you can see the actual sms body saying testing was gotten. My goal is to get the entire message and parse the entire string to get the sms body alone. Thank you in advance.