Overview
In this article:
This guide provides comprehensive instructions on how to set up, configure, and communicate with the AT Command Modem. It covers hardware connection, serial communication settings, the AT command protocol, and common troubleshooting steps.
Initial Setup
Before you can send commands, you need to connect the hardware and configure your serial terminal correctly.
Hardware Connection
Connect the following pins from your host system to the modem:
- LEUART Tx/Rx
- GND
- GPIO7 (Optional: This pin outputs high to indicate a job is running)
For detailed electrical characteristics and integration guidance, refer to the Myriota Modem Application Note.
Serial Communication Configuration
Use the following settings in your serial terminal application (e.g., PuTTY, minicom, Tera Term):
- Baudrate: 9600
- Data bits: 8
- Stop bits: 1
- Parity: None
- Flow control: None
Understanding the AT Command Protocol
The modem uses a standard AT command set for communication. Here are the fundamental rules.
Command Structure
-
Prefix: All commands must begin with
AT. -
Case Sensitivity: Commands are case-sensitive and must be in UPPERCASE. For example,
AT+MSGQ=?is valid, butat+msgq=?is not. -
Terminators: Commands are terminated by a carriage return (
<CR>), a line feed (<LF>), or a space. It's best practice to use<CR><LF>at the end of each command. -
Length: The maximum command length, including the
ATprefix and terminators, is 80 characters.
Power-Up Sequence
On power-up, the modem will send status messages to the host. You must wait for the +STATE=READY message before you can schedule a message for transmission.
-
+STATE=INITIALIZING: The system is starting up. -
+STATE=GNSS_ACQ: The modem is attempting to acquire a GNSS fix. -
+STATE=READY: A GNSS fix has been acquired, and the modem is ready for all operations.
Command Types & Responses
There are two main types of commands:
-
Query Commands (
AT+<CMD>=?): Used to read data or status from the modem.-
Success Response:
OK+<CMD>=<VALUE> -
Failure Response:
FAIL+<CMD>=<VALUE>
-
Success Response:
-
Control Commands (
AT+<CMD>=<PARAMETER>): Used to perform an action or change a setting.-
Success Response:
OK+<CMD>orOK+<CMD>=<PARAMETER> -
Failure Response:
FAIL+<CMD>orFAIL+<CMD>=<PARAMETER>
-
Success Response:
A simple AT command is used to check communication and will return OK if successful.
Commands with Examples
Here are some of the most frequently used query and control commands. For a complete list and advanced details, please refer to the at_modem README on GitHub.
Query Commands
-
Check Communication
-
Usage:
AT -
Example Response:
OK
-
Usage:
-
Message Queue
-
Usage:
AT+MSGQ=? -
Example Response:
OK+MSGQ=10
-
Usage:
Note: Returns the number of free slots in the message queue.
-
System State
-
Usage:
AT+STATE=? -
Example Response:
OK+STATE=READY
-
Usage:
Note: States are: INITIALIZING, GNSS_ACQ or READY.
-
SDK Version
-
Usage:
AT+VSDK=? -
Example Response:
OK+VSDK=1.2.3
-
Usage:
-
Module ID
-
Usage:
AT+MID=? -
Example Response:
OK+MID=0012345678 M1-24
-
Usage:
-
Registration Code
-
Usage:
AT+REGCODE=? -
Example Response:
OK+REGCODE=a1b2c3d4e5f6g7h8i9j0k1l2m
-
Usage:
-
Time
-
Usage:
AT+TIME=? -
Example Response:
OK+TIME=1673395800
-
Usage:
-
Location
-
Usage:
AT+LOCATION=? -
Example Response:
OK+LOCATION=-349205499,1386086737
-
Usage:
Note: The latitude and longitude are scaled by 1e7.
-
Get suspend mode
-
Usage:
AT+SUSPEND=? -
Example Response:
OK+SUSPEND=0
-
Usage:
Control Commands
-
Save Message Queue
-
Usage:
AT+SAVEMSG -
Example Response:
OK+SAVEMSG
-
Usage:
-
Start RF TX Test
-
Usage:
AT+TXSTART=<FREQUENCY>,<TX_TYPE>,<BURST_MODE>,<TIMEOUT> -
Example Usage:
AT+TXSTART=161450000,0,1,60 -
Example Response:
OK+TXSTART=161450000,0,1,60
-
Usage:
-
Stop RF TX Test
-
Usage:
AT+TXSTOP -
Example Response:
OK+TXSTOP
-
Usage:
-
Start GNSS Fix
-
Usage:
AT+GNSSFIX -
Example Response:
OK+GNSSFIX
-
Usage:
Note: Returns OK+GNSSFIX immediately, then returns a second OK+GNSSFIX on a successful fix, or FAIL+GNSSFIX after a 90s timeout.
-
RSSI Test
-
Usage:
AT+RSSI=<FREQUENCY> -
Example Usage:
AT+RSSI=360000000 -
Example Response:
OK+RSSI=-95
-
Usage:
-
Schedule a Message
-
Usage:
AT+SMSG=<PARAMETER> -
Example Usage:
AT+SMSG=0102030405060708091011121314151617181920 -
Example Response:
OK+SMSG=0102030405060708091011121314151617181920
-
Usage:
Note: The message to be sent, represented as a hex string of even length.
-
Suspend Mode
-
Usage:
AT+SUSPEND=<PARAMETER> -
Example Usage:
AT+SUSPEND=1 -
Example Response:
OK+SUSPEND=1
-
Usage:
-
Set Time
-
Usage:
AT+TIME=<PARAMETER> - Parameter: The current time as a Unix epoch timestamp.
-
Example Usage:
AT+TIME=1673395800 -
Example Response:
OK+TIME=1673395800
-
Usage:
-
Set Location
-
Usage:
AT+LOCATION=<PARAMETER> - Parameter: The latitude and longitude, each scaled by 1e7 and separated by a comma.
-
Example Usage:
AT+LOCATION=-349205499,1386086737 -
Example Response:
OK+LOCATION=-349205499,1386086737
-
Usage:
Troubleshooting and Error Codes
If a command fails, the modem will return an error code. The timeout for any response is 2 seconds, after which the host can retry the command.
Common Mistakes
-
Incorrect Case: Sending
at+state=?will fail because commands must be uppercase. This results in anERROR=UNKNOWN_CONTROL_CMD. -
Invalid
SMSGParameter: The message payload forAT+SMSGmust be a valid hexadecimal string with an even number of characters.AT+SMSG=...2(odd length) orAT+SMSG=...G(invalid hex character) will returnERROR=INVALID_PARAMETER. -
Invalid
LOCATIONFormat: The location parameter must contain two numbers separated by a comma.AT+LOCATION=-349205499.1386086737(using a period) will fail.
Error Code Table
| Error code | Meaning | Countermeasure |
|---|---|---|
INVALID_PARAMETER |
Control commands are carrying illegal parameters. | Use the debug port (UART0 - 115200,N,8,1) to monitor detailed causes. |
MESSAGE_TOO_LONG |
Scheduled message is too long. | Reduce message size. |
TOO_MANY_MESSAGES |
Too many messages scheduled in an hour. | Wait for some time before scheduling the message. |
BUFFER_OVERFLOW |
Modem RX buffer overflow. | Reduce UART frame length. |
UNKNOWN_QUERY_CMD |
Query identifier =? detected but no command match. |
Check the query command list for the correct command string. |
UNKNOWN_CONTROL_CMD |
Control format matched but no command is found. | Check the control command list for the correct command string. |
INVALID_COMMAND |
Command format error, can be caused by prefix/terminator match or command/parameter too long. | Check that the command starts with AT, is uppercase, and is not too long. |
