SIM900 receive SMS

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);
  
}

The setting I put is - “AT+CNMI=2,2,0,0,0”. (I tried 2,1,0,0,0 - no change)
The output on the serial monitor is - +CMTI: “ME”,70

Your CNMI setting looks correct for immediate forwarding of the received message to the Arduino, but the +CMTI indicates the message is being held in a receive buffer.

You should be seeing a +CMT response when the second parameter is a 2. The use of the 1 as the second parmeter will give the +CMTI response you are seing.

First, I would confirm that your settings are actually implemented and you don’t have some default override. Use AT+CNMI? to see what the actual settings are. You want 1,2,0,0,0 or 2,2,0,0,0.

If the setting are as you indicate, I don’t understand why your device would behave as it does.

Second, if you can’t figure out how to get the messaged dircetly transfered with +CMT, you may need to actually use the CMTI response and initiate the reading of the message from the index of the stored location with AT+CMGR =.

In your case with +CMTI: “ME”,70 you would use
AT+CMGR = 70.