AT Command Handbook

Last revision 2025/12/30

The AT Command Handbook is a comprehensive guide detailing various AT commands used for device communication, covering GPS positioning, phone calls, SMS transmission, MQTT connections, and audio playback. It includes practical examples and response values for efficient module interaction.

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.

Example AT Commands

(1) Retrieve GPS Positioning Data

When utilizing GNSS positioning, first attach the GPS antenna and place the module outdoors, then power it on, and wait for one minute before initiating the positioning function.

Command Significance Response
AT+CGPS=1 Activate GPS OK
AT+CGPSINFO Print GPS information to the serial port Positioning information
AT+CGPS=0 Deactivate GPS OK

The GPS positioning data printed to the serial port appears as follows:

GPS positioning data

Please note: The latitude and longitude data printed to the serial port cannot be directly used for positioning; it needs to be converted using a formula.

Assuming the read data is +CGPSINFO:1234.567891,N,12345.678912,E,141023,012523.0,455.1,0.0,

Conversion formula:

N (Latitude) 1234.567891

(1) 1234.567891÷100=12 (rounded down)

(2) 34567891÷60=576.13152

The latitude coordinate in degree format is N 12.57613152°

E (Longitude) 12345.678912

(1) 12345.678912÷100=123 (rounded down)

(2) 45678912÷60=761.315.2

The longitude coordinate in degree format is E 123.7613152°

Open a latitude and longitude lookup website, and input the calculated latitude and longitude data in order to obtain the positioning location.

Note: Upon issuing the command to print GPS information, if you fail to retrieve the GPS positional data, kindly reissue the GPS print command persistently until successful acquisition of location information is achieved.

(2) Initiating and Receiving Phone Calls

Command Significance Response
AT+CNUM Query the local number (not all SIM cards support this command) +CNUM OK
AT+CSDVC AT+CSDVC=1: Switch to headphone output AT+CSDVC=3: Switch to speaker output OK
AT+CLVL=? Query the volume range OK
AT+CLVL=2 Set the volume to 2 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.Before making or receiving a phone call, use the AT+CSDVC=3 command to switch to speaker output.

2.Send the AT+CLVL=5 command to set the speaker volume to an appropriate level.

3.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.

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

(3) 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 N+1th message Read the message
AT+CMGD=SMS number Delete the N+1th 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: **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 0.

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

(4) 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 SIM7600G-H 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.

(5) Audio Playback

Command Significance Response
AT+CREC=1,"e:/rec.wav" Start recording a WAV audio and save it to the local path e:/rec.wav. "1" represents the local path. +CREC: 1
OK
AT+CREC=0 Stop recording WAV audio +CREC: 0
OK
+RECSTATE: crec stop
AT+CCMXPLAYWAV="E:/rec.wav",2 Play a WAV audio file from the local path. "2" represents the local path. +WAVSTATE: wav play
OK
+WAVSTATE: wav play stop
AT+CCMXSTOPWAV Stop playing WAV audio files +CCMXSTOPWAV:
OK
+WAVSTATE: wav play stop
AT+CCMXPLAY="E:/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. Enter AT+CSDVC=3 to switch to speaker output. **Note: **You need to set this command each time after booting if you want to use speaker output.
  2. Send AT+CLVL=3 to set an appropriate speaker volume.
  3. Input AT+CREC=1,"e:/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.
  4. Send AT+CREC=0 to stop recording WAV audio. To play the previously recorded WAV audio, use the command AT+CCMXPLAYWAV="E:/rec.wav",2. If you want to stop playback, you can use the AT+CCMXSTOPWAV command.

Note: Please place the audio files into the directory designated as "e:/".

(6) 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

(7) 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 always on input. OK
AT+CSCLK=1 UART enters sleep mode when DTR is high and exits sleep mode when DTR is low. OK
AT+CSCLK? View the current UART sleep state. +CSCLK: Status OK

AT Command Result Codes

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