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
}
}
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.
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