AT Command Network Debug
In IoT development, module network failures are among the most frustrating issues. Often, we see the failure but can't pinpoint where the process stopped. From power‑up to successful connection, there's a clear logical chain. Checking each step in order will pinpoint the issue. This article covers 6 key AT commands to help you systematically troubleshoot. 1. |
| Return Code | Meaning | Explanation |
|---|---|---|
READY | Ready | SIM identified and unlocked – ideal state |
SIM PIN | PIN required | Use AT+CPIN="1234" to unlock |
SIM PUK | PUK required | PIN entered incorrectly 3 times – use PUK to reset |
SIM NOT INSERTED | No SIM detected | Check hardware contact, slot, or try another SIM |
SIM WRONG | SIM error | Card damaged or voltage mismatch (1.8V/3V) |
Debug: If the return is READY, proceed to the next step.
AT+CSQ – Signal StrengthPurpose: Queries the Received Signal Strength Indicator (RSSI) and Bit Error Rate (BER) to check physical layer quality.
Send:
AT+CSQExample return:
+CSQ: 20,99RSSI value conversion & meaning:
| RSSI | Signal Strength (dBm) | Explanation |
|---|---|---|
| 0 | ≤ -113 | Very weak, cannot register |
| 10 | -93 | Average, usable |
| 20 | -73 | Good |
| 31 | ≥ -51 | Excellent |
| 99 | N/A | No signal |
For 4G/NB‑IoT modules, BER (Bit Error Rate) usually returns
99as not applicable.
Debug: RSSI should be above 10. If you see 99,99, check the antenna and location.
AT+CREG? / AT+CEREG? – Network Registration StatusPurpose: Checks if the module has successfully registered with the carrier's network. Use AT+CEREG? (4G/LTE/NB‑IoT) as the primary command, as AT+CREG? is for 2G/GSM.
Send (for 4G):
AT+CEREG?Common returns & meanings:
| Status Code | Meaning | Explanation |
|---|---|---|
| 0 | Not registered | Searching or no signal |
| 1 | Registered (home) | Normal, can communicate |
| 2 | Searching | Check again after a few seconds |
| 3 | Registration denied | SIM invalid, overdue, or IMEI blacklisted |
| 5 | Registered (roaming) | Normal |
| 6 | Emergency only | Cannot access data; check SIM or APN |
Debug: Proceed only when status is 1 or 5. If 3, check SIM status; if 6, verify data services are enabled.
AT+CGATT? – GPRS/PS Domain AttachmentPurpose: Checks if the module has attached to the data core network. If CEREG is "connected to the tower," CGATT means "authorized for data."
Send:
AT+CGATT?Return & meaning:
| Value | Meaning |
|---|---|
| 0 | Detached – cannot access data |
| 1 | Attached – data channel can be established |
Debug: If it returns 0, confirm CEREG status is 1 or 5. You can manually attach with AT+CGATT=1.
AT+CGACT? – PDP Context ActivationPurpose: Checks if a PDP context is active. This is the final step. Only when activated does the module obtain an IP address and enable TCP/UDP communication.
Send:
AT+CGACT?Example return:
+CGACT: 1,1The first number is the Context ID (usually 1), the second is the state.
State meaning:
| State | Meaning |
|---|---|
| 0 | Inactive – no IP address |
| 1 | Active – ready to communicate |
Debug: If status is 0, follow this sequence:
Check attachment: Ensure AT+CGATT? returns 1.
Set APN: AT+CGDCONT=1,"IP","cmnet" (example for China Mobile).
Activate context: AT+CGACT=1,1.
Verify: Run AT+CGACT? again. Use AT+CGPADDR=1 to see the assigned IP.
Follow these commands in order. Each step is a prerequisite for the next:
Rule of thumb: Follow this order: Card → Signal → Network → Attach → Session. Skip none.
| Symptom | Possible Cause | Check Sequence |
|---|---|---|
CPIN returns SIM NOT INSERTED | Card not inserted, bad contact, or damaged | Hardware check > Replace SIM |
CSQ returns 99,99 | No signal, antenna not connected | Check antenna > Change location |
CEREG returns 0,3 or 0,6 | SIM invalid, overdue, or no data plan | Check CPIN > Check APN > Contact operator |
CGATT returns 0 | Not attached to data domain | Check CEREG > Manual CGATT=1 |
CGACT returns 0 | PDP context not active | Check CGATT > Set APN > Activate context |
Master these six AT commands, and you'll have a universal method for diagnosing cellular module connectivity issues, regardless of the module brand or model (4G/NB‑IoT). Next time your module won't connect, use this checklist!