Send AT commands to cellular module

Find the AT command port of a cellular module on Linux and send AT commands with Minicom or Sixfab’s ATCom command-line tool.

AT commands configure and query a cellular module from the host computer; each module manufacturer publishes the command set of its modules. Any serial terminal works with the right port and settings: 115200 baud, 8N1.

Requirements

Set up the board first with its quickstart: Get started with Base HAT, Get started with Cellular IoT Kit, Get started with 4G/LTE Cellular Modem Kit or Get started with Jetson Nano Cellular Modem Kit.

Required

Hardware

Software

  • LinuxFor example Raspberry Pi OS.

Find AT command port

  1. List USB serial ports

    The module appears as several USB serial ports. Run the command before and after you connect the USB cable; the new ports belong to the module:

    ls /dev/ttyUSB*
    /dev/ttyUSB0  /dev/ttyUSB1  /dev/ttyUSB2  /dev/ttyUSB3

    The kernel log shows the same ports as they are created:

    dmesg | grep ttyUSB
    [   35.807711] usb 1-1.1: GSM modem (1-port) converter now attached to ttyUSB0
    [   35.808358] usb 1-1.1: GSM modem (1-port) converter now attached to ttyUSB1
    [   35.808916] usb 1-1.1: GSM modem (1-port) converter now attached to ttyUSB2
    [   35.810673] usb 1-1.1: GSM modem (1-port) converter now attached to ttyUSB3
  2. Pick AT port of module

    ModuleAT command port
    Quectel EC25, EG25-G, BG96/dev/ttyUSB2 (ttyUSB0 DIAG, ttyUSB1 GNSS, ttyUSB3 modem)
    Telit ME910C1-WWUsually /dev/ttyUSB2
    Telit LE910C1, LE910C4/dev/ttyUSB2 in the Sixfab guides; the number of ports changes with the USB configuration (AT#USBCFG)

    If another USB serial device is connected, the numbers shift. The port that answers AT with OK is the AT port.

Send commands with Minicom

Minicom is a text-based serial terminal. To send one command at a time from the command line instead, use ATCom.

  1. Install Minicom

    sudo apt install minicom
  2. Open AT port

    sudo minicom -b 115200 -D /dev/ttyUSB2

    Type the commands and press Enter. The module answers OK when it accepts a command and ERROR when it does not:

    Welcome to minicom 2.7.1
    OPTIONS: I18n
    Compiled on Aug 13 2017, 15:25:34.
    Port /dev/ttyUSB2
    Press CTRL-A Z for help on special keys
    AT
    OK
    AT+CPIN?
    +CPIN: READY
    OK
    AT+CSQ
    +CSQ: 17,99
    OK
    CTRL-A Z for help | 115200 8N1 | NOR | Minicom 2.7.1 | VT102 | Offline | ttyUSB2
  3. Exit Minicom

    Press Ctrl+A, then X.

Send commands with ATCom

ATCom sends one AT command from the command line and prints the answer.

  1. Install ATCom

    On Raspberry Pi OS Bookworm and later, pip does not install packages into the system Python; pipx installs ATCom in its own environment:

    sudo apt install pipx
    pipx install atcom
    pipx ensurepath

    Open a new terminal so that the atcom command is found.

  2. Send command

    atcom --port /dev/ttyUSB2 AT

    Without --port, ATCom looks for the port of a known modem by its USB IDs. Put a command with quotes in single quotes:

    atcom --port /dev/ttyUSB2 'AT+CGDCONT=1,"IP","internet"'

Verify

  1. Send AT

    On the AT port, send AT with Minicom or ATCom.

    Result: the module answers OK.

Details

Set port in Minicom menu

To set the port, baud rate and flow control in Minicom’s menu instead of on the command line, run minicom -s and open Serial port setup. With only TX and RX connected, as on a UART connection, turn hardware flow control off. All options: minicom manual. The picture shows the menu set for the UART port /dev/ttyS1.

ATCom options

OptionDefaultDescription
-p, --portFound by USB IDSerial port of the module
-b, --baudrate115200Baud rate
-t, --timeout10Command timeout, in seconds
-f, --findNoneText to wait for in the answer
-c, --config./configs.ymlConfiguration file
-v, --verboseOffFull log output
--rts-ctsOffRTS/CTS flow control
--dsr-dtrOffDSR/DTR flow control

Options that you use every time can go into configs.yml in the working directory, or into a YAML file given with --config:

port: /dev/ttyUSB2
baudrate: 115200
timeout: 10

AT command manuals

ModuleManual
Quectel EC25, EG25-GEC2x, EG9x, EG2x-G and EM05 Series AT Commands Manual V2.0
Quectel BG96BG96 AT Commands Manual V2.2
Quectel UC20UC20 AT Commands Manual V1.5
Telit LE910C1, LE910C4LE910Cx AT Commands Reference Guide r12
Telit ME910C1-WWME910C1 and ML865C1 AT Commands Reference Guide r15

Next steps