Parsing SMS Message

currently I have a code to check an internet data plan using AT command, to see it i use USSD at command to check my internet data plan and the USSD send my internet data plan via SMS, all i need now is to parse that long text i got from the USSD into a few sentence. like "your Internet data is only...."

void setup() {
  Serial.begin(9600);
  Serial.println("Starting..."); 
  delay(1000);
  cek_kuota();
}
void cek_kuota ()
{ 
  Serial2.begin(9600);
  Serial2.println("AT");
  updateSerial();
  Serial2.println("AT+CUSD=1");
  updateSerial();
  Serial2.println("AT+CUSD=1,\"*888*6*2*1#\"");
  updateSerial();
  Serial2.println("AT+CMGF=1"); 
  updateSerial();
  Serial2.println("AT+CNMI=1,2,0,0,0");
  updateSerial();
}
void loop() 
{
  updateSerial();
}
void updateSerial() {
  delay(500);
  while (Serial.available()) {
    Serial2.write(Serial.read());//Forward what Serial received to Software Serial Port
  }
  while (Serial2.available()) {
    Serial.write(Serial2.read());//Forward what Software Serial received to Serial Port
  }
}

this how i check my internet data plan via USSD

Show your code and how you store the answer

(please read How to get the best out of this forum and post accordingly, including code tags and necessary documentation for your ask).

can you give an example of the text you receive and what information you wish to parse out of it?
what Arduino are you using?

owh i use Esp32 and a sim800L and the text i receive is like this
"Freedom U 35GB/30days active until 19/01/2023 12:36. internet data plan: 726 MB, you already use 11 gb from 23gb. you can also check via *myphone provider"
the Bold sentence is what am tryning to parse.

read the text into a String and use the subString() method to search for internet data plan:

Hopefully this video will help a bit

Do you receive it in a char buffer or a String instance ?

Serial2.readStringUntil(':'); // Skip past "...19/01/2023 12:"
Serial2.readStringUntil(':'); // Skip past "internet data plan:"
int num = Serial2.parseInt(); // Read 726
String suffix = readStringUntil(','); // Read KB, MB or GB

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.