Hello,
I'm having some problems using a SIM900 module with my UNO. After some time of listening to a NeoSWSerial connection (same with SoftwareSerial) I only receive a huge mess of data. The interesting thing is, that if I have this issue and I try to send a SMS (sending is always possible) the connection "gets" healed. It looks like that there is an overflow within the NeoSWSerial of the receive buffer. Does anyone have any idea what I can try? Attached you find the part of the code which is relevant:
bool waitForSMS() {
if (SIM900.available() != 0) {
incoming_message = "";
unsigned long lastmillis = millis();
int i = 0;
memset(rx_buffer, EOS, 200); // Initialize the string
while((lastmillis + 100)>millis()){
while (SIM900.available() != 0) {
rx_buffer[i] = SIM900.read();
i++;
}
}
Serial.println(rx_buffer);
incoming_message = String(rx_buffer);
Serial.println(incoming_message);
if (incoming_message.startsWith(startPattern)) {
incoming_message = removeFirstLine(incoming_message, startPattern);
return true;
} else if (!incoming_message.startsWith("AT+CMGF=1")) {
SIM900.print("AT+CMGF=1\r"); //try to "heal" connection
delay(100);
}
}
return false;
}
By the way, I use a fixed baudrate for the SIM900
SIM900.print("AT+IPR=9600\r");
Hope someone can help me.