AT Command Guide - Table of Contents
- What are AT commands?
- What can AT commands be used for?
- What is the syntax of AT commands?
- Do different modules and vendors have different AT commands?
- How do I identify proprietary AT commands?
- How do I find the AT commands my modem supports?
- My AT-command only responds with ERROR - how do I get more info?
- Basic commands to get information about the modem and SIM card
- Removing or adding SIM PIN via AT commands
- AT commands for network selection and configuration
- AT commands for radio signal quality analysis
- AT commands to establish a PDP context / data session
- Final thoughts
What are AT commands?
The first step to diving into the Internet of Things is connecting your hardware to a modem. The connection between a modem and your hardware is achieved using AT commands. AT commands are a short text command language dating back to 1981, originally developed for Hayes smart modems and later used in dial-up modems in the 1990s.
What can AT commands be used for?
AT commands enable you to control everything around the modem, device, and SIM:
- Wake the device or put it in sleep mode
- Configuration of power-saving modes
- Scan for and register to available networks and radio types
- Get updates about network condition changes
- Read/send SMS and USSD
- Send data (TCP/IP)
- Get hardware and SIM information (IMEI, IMSI, etc.)
- and much more
To get started, we will talk about the syntax or the types of AT commands that can be sent to the modem.
What is the syntax of AT commands?
AT Commands usually have a standardized syntax rule - most commands have three different types: write, read, and test. And then there are also others that can be executed just to retrieve information. All standard AT commands start with AT+<command>
. The response to the commands do not contain AT and only use +<command>:
1. Write: AT+<x>=<…>
Sets the user-definable parameter values of the modem
The expected response is usually only "OK"
Example: AT+CREG=1
– meaning enable network registration report
2. Read: AT+<x>?
Returns the settings of the modem
Example: AT+CREG?
Response: +CREG: 1,1
– meaning currently reports are configured to be enabled and the device is registered on the home network
3. Test: AT+<x>=?
Checks supported configurations / services of the modem
Example: AT+CREG=?
Response: +CREG: (0-2)
– meaning that 0,1,2 can be set in the AT+CREG command
4. Execute: AT+<x>
Retrieve information or execute command
Example: AT+CCID
Response: +CCID:8988303000005737285 - returning the SIM card identifier (ICCID)
Then there are also reports that can be generated on status changes for several commands often called unsolicited results code (reports). For example when the network registration changes. These reports have a similar format to the read command but sometimes differ on a couple of parameters.
Do different modules and vendors have different AT commands?
Whereas AT commands are standardized in 3GPP TS 27.005 and 27.007 and all manufacturers need to implement them, there can be differences based on the modem type and vendor.
Based on the modem type - for e.g., some power saving commands are only available on newer versions that also have the functionality. Parameters may also differ because the modem does not support this specific radio type configuration or error code.
Often manufacturers introduce additional proprietary AT commands that either have new functionality or enhance existing AT commands. While these commands can be powerful, considerations for cross-vendor firmware need to be taken.
How do I identify proprietary AT-commands for U-Blox, Quectel, Telit, Nordic, Gemalto etc.?
Usually vendor proprietary commands are identifiable by a slightly changed command syntax in the beginning.
- Quectel - start with AT+Q - e.g. AT+QCFG
- U-Blox - start with AT+U - e.g. AT+UDCONF
- Telit - start with AT “@”, “#”, “$” or “*” - e.g. AT@CLCK
- Nordic - start with AT% - e.g. AT%XSNRSQ
- Gemalto/Cinterion - start with AT^ - e.g. AT^SMSO
- ZTE - start with AT+Z - e.g. AT+ZCELLINFO
How do I find the AT commands my modem supports?
Every modem should have a detailed description of its AT commands in an AT command guide. Nevertheless, you can also check the list of available AT commands with an AT command itself: AT+CLAC
My AT-command only responds with ERROR - how do I get more info?
In the standard configuration, the AT-Command response is short: OK and ERROR.
For getting a more detailed output of what caused the error you can use the command AT+CMEE=1 or AT+CMEE=2.
The error will then either start with +CMS ERROR: xxx (indicating a network error) or +CME ERROR: xxx (indicating a device error)
AT+CMEE=1 - each error message includes an error code as described 3GPP TS 27.007 Ch. 9.2. For example, the module will return +CME ERROR: 11 -
meaning the SIM PIN is required.
AT+CMEE=2 - if the modem supports it, then the error message includes a string expression of the error. For example +CME ERROR: SIM PIN required
Basic commands to get information about the modem and SIM card
The below commands do not have a read or test command and no parameters - they only execute commands that return information.
Name |
AT Command |
Description |
Get manufacturer |
AT+CGMI |
Returns string representation of the manufacturer |
Get model |
AT+CGMM |
|
Get firmware |
AT+CGMR |
Returns firmware revision |
Get IMEI |
AT+GSN |
Retrieves the International Mobile Equipment Identity of the module |
Get IMSI |
AT+CIMI |
Returns the current used IMSI |
GET ICCID |
AT+CCID |
Returns the ICCID of the SIM |
GET MSISDN |
AT+CNUM |
Returns the phone number / MSISDN of the device |
Removing or adding SIM PIN via AT commands
EMnify SIMs come with the SIM PIN deactivated so they work in devices that do not have a screen or interface to enter the PIN (e.g. GPS tracker). Below you have examples on how to activate and re-activate the use of the SIM PIN.
The two commands used for managing SIM PIN are AT+CPIN and AT+CLCK.
To remove the check for the SIM PIN:
AT+CPIN? // check which PIN required
+CPIN=SIM PIN // response = SIM pin code required
AT+CPIN=1234 // enter current PIN
OK
AT+CLCK=”SC”,0,”1234″ // remove SIM PIN request at startup - reboot needed
OK
To add the check for SIM PIN:
AT+CPIN? // check if and which PIN required
+CPIN=Ready // no PIN required
AT+CLCK=”SC”,1,”1234″ // PIN activated
You find more information about the CPIN and CLCK command below.
Command | Commands and example | Parameters |
AT+CPIN |
AT+CPIN=<pin> Enter the PIN so that the SIM can be used Example: AT+CPIN="1234” |
<code> |
AT+CPIN? Response Format: |
||
AT+CLCK |
AT+CLCK=<fac>,<mode>,<passed>, <class> |
<fac> facility <mode> Defines the operation |
AT commands for network selection and configuration
While operator selection is often an automated procedure - there are some configurations that you can do to either enforce or prefer specific operators.
Command |
Commands and examples |
Parameters |
AT+COPS
|
AT+COPS=<mode>,<format>, <oper>,<AcT> |
<mode>: 0 - automatic (<oper> field is ignored) 1 - manual (<oper> field) 2 - deregister from network 3 - set only <format> for AT+COPS? 4 - manual/automatic (<oper> field shall be present); if manual selection fails, automatic mode (=0) is entered <format> 0 - long alphanumeric – e.g “Telekom.de” 1 – short alphanumeric e.g “TDG” 2 – numeric – e.g. “26201” <oper> desired operator in <format> <AcT> Access technology 0 - GSM 1 - GSM Compact 2 - UTRAN 3 - GSM w/EGPRS 4 - UTRAN w/HSDPA 5 - UTRAN w/HSUPA 6 - UTRAN w/HSDPA and HSUPA 7 - E-UTRAN 8 – LTE-M 9 - NB-IoT If no operator is selected <format>,<oper> <Act> are omitted. <stat> Operator status 0 - unknown 1 - available 2 - current 3 - forbidden |
AT+COPS? Response Format: |
||
AT+COPS=? Response Format: Example Response: |
||
AT+CPLS Preferred PLMN list file to be used
|
AT+CPLS=<list> Example: |
On the SIM there are file to manage operator and radio type preference. These can be set by the user, operator or home network. These files usually start with EFxxxx <list>: integer type |
AT+CPLS? |
||
AT+CPLS=? |
||
AT+CPOL
|
AT+CPOL=<index>,<format>,<oper>,<GSM_AcT>, <GSM_Compact_AcT>,<UTRAN_AcT>,<EUTRAN_AcT> Set preferred operator list on the SIM Config example: |
<index> order number of operator list. The first index indicates the highest priority and the nth index indicates the lowest <format>: 0 - long format alphanumeric <oper> 1 - short format alphanumeric <oper> 2 - numeric <oper> <oper> Operator in defined Format <format> For all parameters <GSM_AcTn>, <GSM_Compact_AcTn>, <UTRAN_AcTn>, <E-UTRAN_AcTn>: 0 - access technology not selected 1 - access technology selected |
AT+CPOL? |
||
AT+COPN
|
AT+COPN |
|
AT+CREG
|
The syntax for CREG, CGREG, CEGREG is the similar- here explained with AT+CREG |
<n> Report configuration <stat>: |
The syntax for CREG, CGREG, CEGREG is the similar- here explained with AT+CREG AT+CREG? |
||
AT+CREG =? Example Response |
AT commands for radio signal quality analysis
Command |
Commands and examples |
Parameters |
AT+CSQ Signal Quality Reports |
AT+CSQ Response Format: |
<rssi> received signal strength RSSI values <qual> For 2G – Bit Error rate ( ~assumed value) <qual> For 3G - EcNo <qual> For LTE/NB-IoT/LTE-M - RSRQ <rxlev> RSSI with 1dbm steps <ber> - Bit Error Rate as above for 2G <rscp> RSCP with 1dBm steps |
AT+CSQ=? Example Response |
||
AT+CESQ Extended signal quality |
AT+CESQ Response format: +CESQ:99,99,255,255,31,62 |
|
AT+CESQ=? Returns list of supported parameters value ranges <rxlev>,<ber>, <rscp>, ecno>, <rsrp>, <rsrq> Example Response: |
AT commands to establish a PDP context / data session
Command |
Commands and examples |
Parameters |
AT+ CGDCONT Define PDP context |
<AT+CGDCONT=<cid>,<PDP_type>,<APN>,<PDP_addr>,<data_comp>,<head_comp> |
<cid> PDP context identifier <PDP_addr> (IP) Address identifying the mobile terminal. EMnify assigns private static IPs - so 0.0.0.0 is fine <d_comp> - controls PDP data compression - for SNDCP 0 OFF <h_comp> - controls PDP header compression
|
AT+CGDCONT? Returns list of current PDP definitions Response Format: Example Response: |
||
AT+CGACT Activate and Deactivate PDP contexts |
AT+CGACT=<state>,<cid> |
<state>
|
AT+CGACT? |
Final Thoughts
These were some of the standard AT commands that all modems support. They let you configure and have control over your cellular communication. Many manufacturer-specific AT commands exist which let you optimize the communication. We will talk about these in another blog post.
Get in touch with our IoT experts
Discover how emnify can help you grow your business and talk to one of our IoT consultants today!
Constantin Ernst
Product Manager at EMnify.