Get the Most of Your Modem with AT Commands

AT Commands, Code, Binary, Image By Adobe Stock
General disclaimer: AT command support differs widely by device and manufacturer, and these commands may not be appropriate for your specific device. Soracom always recommends consulting your device’s manual to ensure commands are supported and that their parameters are being used correctly. A list of standardized AT commands from 3GPP can be found here If you require support using AT commands with your Soracom-enabled device please contact our support team for assistance.

When developing or testing cellular hardware, engineers are often faced with software or firmware that limits their ability to directly interact with the modem to achieve the desired functionality. How can the same level of granular control offered by something like the BASH or Command shells be implemented in our cellular application? The solution is Attention commands.

Attention commands, more commonly known as AT commands, allow users to control and modify modem behavior at the lowest possible level and are how most software applications interact with cellular hardware under the hood. These commands range in functionality and complexity, from simple commands to check if a modem is responsive, to configuring the device Access Point Name or PLMN lists, and more.

While many technical users may be comfortable with the command line, the prospect of learning a brand new vocabulary of commands can be daunting  – especially as these commands can differ from module to module. But not to fear, in this article, we will go over some of the most valuable AT commands as a primer to kickstart your learning in the world of cellular hardware.

How to Send AT Commands

AT commands are generally sent via the serial interface of the modem. Instructions for accessing the serial interface of embedded modules can usually be found in the manual for the device. USB modules, meanwhile, generally have their interfaces accessed using screen on Linux devices, or with serial port terminals like CoolTerm on Windows. If an AT command is sent successfully it will always reply with either the output of the command, OK, or an error. 

Programmer, Coder, Developer, IoT, AT Commands, Image by Adobe Stock

Turning on the Modem

After connecting to your modem’s serial port, you can verify your modem is listening by sending ATI, which will return some basic information about the modem and its status.

After verifying the modem is listening, the command AT+CFUN=1 can be used to enable its full functionality. At this point, if a modem is capable of communication using multiple Radio Access Technologies (RATs), which RATs to use can be manually defined. Unfortunately, there is no standard 3GPP AT Command for this functionality and the device manual will have to be consulted to determine which command is appropriate to use. For example, SimCom devices use the commands AT+CNMP=. Some common values for this command include AT+CNMP=2 for Automatic selection, AT+CNMP=14 for 3G W-CDMA, or AT+CNMP=38 for LTE. If you are uncertain which value to use in this command, consult your device’s manual for more information on available RATs.

Configuring the APN

Although LTE devices are capable of automatically retrieving APN information from the network, this process does not always succeed,  2G/3G devices, meanwhile, will always need their APN specified manually. While most devices will have a way to easily set the APN via a GUI or SMS, it may be necessary to use AT commands to define it.

When using AT commands, there are two parts to defining an APN; specifying the PDP context, and defining authentication credentials for that context (if required). Using Soracom’s APN as an example, we would first define the PDP context using AT+CGDCONT=1,IP, As most devices allow for saving multiple PDP contexts, this command specifies slot 1 to be used. Because there are occasionally issues with using an APN not stored in context slot 1, Soracom always recommends saving your primary APN in that slot.

After defining the PDP context, authentication credentials for that context can be saved using AT+CGAUTH=1,1,"sora","sora". Here 1,1 indicates that these credentials are for PDP context 1, and that PAP authentication should be used for that context. These values can be changed to apply the credentials to an alternative slot or modify what form of authentication is being used. For more details on these parameters please consult your device’s manual.

Once these parameters have been defined, it is possible to check that the PDP context is active using the AT+CGACT? command. Ideally, this will return +CGACT 1,1 where 1,1 indicates that the PDP context in slot 1 is being used, and is currently active. If for some reason the saved PDP context is not active, it can be activated using AT+CGACT=1,1 where 1,1 again defines that we would like to use the PDP context stored in slot 1 and set it to active.

network map of north america

Connecting to a Network

The next step is to get our modem connected to a network using the AT+COPS series of commands. While most modems will automatically perform a network search upon initiation, a manual network search can be performed using AT+COPS=?. This complete network search may take several minutes to complete, especially if the device has a wide range of compatible bands. After the scan is complete, a list of available networks, their MCC and MNC values, and the RAT used for connection will be displayed. An example return may look like +COPS: (2,"AT&T","AT&T","310410",7),(1,"T-MOBILE","TMO","310260",0) showing that the Modem discovered both an E-UTRAN (LTE) connection to AT&T, as well as a GSM (3G) connection to T-Mobile. To determine what RAT the final digit represents please consult the device’s manual. A modem might occasionally appear to duplicate a certain carrier in its results. This is often due to network operators using multiple MNC numbers for their service.

After determining that our modem has visibility to the network to which we want to connect, we can use AT+COPS again to instruct the modem to connect manually. For example, if we wanted to connect to AT&T, we could use the command AT+COPS=1,2,"310410". In most cases, this command format will stay the same across devices. This means that 1,2 will typically indicate that we would like to manually select our operator and we will be using the MCC and MNC to define which operator that is. This is then followed by 310410; the MCC of the United States and the MNC of AT&T. A full list of global MCCs and MNCs can be found here.

It’s important to note that almost all modems’ manual network selection will persist through power cycles. In order to return the modem to automatic network selection use AT+COPS=0. When using a roaming SIM card, like those available from Soracom, it is recommended to leave the device in automatic operator selection mode whenever possible to take full advantage of the multi-carrier redundancy available.

Checking Registration Status

Following our manual network selection, the connection status of the modem to various cores of the cellular network can be determined. For example, to determine the connection status of the modem to the 2G Circuit Switch network, we would use the command AT+CREG?. in the case of a successful connection with a roaming SIM card, this should report back +CREG: 0,5.

The commands to investigate the connection to each specific core of the network are as follows:

  • 2G (Circuit Switch mode) – AT+CREG?
  • 2G/3G (Packet Switch mode) – AT+CGREG?
  • 4G (LTE mode) – AT+CEREG?

The second digit of the response to these commands is important, as it indicates the status of the connection. Possible values are:

  • 0 – Not registered. The modem is not currently searching for a new operator 
  • 1 – Registered, home network 
  • 2 – Not registered, but the modem is currently searching for a new operator to register to 
  • 3 – Registration denied 
  • 4 – Unknown 
  • 5 – Registered, roaming
Signal Strength, Radio Waves, Ripple, Image by Adobe Stock

Checking Signal Strength

After ensuring that a device has properly registered to the necessary cores of the cellular network, it may be necessary to check the signal strength of that connection. Signal strength checks are most commonly performed using AT+CSQ. This command is particularly useful in troubleshooting connectivity issues on a device. 

The supported return values of this command can first be determined using AT+CSQ=?, which will return the supported Received Signal Strength Indicator (RSSI) values and Bit Error Rate (BER) values for the device, respectively, like so: +CSQ: (0-31,99),(0-7,99). When using AT+CSQ to determine signal strength, an RSSI value of less than 10 is generally accepted as being a weak signal, which could result in connectivity issues. For more information on signal strength values, please consult this article on the subject from Soracom’s partner Teltonika.

AT+CSQ may also report 99 for unknown signal strength, or a CME error such as +CME 17. A key for these CME errors can usually be found in the manual of the device, which can help determine the root cause of an issue in the troubleshooting process.


We have now explored all the necessary AT commands required to establish an initial connection to the cellular network on most devices. The Soracom team hopes that this guide has removed some of the mystique around this unique messaging system, and look forward to seeing what solutions you create with them!