Hi,
I am installing the SIM808 module (which is very similar to SIM900, just having an additional GPS and BT on it), and not being able to process the incoming sms.
(I checked probably 10-20 different coding instructions on the net, but still…).
The thing is that when I send sms to the UNO+SIM808, I want the module to process the content and upon it, print a different message to the serial monitor.
The setting I put is - “AT+CNMI=2,2,0,0,0”. (I tried 2,1,0,0,0 - no change).
The code is very simple at the moment.
(As soon as I got this working, it is going to be used in a much more complex project, with control via mobile).
The output on the serial monitor is - +CMTI: “ME”,70
#include <SoftwareSerial.h>
SoftwareSerial SIM808(7,8);
void send_message(int);
String incoming_message = "";
void setup() {
Serial.begin(9600);
pinMode(11, INPUT_PULLUP);
pinMode(12, INPUT_PULLUP);
// Power ON SIM808 module
digitalWrite(9, LOW);
delay(1000);
digitalWrite(9, HIGH);
SIM808.begin(9600);
SIM808.println("AT+CNMI=2,2,0,0,0");
delay(200);
SIM808.println("AT+CMGF=1");
delay(200);
}
void loop() {
if (SIM808.available() > 0 ) {
incoming_message = SIM808.readString();
Serial.print(incoming_message);
delay(200);
}
if (incoming_message.indexOf("STAT") >= 0) {
Serial.println("STATUS command received");
incoming_message = "";
}
if (incoming_message.indexOf("HLP") >= 0) {
Serial.println("HELP command received");
incoming_message = "";
}
if(digitalRead(11) == LOW) {
delay(2000);
send_message(1);
}
else if(digitalRead(12) == LOW) {
delay(2000);
send_message(2);
}
} // end of main loop
void send_message(int variator) {
SIM808.print("AT+CMGF=1\r");
delay(200);
SIM808.print("AT+CMGS=\"+xxxxxxxxxxxx\"\r"); // mobile number is here
delay(200);
if(variator == 1) {
SIM808.print("TEST_1");
}
else if(variator == 2) {
SIM808.print("TEST_2");
}
delay(200);
SIM808.println((char)26);
}