AT Command

Description

AT+CMGL command is used to read SMS messages from preferred storage.


Support

Module Tutorial

Examples

KeywordsAT+CMGL syntax, examples, parameters, error, input, response.

Try the below script in the AT Command Tester tool

////Script: at_cmgl.at
//Use this script to AT+CMGL AT command

//Get the command support
AT+CMGL=?

WAIT=2

//Set it for SMS text mode
AT+CMGF=1

//SMS text mode, get received unread messages
AT+CMGL="REC UNREAD"

WAIT=1

//SMS text mode, get received read messages
AT+CMGL="REC READ"

WAIT=1

//SMS text mode, get stored unsent messages
AT+CMGL="STO UNSENT"

WAIT=1

//SMS text mode, get stored sent messages
AT+CMGL="STO SENT"

WAIT=1

//SMS text mode, get all messages
AT+CMGL="ALL"

WAIT=1

//Set it for SMS pdu mode
AT+CMGF=0

WAIT=1

//SMS pdu mode, get received unread messages
AT+CMGL=0

WAIT=1

//SMS pdu mode, get received read messages
AT+CMGL=1

WAIT=1

//SMS pdu mode, get stored unsent messages
AT+CMGL=2

WAIT=1

//SMS pdu mode, get stored sent messages
AT+CMGL=3

WAIT=1

//SMS pdu mode, get all messages
AT+CMGL=4

WAIT=1


Output of the above script in the AT Command Tester tool tool.

AT+CMGL=?

+CMGL: (0-4)

OK
AT+CMGF=1

OK
AT+CMGL="REC UNREAD"

OK
AT+CMGL="REC READ"

+CMGL: 0,"REC READ","+17026089670","","19/04/05,23:32:12-28"
Test message to AT Command Tester
+CMGL: 1,"REC READ","+17026089670","","19/04/05,23:32:34-28"
Testing AT+CMGL Command
+CMGL: 2,"REC READ","+17026089670","","19/04/05,23:33:40-28"
Read all SMS messages

OK
AT+CMGL="STO UNSENT"

OK
AT+CMGL="STO SENT"

OK
AT+CMGL="ALL"

+CMGL: 0,"REC READ","+17026089670","","19/04/05,23:32:12-28"
Test message to AT Command Tester
+CMGL: 1,"REC READ","+17026089670","","19/04/05,23:32:34-28"
Testing AT+CMGL Command
+CMGL: 2,"REC READ","+17026089670","","19/04/05,23:33:40-28"
Read all SMS messages

OK
AT+CMGF=0

OK
AT+CMGL=0

OK
AT+CMGL=1

+CMGL: 0,1,"",48
07912180958739F1040B917120069876F000009140503223218A21D4F29C0E6A97E7F3F0B90CA2BF41412A68F86EB7C36E32885A9ED3CB72
+CMGL: 1,1,"",40
07912180958739F1040B917120069876F000009140503223438A17D4F29C9E769F4141EA6AD83C3241C377BB1D769341
+CMGL: 2,1,"",38
07912180958739F1040B917120069876F000009140503233048A15D272980C0AB3D9A069730A6A97E7F3F0B93C07

OK
AT+CMGL=2

OK
AT+CMGL=3

OK
AT+CMGL=4

+CMGL: 0,1,"",48
07912180958739F1040B917120069876F000009140503223218A21D4F29C0E6A97E7F3F0B90CA2BF41412A68F86EB7C36E32885A9ED3CB72
+CMGL: 1,1,"",40
07912180958739F1040B917120069876F000009140503223438A17D4F29C9E769F4141EA6AD83C3241C377BB1D769341
+CMGL: 2,1,"",38
07912180958739F1040B917120069876F000009140503233048A15D272980C0AB3D9A069730A6A97E7F3F0B93C07

OK