Hello. I am using SIM800L module and for this project I need to be able to configure various program settings such as:
Delay time
Temperature_high
Temperature_low
and others....
First of all, I must configure the SIM800 modem to be able to receive SMS texts and route them to the USART:
In my void loop I can check what the sim800 modem is saying:
The serial monitor output:
The next step for me is to be able to store the messages to the buffer. That way, I can receive an SMS message and parse it how I want. I have developed a function to check whether there is Serial data available, if so, store the chars to the buffer one by one until the end of serial. However, it does not work as expected. It seems to work very unreliably. Could it be because that it detects null or end line characters and appends it to my array. And once my array detects null characters it thinks that its the end of this message? Please check the serial monitor below the read_SMS_data() function:
Please suggest a way to solve this issue? How can I read messages properly and store them to the buffer in a proper way?
Delay time
Temperature_high
Temperature_low
and others....
First of all, I must configure the SIM800 modem to be able to receive SMS texts and route them to the USART:
Code:
void configure_sms_mode()
{
SerialAT.println("AT+CMGF=1");
modem.waitResponse();
// 2ND OPTION 1 - save messages in buffer
// 2nd option 2 - route messages to usart
SerialAT.println("AT+CNMI=1,2,0,0,0"); // Decides how newly arrived SMS messages should be handled
modem.waitResponse();
Serial.println("waiting for response complete");
}
Code:
void loop()
{
if (SerialAT.available()) {
Serial.write(SerialAT.read());
}
if (Serial.available()) {
SerialAT.write(Serial.read());
}
}
Code:
07:43:43.702 -> waiting for response complete
07:43:44.654 ->
07:43:44.654 -> Call Ready
07:43:45.401 ->
07:43:45.401 -> SMS Ready
07:43:50.677 ->
07:43:50.677 -> *PSUTTZ: 2021,7,23,4,43,49,"+12",1
07:43:50.677 ->
07:43:50.677 -> DST: 1
07:43:52.784 ->
07:43:52.784 -> *PSUTTZ: 2021,7,23,4,43,52,"+12",253
07:43:52.784 ->
07:43:52.784 -> DST: 253
07:43:52.784 ->
07:43:52.784 -> +CIEV: 10,"24601","Telia LT","Telia LT", 0, 0
Code:
char full_message[50];
byte index5;
void read_SMS_data(){
if(SerialAT.available() > 0){
index5 = 0;
while(SerialAT.available() > 0)
{
char inChar = SerialAT.read();
full_message[index5] = inChar;
index5++;
}
Serial.print("full message = ");
Serial.println(full_message);
}
}
Code:
07:50:28.142 -> waiting for response complete
07:50:29.121 -> full message =
07:50:29.121 -> full message =
07:50:29.121 ->
07:50:29.121 -> full message = C
07:50:29.121 -> full message = a
07:50:29.121 -> full message = l
07:50:29.121 -> full message = l
07:50:29.121 -> full message =
07:50:29.121 -> full message = R
07:50:29.121 -> full message = eady
07:50:29.121 ->
07:50:29.872 -> full message =
ady
07:50:29.872 ->
07:50:29.872 -> full message =
07:50:29.872 -> ady
07:50:29.872 ->
07:50:29.872 -> full message = Sady
07:50:29.872 ->
07:50:29.872 -> full message = Mady
07:50:29.872 ->
07:50:29.872 -> full message = Sady
07:50:29.872 ->
07:50:29.872 -> full message = ady
07:50:29.872 ->
07:50:29.872 -> full message = Ready
07:50:29.872 ->
07:50:29.872 -> full message =
07:50:29.872 -> ady
07:50:29.872 ->
07:50:33.606 -> full message =
07:50:33.606 -> ady
07:50:33.606 ->
07:50:33.606 -> full message =
07:50:33.606 ->
07:50:33.606 -> ady
07:50:33.606 ->
07:50:33.606 -> full message = *
07:50:33.606 -> ady
07:50:33.606 ->
07:50:33.606 -> full message = P
07:50:33.606 -> ady
07:50:33.606 ->
07:50:33.606 -> full message = S
07:50:33.606 -> ady
07:50:33.606 ->
07:50:33.606 -> full message = U
07:50:33.606 -> ady
07:50:33.606 ->
07:50:33.606 -> full message = TTZ:
07:50:33.606 ->
07:50:33.606 -> full message = 2021,7,23,4,50,32,"+12",1
07:50:33.606 -> full message =
07:50:33.606 ->
07:50:33.606 -> DST: 1
07:50:33.606 -> 50,32,"+12",1
07:50:35.566 -> full message =
07:50:35.566 ->
07:50:35.566 -> DST: 1
07:50:35.566 -> 50,32,"+12",1
07:50:35.566 -> full message =
07:50:35.566 ->
07:50:35.566 ->
07:50:35.566 -> DST: 1
07:50:35.566 -> 50,32,"+12",1
07:50:35.566 -> full message = *
07:50:35.566 ->
07:50:35.566 -> DST: 1
07:50:35.566 -> 50,32,"+12",1
07:50:35.566 -> full message = P
07:50:35.566 ->
07:50:35.566 -> DST: 1
07:50:35.566 -> 50,32,"+12",1
07:50:35.566 -> full message = SUTTZ: 2021,7,23,4,50,35,"+12",253
07:50:35.566 ->
07:50:35.566 -> DS
07:50:35.566 -> full message = T: 253
07:50:35.566 ->
07:50:35.566 -> +CIEV: 10,"24601","Telia LT","Telia LT", 0, 0
07:50:35.566 ->
Last edited: