🛠 Diagnostic AT du module et version de firmware

Arduino MKR GSM 1400 · avance · Schéma : IMG-mkr-gsm-1400-avance-3-mkrgsm-diagnostic-at.svg — Console série affichant des commandes AT envoyées au module SARA-U201 de la MKR GSM 1400 (AT+CSQ, AT+COPS?, AT+CGMR) avec leurs réponses, antenne à côté.

Objectives

Troubleshoot the cellular part at a low level: send AT commands to the u-blox SARA-U201 module to read signal strength, the registered operator, the module's firmware version, and check the SIM status. When MKRGSM fails in a loop without a clear message, the AT commands tell you everything: missing SIM, blocked PIN, network not found, rejected APN.

Hardware

Complete Code

#include <MKRGSM.h>
#include "arduino_secrets.h"
const char PINNUMBER[] = SECRET_PINNUMBER;

GSM gsmAccess;

void at(const char* cmd) {
  Serial.print(">> "); Serial.println(cmd);
  char rep[128] = {0};
  // sendTestRequest envoie la chaine brute au module et recupere la reponse.
  gsmAccess.sendTestRequest(cmd, rep, sizeof(rep));
  Serial.print("<< "); Serial.println(rep);
}

void setup {
  Serial.begin(9600);
  while (!Serial) {}

  at("AT");            // vie du module : doit repondre OK
  at("AT+CGMR");       // version du firmware du module
  at("AT+CPIN?");      // etat SIM : READY, SIM PIN, ou SIM NOT INSERTED
  at("AT+CSQ");        // signal : 0..31,99 ; 99 = aucun
  at("AT+COPS?");      // operateur enregistre et mode (0 = pas enregistre)
  at("AT+CGREG?");    // etat d'enregistrement GPRS
  at("AT+CGDCONT?");   // APN actif

  // Puis tentative normale de demarrage pour croiser les indices
  int r = gsmAccess.begin(PINNUMBER);
  Serial.print("gsmAccess.begin = "); Serial.println(r);
}

void loop {}

Expected Verification

AT responds OK; AT+CPIN? returns READY (otherwise: SIM poorly inserted, or PIN needs unlocking with AT+CPIN="1234"); AT+CSQ gives a reasonable value between 0-31 (99 = no antenna/no network); AT+COPS? displays the operator; AT+CGMR displays the firmware version of the SARA-U201, to be noted in your maintenance log. Cross-reference with the return code of begin: 1 = SIM not initialized, 2 = network not found, 3 = GPRS error (see MKRGSM).

Common Errors

Other tutorials for this board

Code examples for this board

← Back to the board 🛠 All tutorials