🛠 Diagnostic AT et qualité de signal
Objectives
Troubleshoot a cellular link using AT commands on the SARA-R410M module: registration status (AT+CEREG?), radio quality (AT+CSQ), serving cell and technology (AT+QENG). The MKRGSM library exposes sendModemCommand to send raw AT commands without rewriting a UART driver. The modem is on a dedicated UART (SERCOM4: GSM_TX PA12, GSM_RX PA13, RTS/CTS PA14/PA15) whose flow control is not enabled by the core — hence truncated responses under heavy AT traffic.
Hardware
- 1 MKR NB 1500 board + antenna + data SIM
- Micro-USB cable + serial console
- MKRGSM library (AT probe commands are available in it)
Full code
// Diagnostic AT periodique — MKR NB 1500
#include <MKRGSM.h>
#include "arduino_secrets.h"
const char PINNUMBER[] = SECRET_PINNUMBER;
GSM gsm;
void setup {
Serial.begin(9600);
while (!Serial);
bool ok = false;
while (!ok) {
if (gsm.begin(PINNUMBER) == GSM_READY) ok = true;
else delay(3000);
}
}
void loop {
Serial.println(F("--- Diagnostic ---"));
Serial.println(F("Enregistrement :"));
gsm.sendModemCommand("AT+CEREG?", &Serial); // 0,1 = enregistre, 0,5 = en roaming
Serial.println(F("Qualite signal :"));
gsm.sendModemCommand("AT+CSQ", &Serial); // +CSQ: rssi,ber
Serial.println(F("Cellule/RAT :"));
gsm.sendModemCommand("AT+QENG=\"servingcell\"", &Serial);
delay(30000);
}
Expected verification
AT+CEREG? responds with +CEREG: 0,1 (registered) or 0,5 (roaming). AT+CSQ responds with +CSQ: 20,99: the first number is 0–31 (RSSI, dBm ≈ -113 + 2×CSQ, so 20 ≈ -73 dBm, excellent; < 10 ≈ -93 dBm, borderline), 99 = unknown. AT+QENG indicates the RAT (NB-IoT or LTE-M) and the band — verify that these are the expected ones.
Common errors
- Interpreting CSQ as a percentage: it is a logarithmic scale from 0–31; 99 means "no measurement", not "zero signal".
- Incomplete or corrupted AT responses: the modem's UART does not use RTS/CTS (open core bug); limit the volume of AT commands and add pauses.
- The module freezes after a software restart (forum thread "SARA Modem freezes when restarted"): prefer a clean shutdown (
shutdown) or cutting power over an AT restart. sendModemCommandwithout output stream: make sure to pass&Serialto see the responses.- In case of persistent failure, the historical reliability of MKRGSM is known (issue #66): cross-check with the MKRNB library before declaring the board dead.
Other tutorials for this board
Code examples for this board
attente-lte-nbiot.inoArduinochoix-bande.inoArduinopublish-mqtt-minimal.inoArduinoeconomie-energie.inoArduinogeoloc-cellules.inoArduinotest-coverage.inoArduino