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