🛠 Diagnostic AT et qualité de signal

Arduino MKR NB 1500 · avance · Schéma : IMG-mkr-nb-1500-avance-3-mkrnb-diagnostic-at.svg — Console série affichant les réponses AT+CSQ, AT+CEREG? et AT+QENG d'une MKR NB 1500, avec échelle de conversion RSSI en dBm à droite

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

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

Other tutorials for this board

Code examples for this board

← Back to the board 🛠 All tutorials