AT Command Handbook

Last revision 2025/12/30

The AT Command Handbook offers a thorough guide on using AT commands for managing network modules, initiating phone calls, sending SMS, establishing MQTT connections, audio playback, and optimizing power usage.

Common AT Commands

Command Significance Return Value
AT AT test command OK
ATE ATE1 sets echo, ATE0 disables echo OK
AT+CGMI Query module manufacturer OK
AT+CGMM Query module model OK
AT+CGSN Query product serial number OK
AT+CSUB Query module version and chip OK
AT+CGMR Query firmware version number OK
AT+IPR=9600 Set the module's temporary hardware serial port baud rate to 9600 +IPR: OK
AT+IPR? Query the current hardware serial port baud rate +IPR: Baud Rate
AT+CRESET Reset the module (the module will restart and automatically register on the network) OK
AT+CSQ Query network signal quality, returns signal value +CSQ: 14,99 OK
AT+CPIN? Query SIM card status, returns READY if the SIM card is recognized +CPIN: READY
AT+COPS? Query the current operator, will return operator information after normal connection +COPS: OK
AT+CREG? Query network registration status +CREG: OK

Note: This AT command is case-insensitive.

AT Command Examples

(1)Initiating and Receiving Phone Calls

Command Significance Response
AT+CNUM Query the local number (not all SIM cards support this command) +CNUM OK
ATD<phone_number>; Dial a specified target mobile number OK
AT+CHUP Hang up the call OK
AT+CLIP=1 Enable caller ID display OK
ATA Answer the call OK

Demonstration of Making and Receiving Phone Calls:

1.Send the ATD138xxxxxxxx; command to dial the target user's phone number. Note: Remember to add a semicolon at the end of the command.

VOICE CALL: BEGIN: Indicates the call has started. After hanging up, you will see VOICE CALL END: xxxxx and NO CARRIER, indicating the end of the call.

RING: Indicates an incoming call. Use the ATA command to answer the call.

VOICE CALL BEGIN: Indicates that the call has been answered.

2.During the call, use the AT+CHUP command to hang up.

(2)Transmitting Text Messages

Command Significance Response
AT+CMGF=1 Set SMS mode to TEXT mode OK
AT+CMGS="phone number" Set the recipient's phone number Return ">," to send the required content
AT+CMGR=SMS number Read the Nth message Read the message
AT+CMGD=SMS number Delete the Nth message OK
AT+CPMS? Check message storage and number of messages "SM," number of messages, maximum message limit

Demonstration of Sending Messages and Querying:

1.Send the AT+CMGF=1 command to set the SMS mode to TEXT mode.

2.Then, input AT+CMGS="138xxxxxxxx" to send a message to the target phone. You will receive the ">" prompt, then input the message you want to send. Note: When dispatching the contents of the message, omit the carriage returns and line breaks.

3.After composing and sending the message, confirm it and check "SendHEX" to send the message in 16-bit hexadecimal. Send 1A (used to instruct the module to perform the sending operation), and receive +CMGS: ok, indicating successful transmission.

These are the steps for sending SMS messages. If you want to inquire about the number of existing messages and the message limit, you can use the AT+CPMS? command. Note: The number of existing messages starts from 1.

You can also input AT+CMGR=X to read the specific content of the Xth message or use AT+CMGD=X to delete the Xth message.

(3)MQTT Connection

Command Significance Response
AT+CMQTTSTART Initiate the MQTT service OK
+CMQTTSTART: 0
AT+CMQTTACCQ=0,"client test ID",<server_type>,<mqtt_version> Acquire an MQTT client
"client test ID" can be customized; <server_type> indicates the server type (0: TCP, 1: SSL/TLS); <mqtt_version> indicates the MQTT protocol version (3: MQTT version 3.1, 4: MQTT version 3.1.1)
OK
AT+CMQTTCONNECT=0,"<server_addr>",<keepalive_time>,<clean_session>,"user_name","password" Connect to the MQTT server
<server_addr> must start with "tcp://". If <server_addr> does not include a port, the default port is 1883, e.g., tcp://116.247.119.165:5141; <keepalive_time> is the interval between receiving two messages by the client (1 second to 64800 seconds); <clean_session> indicates two session flags when the client disconnects from the server, defaulting to 1;
OK
AT+CMQTTSUB=0,<req_length>,0 Subscribe to a message from the server
<req_length> input the length of the topic data (1 to 1024 bytes)
>
**<input_data here>
**OK
AT+CMQTTTOPIC=0,<req_length> Input the message publishing topic
<req_length> input the length of the topic data (1 to 1024 bytes)
>
**<input_data here>
**OK
AT+CMQTTPAYLOAD=0,<req_length> Input the message body for publishing
<req_length> input the length of the message data (1 to 10240 bytes)
>
**<input_data here>
**OK
AT+CMQTTPUB=0,,<pub_timeout> Publish the message to the server
(0: at most once, 1: at least once, 2: exactly once); <pub_timeout> (60 seconds to 180 seconds)
OK
AT+CMQTTDISC=0,120 Disconnect from the server
Here, set the disconnect timeout value to 120 seconds, within the range of 60 seconds to 180 seconds
OK
+CMQTTDISC: 0,0

Demonstration of Sending Messages to the Target Server:

This example demonstrates sending a predefined message to the Easy IoT platform using AT commands with the A7670G module.

Enter Easy IoT. If you do not possess an account, you may commence by registering one.

Upon successful login, proceed to open your workspace. Retrieve your credentials: username, password. Then, proceed to add a novel device, denoted as a Topic, and meticulously document the aforementioned three pivotal parameters.

Easy IoT

1.Open the SSCOM assistant and send the AT+CMQTTSTART command to initiate the module's MQTT service.

2.Send the AT+CMQTTACCQ=0,"EASYIOT" command (set the connection mode to TCP and customize the username as "EASIOT").

3.Send the AT+CMQTTCONNECT=0,"tcp://iot.dfrobot.com:1883",120,1,"user","password" command (TCP, set the server address to Easy IoT, set the message interval to 120 seconds [maximum 64800], enter the account [user] and password [password] obtained from the Easy IoT platform, and clear user information when the device is offline).

4.Send the AT+CMQTTSUB=0,9,1 command (parameter 1 is the client parameter, parameter 2 sets the number of message publications, parameter 3 sets the publication timeout interval in seconds) and wait for the ">" prompt. Then send the topic obtained from the Easy IoT platform.

5.Send the AT+CMQTTTOPIC=0,9 command (set the publishing topic, with parameter 1 as the client parameter and parameter 2 as the topic data length). Wait for the ">" prompt and then send the topic obtained from the Easy IoT platform.

6.Send the AT+CMQTTPAYLOAD=0,12 command (set the message content, similar to AT+CMQTTTOPIC, and directly send characters afterward; ensure the length matches). Wait for the ">" prompt and then send the message content (HELLODFROBOT).

message

7.Send the AT+CMQTTPUB=0,1,60 command (publish the message, parameter 1 is the client parameter, parameter 2 sets the number of message publications, and parameter 3 sets the publication timeout interval in seconds).

8.Finally, access the Easy IoT workspace, check the detailed information of the created topic, and verify that the message (HELLODFROBOT) sent from the module has been received.

success

Note: Line breaks should also be entered when inputting topics and messages.

(4)Audio Playback

Command Significance Response
AT+CREC=1,"c:/recording.wav" Start recording a WAV audio and save it to the local path c:/recording.wav. "1" represents the local path. +CREC: 1
OK
AT+CREC=0 Stop recording WAV audio +CREC: 0
OK
+RECSTATE: crec stop
AT+CCMXPLAYWAV="c:/recording.wav",<play_path>, Play the local path's WAV audio, <play_path> (0: local path, 1: remote path); (0: ) +WAVSTATE: wav play
OK
+WAVSTATE: wav play stop
AT+CCMXSTOPWAV Stop playing WAV audio files +CCMXSTOPWAV:
OK
+WAVSTATE: wav play stop
AT+CCMXPLAY="c:/rec.mp3",0,0 Play an audio file from the local path. "0,0" indicates default local playback and playback once. +CCMXPLAY:
OK
+AUDIOSTATE: audio play
+AUDIOSTATE: audio play stop
AT+CCMXSTOP Stop playing audio files +CCMXSTOP:
OK
+AUDIOSTATE: audio play stop

Recording and Playing Back WAV Audio - Demonstration

1.Input AT+CREC=1,"c:/rec.wav" to start recording WAV audio and save it to the local path e:/rec.wav. A return of +CREC: 1, OK indicates successful recording, while ERROR indicates recording failure. **Note: **Use only English characters when sending AT commands.

2.Send AT+CREC=0 to stop recording WAV audio. To play the previously recorded WAV audio, use the command AT+CCMXPLAYWAV="c:/rec.wav",0,255. If you want to stop playback, you can use the AT+CCMXSTOPWAV command.

Please take note: The audio file should be placed within the "C:/" directory.

(5)Power Saving Mode

Command Significance Response
AT+CFUN=0 Minimum functional mode. The serial port can still be used, but functions related to RF and SIM card, as well as some AT commands, cannot be used. OK
AT+CFUN=1 Full functional mode with maximum power. OK

(6)Sleep Mode

In sleep mode, the module can still receive paging, SMS, and voice calls from the network.

Command Significance Response
AT+CSCLK=0 UART remains operational OK
AT+CSCLK=1 DTR raised, module enters DTR sleep mode OK
AT+CSCLK=2 Module enters RX sleep state, can be awakened by sending data via the serial port (e.g., AT) OK
AT+CSCLK? View the current UART sleep state +CSCLK: Status OK

Querying Result Codes and Their Meanings

Detailed Result Code Meaning
OK Command executed successfully with no errors
CONNECT Connection successful
RING Ring detected (incoming call received)
NO CARRIER No established connection or connection disconnected
ERROR Invalid command or command failed
NO DIALTONE No dial tone, unable to dial, incorrect mode
BUSY Currently in a call or server is busy
NO ANSWER Connection timed out

Was this article helpful?

TOP