GSM returns OK when Reading SMS instead of SMS Message

Hello,
I m trying to read SMS from SIM868 using arduino with following commands but it only returns OK and not the original message.

SIM800.println("AT+CREG?"); //Check whether it has registered in the network
  updateSerial();
  SIM800.println("AT+CMGF=1\r"); // Text Mode
  updateSerial();

  SIM800.println("AT+CNMI=2,2,0,0,0\r"); 
  updateSerial();
  SIM800.println("AT+CPMS=\"SM\",\"SM\",\"SM\""); //SMS Storage in SIM
  SIM800.println("AT+CMGR=1"); // Read SMS at index 1
  updateSerial();

  SIM800.println("AT+CMGL=\"ALL\""); // Read All SMS
  updateSerial();

@ayazurrehman786, your topic has been moved to a more suitable location on the forum.

Please post your complete program.

Below is the code:

// I2C Library
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2); // set the LCD address to 0x27 for a 16 chars and 2 line display

#include <HardwareSerial.h>
HardwareSerial SIM800(1);
#define DEBUG true

void setup () {

  Serial.begin(115200);
  SIM800.begin(9600, SERIAL_8N1, 35, 32);    // RX and TX of ES32 for GSM SIM800L
  Wire.begin();   // Initialize I2C.
  lcd.init();                      // initialize the lcd
  lcd.backlight();

  Serial.println("Initialize...");
  delay(1000);

  SIM800.println("AT"); //Once the handshake test is successful, it will back to OK
  updateSerial();
  SIM800.println("AT+CREG?"); //Check whether it has registered in the network
  updateSerial();
  SIM800.println("AT+CMGF=1\r"); // Text Mode
  updateSerial();
  SIM800.println("AT+CNMI=2,2,0,0,0\r"); 
  updateSerial();
  SIM800.println("AT+CPMS=\"SM\",\"SM\",\"SM\""); //SMS Storage in SIM
  SIM800.println("AT+CMGR=1"); // Read SMS
  updateSerial();
  SIM800.println("AT+CMGL=\"ALL\""); // Read SMS
  updateSerial();
  delay(100);
}

void loop()
{
updateSerial();
}

void updateSerial()
{
  delay(500);
  while (Serial.available())
  {
    SIM800.write(Serial.read());//Forward what Serial received to Software Serial Port
  }

  while (SIM800.available())
  {
    Serial.write(SIM800.read());
  }
}

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.