AT+ Commands

Example of a Quectel BG95 cellular modem module

Introduction to AT Commands


AT commands (short for Attention Commands) are a way to interact and control cellular modems. It provides a standard way to instruct modems on how to behave and where to connect to.

Commands are standardized by the 3GPP. However, different modems adhere to different versions of the specifications and manufacturers often provide additional vendor specific AT commands.

It is therefore recommended to find the AT commands manual from your modem manufacturer so you can configure your specific cellular modem.

AT command basics


AT commands usually start with an AT, followed by the required <command> and sometimes a <value>.

The are 4 types of AT commands: Read, Test, Set and Execute:

  • Read AT+<command>?
    Check the current configuration settings of the cellular modem. For example to read the network and cellular technology the modem is using, enter: AT+CSQ?

  • Test AT+<command>=?
    Test the possible input values for specific commands. For example to list the available modes of operations modem, enter: AT+CFUN=?

  • Set AT+<command>=<value>
    Instruct the modem to perform an action, such as activating the modem or enabling roaming.
    For example, the command to set the modem to active is: AT+CFUN=1

  • Execute AT+<x>
    Some commands can be simply executed. For example, the command to check and return the signal quality: AT+CSQ

💡
Advanced tip: It is possible to send multiple AT Commands to the modem at the same time. To do so, list the commands in one line separated by a semi column ;, only write AT at the start of the first command. For examples: AT+CMEE=2;+CPIN?;+CIMI

Connect to the modem


In order to send AT Commands, you need to connect to the modem first. You may need a program which provides the interface between your computer and the modem.

You can use minicom, screen or miniterm for Linux/MacOS or PuTTY for Windows.

When using Windows, you might need to install a driver to establish a connection. Have a look at the modem manufacturer's website for details about a possible driver.

To test if the connection with the cellular modem has been established, enter AT. When the modem responds with OK you're set.

Before you get start started

💡
Not all modems support the AT commands listed in this post. It is always recommended to check the AT Command manual of your specific cellular modem.


You need to reset the modem to its default configuration and activate the modem before starting the configuration process:

AT Command Response
AT+CFUN=1,1 OK


Set the error reporting to verbose which allows more descriptive error messages:

AT Command Response
AT+CMEE=2 OK


Check the status of the SIM card. If you receive an error, the SIM may not be inserted properly or the SIM might be locked with a PIN. Note: a lot of SIMs are not PIN protected by default:

AT Command Response
AT+CPIN? +CPIN: READY
OK


Query device information


Request the modem hardware version:

AT Command Response
AT+CGMM Quectel_BC95-GV
OK


Request the modem firmware version:

AT Command Response
AT+CGMR +SEBoot,V100R001C00SPC052
PROTOCOL,V100R001C00SPC052
APPLICATION,V100R001C00SPC052
SEMain,V100R001C00SPC052
RADIO,RF_020219_202211101224
OK

💡
It is usually best to run the latest modem firmware version available. Compare the previous response with the latest version published by the modem manufacturer.


Request the IMSI (International Mobile Subscriber Identity):

AT Command Response
AT+CGMM Quectel_BC95-GV
OK

Request the ICCID (Integrated Circuit Card ID), which is the identification number of the SIM card:

AT Command Response
AT+CGMM Quectel_BC95-GV
OK


Network provider and cellular technology settings


The AT Command related to the Network Provider and cellular technology: AT+COPS

Syntax: AT+COPS=<mode>,<format>,<oper>,<AcT>

Read the operator and access technology:

Parameter Description
mode Network Selection Mode. Use 0 for automatic, 1 for manual
format 0 for long alphanumeric (e.g. vodafone NL), 1 for short alphanumeric (e.g. voda NL), 2 for numeric/MCCMNC codes (e.g. 50501)
oper Operator, to be defined as long alphanumeric, short alphanumeric or numeric
AcT Access Technology. It depends which technology your modem is using, usually the values are: 0 for GSM, 3 for GSM/GPRS/EDGE, 7 for LTE/LTE Cat-M1, 9 for NB-IoT

The test command lets the modem perform a network scan:

AT Command Response
AT+COPS=? +COPS: (0,2,"50501"),(0,2,"50502"),(0,2,"50503")
💡
Be patient, it may take several minutes before the modem responds, you cannot send any AT Commands in the meantime.

In Australia, the following PLMN (public land-mobile network),
codes represent the telecommunication carriers:

Code Carrier APN
50501 Telstra telstra.nbiot
telstra.m2m
50502 Optus ?
50503 Vodafone vodafone.nbiot


Check the modem signal strength and signal quality


Request the modem hardware version:

AT Command Response
AT+CSQ +CSQ: 14,99
OK

+CSQ returns 2 values separated by a comma. The first value represents the signal strength and provides a value between 0 and 31; higher numbers indicate better signal strength. The second value represents the signal quality indicated by a value between 0 and 7. If AT+CSQ returns 99, the signal is undetectable or unknown.
Note: In my experience in Australia, the second digit always returns 99 regardless of the connection.


Network Configuration


Set the APN to telstra.nbiot

AT Command Response
AT+CGDCONT=1,"IP","telstra.nbiot" OK


Read the APN configuration:

AT Command Response
AT+CGDCONT? +CGDCONT:1,"IPV4V6","vodafone.nbiot",,,0,,,,,0,0
OK


Set the PDP (packet data protocol) context to active:

AT Command Response
AT+CGACT=1,1 OK


Read the APN configuration:

AT Command Response
AT+CGACT? +CGACT: 1,1
OK


Read Network registration status:

AT Command Response
AT+CGREG? +CEREG: 0,5
OK

The second variable indicates the registraion status:
0: Not registered
1: Registered, home network
2: Not registered, but the modem is trying to connect
3: Registration denied
4: Unknown (for example, out of coverage)
5: Registered, roaming
90: Not registered due to UICC failure