console-at.sh

Arduino MKR GSM 1400 · File : console-at.sh · Language : Bash · Use case : Dialoguer en AT avec le modem depuis un terminal Linux

When the Arduino sketch looks guilty, talk straight to the MKR GSM 1400 u-blox modem: this Bash script fires a volley of classic AT commands and prints the replies. Ideal to check SIM, network registration and signal before coding.

Hardware

An Arduino MKR GSM 1400 (SAMD21 microcontroller, 2G/GPRS cellular modem, external antenna, powered by a LiPo battery on the J6 connector or over USB). A Linux box (or WSL), socat/stty, and TTL access to the modem serial port (3.3 V USB-TTL cable on the modem RX/TX pins).

Wiring

Cross TX/RX between the 3.3 V USB-serial adapter and the modem, common ground; the modem is 3.3 V logic, never RS-232.

How it works

stty sets the port raw at 115200 baud; the at() function writes a command then reads 5 s of reply with timeout. AT+CREG/CSQ/COPS/CPIN cover network and SIM diagnostics.

Running it

In the Arduino IDE, install the Arduino SAMD Boards package, select the MKR GSM 1400 board, then upload. Network examples assume an active data SIM is inserted, the antenna is screwed on, and 2G coverage still exists in your area.

Variants

Replace at() with a real interactive terminal (socat -, raw, echo, icrnl $PORT), or log every reply to a file for remote diagnosis.

console-at.sh

#!/usr/bin/env bash
# Console AT vers le modem du MKR GSM 1400 (mode bootloader/firmware AT).
# Le modem u-blox est accessible sur le port serie 1 (115200 bauds)
# quand le SAMD21 est en mode bootstrap, ou via un shield TTL.
# Usage : ./console-at.sh /dev/ttyUSB0
set -euo pipefail

PORT="${1:-/dev/ttyUSB0}"
VITESSE=115200

command -v socat >/dev/null || { echo "installez socat (apt install socat)"; exit 1; }
stty -F "$PORT" $VITESSE raw -echo

at() {
  printf '%s\r\n' "$1" > "$PORT"
  timeout 5 cat "$PORT" | head -n 20
}

echo "== Identite =="
at "AT"
at "AT+GMR"        # versions firmware
at "AT+CGMI"       # fabricant
echo "== Reseau =="
at "AT+CREG?"       # enregistrement 2G (0,1 = ok)
at "AT+CSQ"         # qualite signal (RSSI,BER)
at "AT+COPS?"       # operateur
echo "== SIM =="
at "AT+CPIN?"       # etat du code PIN
echo "Termine."

← Back to the board