Sending AT Commands

AT Commands are instructions that provide communication and control between any cellular modem and a host controller. Cellular modems can be controlled using special AT commands provided by the module manufacturer. There are several serial monitor tools that can be used to send AT commands to the cellular module. The most common is the minicom application on Linux. One can use Cutecom as GUI supported tool.

As long as the right configurations such as the device port, baud rate are selected right; any tool can be used. This tutorial will explain how to use the ATCom and Minicom tools. These tools can communicate with cellular modems on Sixfab HATs.

Module Port Availability

Before you start sending AT commands to your modem, be sure the check the port your modem is connected to as well as the baudrate. Use the built-in logs to identify the different serial ports on your system. Follow the steps below to find the name of your port(s).

Before connecting USB to your HAT, open Terminal and type the following command:

[email protected]:~ $ ls /dev/tty* /dev/tty /dev/tty14 /dev/tty20 /dev/tty27 /dev/tty33 /dev/tty4 /dev/tty46 /dev/tty52 /dev/tty59 /dev/tty8 /dev/tty0 /dev/tty15 /dev/tty21 /dev/tty28 /dev/tty34 /dev/tty40 /dev/tty47 /dev/tty53 /dev/tty6 /dev/tty9 /dev/tty1 /dev/tty16 /dev/tty22 /dev/tty29 /dev/tty35 /dev/tty41 /dev/tty48 /dev/tty54 /dev/tty60 /dev/ttyAMA0 /dev/tty10 /dev/tty17 /dev/tty23 /dev/tty3 /dev/tty36 /dev/tty42 /dev/tty49 /dev/tty55 /dev/tty61 /dev/ttyprintk /dev/tty11 /dev/tty18 /dev/tty24 /dev/tty30 /dev/tty37 /dev/tty43 /dev/tty5 /dev/tty56 /dev/tty62 /dev/tty12 /dev/tty19 /dev/tty25 /dev/tty31 /dev/tty38 /dev/tty44 /dev/tty50 /dev/tty57 /dev/tty63 /dev/tty13 /dev/tty2 /dev/tty26 /dev/tty32 /dev/tty39 /dev/tty45 /dev/tty51 /dev/tty58 /dev/tty7

This should return all USB devices currently plugged into your computer. Now that we know which devices are not cellular modems, it will be easier to identify when plugged in.

Connect USB and run:

[email protected]:~ $ ls /dev/tty* /dev/tty /dev/tty14 /dev/tty20 /dev/tty27 /dev/tty33 /dev/tty4 /dev/tty46 /dev/tty52 /dev/tty59 /dev/tty8 /dev/ttyUSB3 /dev/tty0 /dev/tty15 /dev/tty21 /dev/tty28 /dev/tty34 /dev/tty40 /dev/tty47 /dev/tty53 /dev/tty6 /dev/tty9 /dev/tty1 /dev/tty16 /dev/tty22 /dev/tty29 /dev/tty35 /dev/tty41 /dev/tty48 /dev/tty54 /dev/tty60 /dev/ttyAMA0 /dev/tty10 /dev/tty17 /dev/tty23 /dev/tty3 /dev/tty36 /dev/tty42 /dev/tty49 /dev/tty55 /dev/tty61 /dev/ttyprintk /dev/tty11 /dev/tty18 /dev/tty24 /dev/tty30 /dev/tty37 /dev/tty43 /dev/tty5 /dev/tty56 /dev/tty62 /dev/ttyUSB0 /dev/tty12 /dev/tty19 /dev/tty25 /dev/tty31 /dev/tty38 /dev/tty44 /dev/tty50 /dev/tty57 /dev/tty63 /dev/ttyUSB1 /dev/tty13 /dev/tty2 /dev/tty26 /dev/tty32 /dev/tty39 /dev/tty45 /dev/tty51 /dev/tty58 /dev/tty7 /dev/ttyUSB2

Whatever new entries appear is your cellular modem.

Alternatively, you can check dmesg:

[email protected]:~ $ dmesg | grep tty [ 0.000000] Kernel command line: coherent_pool=1M 8250.nr_uarts=0 snd_bcm2835.enable_compat_alsa=0 snd_bcm2835.enable_hdmi=1 smsc95xx.macaddr=DC:A6:32:49:FB:39 vc_mem.mem_base=0x3ec00000 vc_mem.mem_size=0x40000000 console=ttyS0,115200 console=tty1 root=PARTUUID=9c0c76f5-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait [ 0.001546] printk: console [tty1] enabled [ 1.193107] fe201000.serial: ttyAMA0 at MMIO 0xfe201000 (irq = 29, base_baud = 0) is a PL011 rev2 [ 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

ATCom

In order to, send AT commands to a cellular device, one needs to check several parameters and might need a serial monitor tool. ATCom is a command-line interface tool that makes AT command operations easier.​

Installation

​pip3 is required to install the ATCom. pip3 can be intalled by​

sudo apt install python3-pip

ATCom can be installed with pip3:

pip3 install atcom

Usage

$ atcom [OPTIONS] AT_COMMAND

Examples

​Running ATCom without --port parameter, scans for available ports, and selects a valid modem port if available.​

$ atcom AT

or

$ atcom --port /dev/ttyUSB2 AT

❗️ Warning

If you need to send " or ' character, you should use escape character \ before it.

Example: atcom AT+CGDCONT=1,\"IP\",\"internet\"

Configuration File

Configuration file(configs.yaml) can be created for persist args. ATCom first checks the current working directory for the configs.yml to read the arguments from. The path of the configuration file can also be specified using the --config parameter. The configuration file must be in yaml format, for example: ​

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

Parameters

DefaultDescription
-p / --port-PORT of modem
-b / --baudrate115200Baudrate for serial communication
-t / --timeout10Communication timeout
-c / --config./configs.yamlConfigurations file Path
-v / --verbose-Enable full log output
--rts-cts-Enable RTS-CTS mode
--dsr-dtr-Enable DSR-DTR mode

Minicom

Minicom is a text-based serial port communications program.

657657

Minicom

Install minicom

Install the program with:

sudo apt install minicom

Using the minicom

Type the following to send AT command to HAT via device: ttyUSBx at baudrate 115200. Where x represents the port number you want to open.

sudo minicom -b 115200 -D /dev/ttyUSB2
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

It should result in an OK reply if successfully received by the module or an ERROR if not interpreted correctly.

Setup Minicom

If the configurations are not selected from the command line as mentioned before, the following command can be used to select the detailed configuration.

minicom -s

For details on how to use minicom, refer to the following webpage.

AT commands manuals

To know about the supported AT commands by the module, check the following links.