web SMS logoweb sms containerweb SMS logo
web SMS hometext online About UsTry text online onlineSignup online smstext online Contact Us
web SMS caption></td>
                <td class=

SMS using AT commands with your GSM modem

You can check and send SMS using AT commands. You can connect to your serial port via "putty" or "hyperterminal" to run these AT commands.

AT commands are instructions used to control a modem. AT is the abbreviation of ATtention. Every command line starts with "AT" or "at". That's why modem commands are called AT commands. Many of the commands that are used to control wired dial-up modems, such as ATD (Dial), ATA (Answer), ATH (Hook control) and ATO (Return to online data state), are also supported by GSM/GPRS modems and mobile phones. Besides this common AT command set, GSM/GPRS modems and mobile phones support an AT command set that is specific to the GSM technology, which includes SMS-related commands like AT+CMGS (Send SMS message), AT+CMSS (Send SMS message from storage), AT+CMGL (List SMS messages) and AT+CMGR (Read SMS messages).

Note that the starting "AT" is the prefix that informs the modem about the start of a command line. It is not part of the AT command name. For example, D is the actual AT command name in ATD and +CMGS is the actual AT command name in AT+CMGS. However, some books and web sites use them interchangeably as the name of an AT command.

Note that mobile phone manufacturers usually do not implement all AT commands, command parameters and parameter values in their mobile phones. Also, the behavior of the implemented AT commands may be different from that defined in the standard. In general, GSM/GPRS modems designed for wireless applications have better support of AT commands than ordinary mobile phones.

In addition, some AT commands require the support of mobile network operators. For example, SMS over GPRS can be enabled on some GPRS mobile phones and GPRS modems with the +CGSMS command (command name in text: Select Service for MO SMS Messages). But if the mobile network operator does not support the transmission of SMS over GPRS, you cannot use this feature.


Some advanced GSM modems like Huawei 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" (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:


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: ,

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","+31625044454",,"07/07/05,09:55:16+08"

Test message 1

+CMGL: 2,"REC UNREAD","+31625044454",,"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","+31625044454",,"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.

More AT commands:

  • Get basic information about the mobile phone or GSM/GPRS modem. For example, name of manufacturer (AT+CGMI), model number (AT+CGMM), IMEI number (International Mobile Equipment Identity) (AT+CGSN) and software version (AT+CGMR).
  • Get basic information about the subscriber. For example, MSISDN (AT+CNUM) and IMSI number (International Mobile Subscriber Identity) (AT+CIMI).
  • Get the current status of the mobile phone or GSM/GPRS modem. For example, mobile phone activity status (AT+CPAS), mobile network registration status (AT+CREG), radio signal strength (AT+CSQ), battery charge level and battery charging status (AT+CBC).
  • Establish a data connection or voice connection to a remote modem (ATD, ATA, etc).
  • Send and receive fax (ATD, ATA, AT+F*).
  • Send (AT+CMGS, AT+CMSS), read (AT+CMGR, AT+CMGL), write (AT+CMGW) or delete (AT+CMGD) SMS messages and obtain notifications of newly received SMS messages (AT+CNMI).
  • Read (AT+CPBR), write (AT+CPBW) or search (AT+CPBF) phonebook entries.
  • Perform security-related tasks, such as opening or closing facility locks (AT+CLCK), checking whether a facility is locked (AT+CLCK) and changing passwords (AT+CPWD). (Facility lock examples: SIM lock [a password must be given to the SIM card every time the mobile phone is switched on] and PH-SIM lock [a certain SIM card is associated with the mobile phone. To use other SIM cards with the mobile phone, a password must be entered.])
  • Control the presentation of result codes / error messages of AT commands. For example, you can control whether to enable certain error messages (AT+CMEE) and whether error messages should be displayed in numeric format or verbose format (AT+CMEE=1 or AT+CMEE=2).
  • Get or change the configurations of the mobile phone or GSM/GPRS modem. For example, change the GSM network (AT+COPS), bearer service type (AT+CBST), radio link protocol parameters (AT+CRLP), SMS center address (AT+CSCA) and storage of SMS messages (AT+CPMS).
  • Save and restore configurations of the mobile phone or GSM/GPRS modem. For example, save (AT+CSAS) and restore (AT+CRES) settings related to SMS messaging such as the SMS center address.
web SMS line
web SMS header
Enter your mobile number:
Enter your password:
  Copyright © TXTOnline. All Rights Reserved

web SMS banner