# AT Commands

AT Commands (abbreviated from Attention Commands) are the way to control cellular modems. It provides a standardized way to instruct modems on how to behave and where to connect to.

Even though the commands are standardized by the 3GPP, different modems adhere to different versions of the specifications and manufacturers may provide additional vendor-specific AT Commands. **Hence we recommend to keep the AT Commands manual of your modem manufacturer close when configuring your cellular modem.**

### AT Commands Basics

AT Commands usually start with <mark style="color:red;">`AT`</mark>, followed by a <mark style="color:red;">`<command>`</mark> and in some cases a <mark style="color:red;">`<value>`</mark>.

There are 4 types of AT Commands: **Set**, **Read**, **Test** and **Execute**.

* **Set** <mark style="color:red;">`AT+<command>=<value>`</mark>\
  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: <mark style="color:red;">`AT+CFUN=1`</mark>
* **Read** <mark style="color:red;">`AT+<command>?`</mark>\
  Check the current configuration settings of the cellular modem. For example to read the network and cellular technology the modem is using, enter: <mark style="color:red;">`AT+COPS?`</mark>
* **Test** <mark style="color:red;">`AT+<command>=?`</mark>\
  Test the possible input values for specific commands. For example to list the available modes of operations modem, enter: <mark style="color:red;">`AT+CFUN=?`</mark>
* **Execute** <mark style="color:red;">`AT+<x>`</mark>\
  Some commands can be simply executed. For example, the command to check and return the signal quality: <mark style="color:red;">`AT+CSQ`</mark>

{% hint style="info" %}
Pro 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 <mark style="color:red;">`;`</mark>, only write <mark style="color:red;">`AT`</mark> at the start of the first command.&#x20;

For examples: <mark style="color:red;">`AT+CMEE=2;+CPIN?;+CIMI`</mark>
{% endhint %}

### **How to Identify the AT Commands Supported by Your Modem**

Most modems provide a comprehensive **AT Command Reference Guide** that outlines all supported commands and their usage. This document is typically available from the manufacturer's website or included in the modem's documentation.

Additionally, many modems support a built-in command that lists all available AT commands directly from the device. To retrieve this list, you can use the following command:

<mark style="color:red;">`AT+CLAC`</mark>\
This command will return a list of supported AT commands, helping you quickly understand the modem's capabilities without referring to external documentation.

### 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&#x20;**<mark style="color:red;">**`AT`**</mark>**. When the modem responds with&#x20;**<mark style="color:red;">**`OK`**</mark>**&#x20;you're set.**

### Before you get start started

{% hint style="warning" %}
Not all modems support the AT Commands listed in the examples in this page. For details, ***always*** check the AT Command manual of your specific cellular modem.
{% endhint %}

Before starting the configuration process, **reset the modem** to its default configuration and activate the modem:

| AT Command | <mark style="color:red;">`AT+CFUN=1,1`</mark> |
| ---------- | --------------------------------------------- |
| Response   | <mark style="color:red;">`OK`</mark>          |

Set the error reporting to **verbose**, resulting in more descriptive error messages:

<table data-header-hidden><thead><tr><th width="200"></th><th></th></tr></thead><tbody><tr><td>AT Command</td><td><mark style="color:red;"><code>AT+CMEE=2</code></mark></td></tr><tr><td>Response</td><td><mark style="color:red;"><code>OK</code></mark></td></tr></tbody></table>

Check the **status of the SIM card**. If you receive an error, the SIM may not be inserted well, or the SIM is locked with a PIN. By default, Monogoto SIMs are not PIN protected.

<table data-header-hidden><thead><tr><th width="200"></th><th></th></tr></thead><tbody><tr><td>AT Command</td><td><mark style="color:red;"><code>AT+CPIN?</code></mark></td></tr><tr><td>Expected response</td><td><p><mark style="color:red;"><code>+CPIN: READY</code></mark></p><p><mark style="color:red;"><code>OK</code></mark></p></td></tr></tbody></table>

### Query device information

Request the modem **hardware version**

<table data-header-hidden><thead><tr><th width="200"></th><th></th></tr></thead><tbody><tr><td>AT Command</td><td><mark style="color:red;"><code>AT+CGMM</code></mark></td></tr><tr><td>Example response</td><td><p><mark style="color:red;"><code>SARA-R412M-02B</code></mark></p><p><mark style="color:red;"><code>OK</code></mark></p></td></tr></tbody></table>

Request the modem **firmware version**

<table data-header-hidden><thead><tr><th width="200"></th><th></th></tr></thead><tbody><tr><td>AT Command</td><td><mark style="color:red;"><code>AT+CGMR</code></mark></td></tr><tr><td>Example response</td><td><p><mark style="color:red;"><code>M0.12.00 [Dec 01 2030 12:00:00]</code></mark></p><p><mark style="color:red;"><code>OK</code></mark></p></td></tr></tbody></table>

{% hint style="warning" %}
Make sure you run the latest modem firmware version possible. Compare the response with the latest version published by your modem manufacturer.
{% endhint %}

Request the **IMSI** (International Mobile Subscriber Identity):

| AT Command       | <mark style="color:red;">`AT+CIMI`</mark>                                                                                 |
| ---------------- | ------------------------------------------------------------------------------------------------------------------------- |
| Example response | <p><mark style="color:red;"><code>XXXXXXXXXXXXXXX</code></mark></p><p><mark style="color:red;"><code>OK</code></mark></p> |

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

| AT Command       | <mark style="color:red;">`AT+CCID`</mark>                                                                                             |
| ---------------- | ------------------------------------------------------------------------------------------------------------------------------------- |
| Example response | <p><mark style="color:red;"><code>+CCID: XXXXXXXXXXXXXXXXXXXX</code></mark></p><p><mark style="color:red;"><code>OK</code></mark></p> |

### Network provider and cellular technology settings

The AT Command related to the Network Provider and cellular technology: <mark style="color:red;">`AT+COPS`</mark>

Syntax: <mark style="color:red;">`AT+COPS=<mode>,<format>,<oper>,<AcT>`</mark>

<table data-header-hidden><thead><tr><th width="150"></th><th width="596.4285714285713"></th></tr></thead><tbody><tr><td><mark style="color:red;"><code>mode</code></mark></td><td>Network Selection Mode. Use <mark style="color:red;"><code>0</code></mark> for automatic, <mark style="color:red;"><code>1</code></mark> for manual</td></tr><tr><td><mark style="color:red;"><code>format</code></mark></td><td><mark style="color:red;"><code>0</code></mark> for long alphanumeric <em>(e.g. vodafone NL)</em>, <mark style="color:red;"><code>1</code></mark> for short alphanumeric <em>(e.g. voda NL)</em>, <mark style="color:red;"><code>2</code></mark> for numeric/MCCMNC codes <em>(e.g. 20404)</em></td></tr><tr><td><mark style="color:red;"><code>oper</code></mark></td><td>Operator, to be defined as long alphanumeric, short alphanumeric or numeric</td></tr><tr><td><mark style="color:red;"><code>AcT</code></mark></td><td><p>Access Technology. It depends on the modem which value represent which technology, usually the values are: </p><p><mark style="color:red;"><code>0</code></mark> for GSM, <mark style="color:red;"><code>3</code></mark> for GSM/GPRS/EDGE, <mark style="color:red;"><code>7</code></mark> for LTE/LTE Cat-M1, <mark style="color:red;"><code>9</code></mark> for NB-IoT</p></td></tr></tbody></table>

**Read** the operator and access technology:

| AT Command       | <mark style="color:red;">`AT+COPS?`</mark>                                                                                           |
| ---------------- | ------------------------------------------------------------------------------------------------------------------------------------ |
| Example response | <p><mark style="color:red;"><code>+COPS: 0,0,"vodafone NL",7</code></mark></p><p><mark style="color:red;"><code>OK</code></mark></p> |

The **test** command lets the modem perform a network scan:

<table data-header-hidden><thead><tr><th width="168.34974384025307"></th><th width="548.0503465888362"></th></tr></thead><tbody><tr><td>AT Command</td><td><mark style="color:red;"><code>AT+COPS=?</code></mark></td></tr><tr><td>Example response</td><td><p><mark style="color:red;"><code>+COPS: (1,"NL KPN","NL KPN","20408",7),(1,"vodafone NL","voda NL","20404",0),(1,"T-Mobile NL","TMO NL","20416",0),(1,"T-Mobile NL","TMO NL","20416",7),(1,"vodafone NL","voda NL","20404",7),(1,"NL KPN","NL KPN","20408",0),,(0,1,2,3,4),(0,1,2)</code></mark></p><p><mark style="color:red;"><code>OK</code></mark></p></td></tr></tbody></table>

{% hint style="warning" %}
Be patient, it may take several minutes before the modem responds, you cannot send any AT Commands in the meantime.
{% endhint %}

**Set** the network and technology parameters

| Automatic operator and AcT selection:               | <mark style="color:red;">`AT+COPS=0`</mark>                                                                                                                       |
| --------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Automatic operator and manual AcT selection:        | <p><mark style="color:red;"><code>AT+COPS=0,0,\<AcT></code></mark><br>Example: <mark style="color:red;"><code>AT+COPS=0,0,7</code></mark></p>                     |
| Manual operator selection, automatic AcT selection: | <p><mark style="color:red;"><code>T+COPS=1,2,\<MMCMNC></code></mark><br>Example: <mark style="color:red;"><code>AT+COPS=1,2,"20404"</code></mark></p>             |
| Manual operator and AcT selection:                  | <p><mark style="color:red;"><code>AT+COPS=1,2,"\<MMCMNC>",\<AcT></code></mark><br>Example: <mark style="color:red;"><code>AT+COPS=1,2,"20404",7</code></mark></p> |
| Response                                            | <mark style="color:red;">`OK`</mark>                                                                                                                              |

{% hint style="info" %}
To find which of the networks Monogoto has **roaming agreements** with, review the [**Coverage lists**](https://docs.monogoto.io/getting-started/coverage-lists).​
{% endhint %}

### **Check the radio signal strength and signal quality:** <a href="#check-the-radio-signal-strength-and-signal-quality" id="check-the-radio-signal-strength-and-signal-quality"></a>

| AT Command       | <mark style="color:red;">`AT+CSQ`</mark>                                                                             |
| ---------------- | -------------------------------------------------------------------------------------------------------------------- |
| Example response | <p><mark style="color:red;"><code>+CSQ: 25,5</code></mark></p><p><mark style="color:red;"><code>OK</code></mark></p> |

<mark style="color:red;">`+CSQ`</mark> 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 <mark style="color:red;">`AT+CSQ`</mark> returns <mark style="color:red;">`99`</mark>, the signal is undetectable or unknown.

### Network Configuration

#### **Set the APN to** `data.mono`:

| AT Command | <mark style="color:red;">`AT+CGDCONT=1,"IP","data.mono"`</mark> |
| ---------- | --------------------------------------------------------------- |
| Response   | <mark style="color:red;">`OK`</mark>                            |

**Read** the APN configuration:

| AT Command        | <mark style="color:red;">`AT+CGDCONT?`</mark>                                        |
| ----------------- | ------------------------------------------------------------------------------------ |
| Expected response | <mark style="color:red;">`+CGDCONT: 1,"IP","data.mono","0.0.0.0",0,0,0,0,0,0`</mark> |

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

| AT Command | <mark style="color:red;">`AT+CGACT=1,1`</mark> |
| ---------- | ---------------------------------------------- |
| Response   | <mark style="color:red;">`OK`</mark>           |

**Read** if the PDP context is set correctly:

| AT Command        | <mark style="color:red;">`AT+CGACT?`</mark>                                                                           |
| ----------------- | --------------------------------------------------------------------------------------------------------------------- |
| Expected response | <p><mark style="color:red;"><code>+CGACT: 1,1</code></mark></p><p><mark style="color:red;"><code>OK</code></mark></p> |

#### **Read network status**: <a href="#validate-if-your-device-received-an-ip-address" id="validate-if-your-device-received-an-ip-address"></a>

| AT Command        | <mark style="color:red;">`AT+CEREG?`</mark>                                                                           |
| ----------------- | --------------------------------------------------------------------------------------------------------------------- |
| Expected response | <p><mark style="color:red;"><code>+CEREG: 0,5</code></mark></p><p><mark style="color:red;"><code>OK</code></mark></p> |

The second variable indicates the status:\ <mark style="color:red;">`0`</mark>: Not registered\ <mark style="color:red;">`1`</mark>: Registered, home network \ <mark style="color:red;">`2`</mark>: Not registered, but the modem is trying to connect \ <mark style="color:red;">`3`</mark>: Registration denied \ <mark style="color:red;">`4`</mark>: Unknown (for example, out of coverage) \ <mark style="color:red;">`5`</mark>: Registered, roaming\ <mark style="color:red;">`90`</mark>: Not registered due to UICC failure

### **Check the the FPLMN:** <a href="#check-the-radio-signal-strength-and-signal-quality" id="check-the-radio-signal-strength-and-signal-quality"></a>

<table data-header-hidden><thead><tr><th width="217"></th><th></th></tr></thead><tbody><tr><td>AT Command</td><td><mark style="color:red;"><code>AT+CRSM=176,28539,0,0,12</code></mark></td></tr><tr><td>Example response</td><td><p><mark style="color:red;"><code>AT+CRSM=214,28539,0,0,12,"24F58024F51024F530FFFFFF"</code></mark></p><p><mark style="color:red;"><code>OK</code></mark></p></td></tr></tbody></table>

We are instructing the SIM to retrieve the data file <mark style="color:red;">28539</mark> in binary format. If we receive a string of 24 "F"s, it indicates that the FPLMN list is empty, which is the desired outcome. If the result contains anything other than 24 "F"s, it means that there is data written in the FPLMN

### **Clear the FPLMN:** <a href="#check-the-radio-signal-strength-and-signal-quality" id="check-the-radio-signal-strength-and-signal-quality"></a>

<table data-header-hidden><thead><tr><th width="217"></th><th></th></tr></thead><tbody><tr><td>AT Command</td><td><mark style="color:red;"><code>AT+CRSM=214,28539,0,0,12,"FFFFFFFFFFFFFFFFFFFFFFFF"</code></mark></td></tr><tr><td>Example response</td><td><mark style="color:red;"><code>OK</code></mark></td></tr></tbody></table>

#### Validate if your device received an **IP address**: <a href="#validate-if-your-device-received-an-ip-address" id="validate-if-your-device-received-an-ip-address"></a>

| AT Command       | <mark style="color:red;">`AT+CGPADDR`</mark>                                                                                        |
| ---------------- | ----------------------------------------------------------------------------------------------------------------------------------- |
| Example response | <p><mark style="color:red;"><code>+CGPADDR: 1,10.XXX.XX.XXX</code></mark></p><p><mark style="color:red;"><code>OK</code></mark></p> |

{% hint style="success" %}
Do you see an IP address? **Congratulations!** 🎉 **You’ve successfully connected your cellular modem to Monogoto.** Have a look at the **Things** logs in the [**Monogoto Console**](https://console.monogoto.io/) to find more details about the established connection.
{% endhint %}
