You are here: > Tutorials > GSM Modem Tutorials > Receive SMS messages using AT commands

Receiving SMS messages using AT commands


Some advanced GSM modems like WaveCom and Multitech, support the SMS text mode. This mode allows you to send and receive SMS messages using AT commands, without the need to decode the binairy PDU field of the SMS first. This is done by the GSM modem.

To send the commands discussed in this tutorial, you can use a terminal program, for instance Hyperterminal.

To check if your modem supports this text mode, you can try the following command:


If the modem reponds with "OK" this mode is supported. Please note that using this mode it is onluy possible to send simple text messages. It is not possible to send multipart, Unicode, data and other types of messages.

Setting up the modem

If the modem contains a SIM card with is secured with a PIN code, we have to enter this pin code first:

AT+CPIN="0000" <ENTER>  (replace 0000 with your PIN code).

Please not that in most cases you have only 3 attemps to set the correct PIN code. After setting the PIN code, wait some seconds before issueing the next command to give the modem some time to register with the GSM network.

In order to send a SMS, the modem has to be put in SMS text mode first using the following command:


If the modem responds with error, either the modem does not support SMS text mode, or the SIM card is not ready. In this case please check that the SIM card is inserted and the pincode is entered. You can also turn on extended error reports by using the following command:


Instead of just an "ERROR" the modem will now respond with "+CMS ERROR: xxx" or "+CME ERROR: xxx". For a list of possible error codes please check this list.

Selecting the preferred message storage

A GSM phone or modem receives messages automatically. Basically you are just retrieving the messages from the memory of the device or SIM card. To select the message storage used to read the messages from, you have to use the "AT+CPMS" command. You can select one of the following message storages, not all storages are supported on every device.

Storage ID Description
SM Read SMS messages from the SIM card. This storage is supported on every GSM phone, because a SIM card should always be present. Usually a SIM card can store up to 15 messages.
ME Read SMS messages from the modem or mobile phone memory. The number of messages that can be stored here depends on the size of the phones memory.
MT Read SMS messages from all storages on the mobile phone. For instance when the phone supports "ME" and "SM", the "MT" memory combines the "ME" and "SM" memories as if it was a single storage.
BM This storage is only used to read stored incoming cell broadcast messages. It is normally not used to store SMS messages.
SR When you enable status reports when sending SMS messages, the status reports that are received are stored in this memory. These reports can read the same way as SMS messages.

To find out which storages are supported by your mobile phone, use the command line below:


The modem will respond with a list of supported storages, for instance:

+CPMS: (("SM","BM","SR"),("SM"))

The storage can be selected using the following command:

AT+CPMS=<read>[,<send>,<receive>] <ENTER>

The first parameter sets the storage to read from the second optional specifies the storage to send messages from and the last optional parameter tells the device where to store newly received messages.

For example, to read messages from the SIM card use:


The modem should respond with the following string:

+CPMS: <used_space>,<max_space> <ENTER>

The used_space indicates the number of messages currently in this memory, the max_space the number of messages that can be stored.

Listing the messages

Once you have successfully set the messages storage, you can list the messages available using the list command:


Please not that "ALL" has to be send in uppercase on some modems. The modem will respond with a list of decoded SMS messages:

+CMGL: 1,"REC UNREAD","+31625012354",,"07/07/05,09:55:16+08"
Test message 1
+CMGL: 2,"REC UNREAD","+31625012354",,"07/07/05,09:56:03+08"
Test message 2


The response messages are formatted like this:

+CMGL: <index>,<status>,<from_address>,<mr>,<scts><CRLF><data>
index The memory index number, use this index to read or delete this message.
status The status of this message. For received messages this can be "REC READ" or "REC UNREAD" depending on whether the messages has been read or listed before.
from_address The subscriber number of the person who sent the message.
mr The reference number of this message. Most modems keep this field empty.
scts The time the message was forwarded to this phone or modem.
data The actual message data in plain text

Reading a message

To list a single message, you have to use the read command. You must use the list command first, so you know the indexes of the messages in the storage. For instance, to read the message on memory location '2' use:


The modem will list the single message:

+CMGR: "REC READ","+31625012254",,"07/07/05,09:56:03+08"
Test message 2


Please note that the status of the message is now "REC_READ" instead of "REC_UNREAD" because we read the message.

Deleting a message

Once you have read a message, you can free the memory by deleting the message from the storage. For instance, to delete the message on memory location '2' use:


The modem will delete the single message.