Sometimes we have to list SMS messages from a preferred store using AT commands. Here is the demonstration to list messages from preferred store by AT commands using SIM900-TTL GSM Modem and Arduino. AT+CMGL is the command used to list messages from preferred store. Modem, I used is given here.
Step 1: Connections are done as shown in figure given below.
Step 2: Connect Arduino board to your computer.
Step 3: Open Arduino IDE.
Step 4: Now upload the below given program to Arduino board.
Some Important Facts :
1. For successfull uploading, wires connected to the RX and TX pins of Arduino board must be disconnected before uploading the code.
2. Don't forget to put a SIM having sufficient balance in the SIM900-TTL MODEM.
3. External power supply should be capable of handling 1A output current.
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()
{
}
Step 4: Open your Serial Monitor. Change the baud rate to 2400.
Step 5: Press the Reset button on Arduino board. Now all the messages in the SIM Memory will be displayed in the Serial Monitor.
mySerial.println("AT+CMGL=\"ALL\"\r");
ReplyDeletedelay(5000);
toSerial();
Above code gives output:
+CMGL: 1,"REC READ","+12xxxxxxxxxx","","17/05/23,15:10:25+22"
the message content is not displayed