I'm trying to receive an SMS and show it on the serial monitor.
My code is as following:
void setup()
{
Serial.begin(2400);
Serial.write("AT+CMGF=1\r"); //set GSM to text mode
delay(1500);
Serial.write("AT+CPMS=\"SM\"\r"); //Preferred SMS Message Storage
delay(1000);
Serial.write("AT+CMGL=\"ALL\"\r"); //List SMS Messages from Preferred Storage
while(1)
{
if(Serial.available())
{
Serial.write(Serial.read());
}
}
}
void loop()
{
}
The circuit diagram is as shown below.
The output that I am getting is as following:
AT+CMGR=1
AT+CMGF=1
OK
AT+CPMS="SM"
ERROR
AT+CMGR=1
AT+CMGF=1
OK
AT+CPMS="SM"
ERROR
ERROR
AT+CMGR=1
AT+CMGF=1
I am not able to use AT+CPMS
or AT+CMGL
commands.