AT Command Set

[中文]

Here is a list of AT commands.

It is strongly recommended to read the following sections for some common information on AT commands before you dive into the details of each command.

AT Command Types

Generic AT command has four types:

Type

Command Format

Description

Test Command

AT+<CommandName>=?

Query the Set Commands’ internal parameters and their range of values.

Query Command

AT+<CommandName>?

Return the current value of parameters.

Set Command

AT+<CommandName>=<…>

Set the value of user-defined parameters in commands, and run these commands.

Execute Command

AT+<CommandName>

Run commands with no user-defined parameters.

  • Not all AT commands support all of the four types mentioned above.

  • Currently, only strings and integer numbers are supported as input parameters in AT commands.

  • Angle brackets < > designate parameters that can not be omitted.

  • Square brackets [ ] designate optional parameters that can be omitted. The default value of the parameter will be used instead when you omit it. Below are examples of entering the command AT+CWJAP with some parameters omitted.
    AT+CWJAP="ssid","password"
    AT+CWJAP="ssid","password","11:22:33:44:55:66"
    
  • If the parameter you want to omit is followed by a parameter(s), you must give a , to indicate it.
    AT+CWJAP="ssid","password",,1
    
  • String values need to be included in double quotation marks.
    AT+CWSAP="ESP756290","21030826",1,4
    
  • Escape character syntax is needed if a string contains special characters. The characters that need to be escaped are ,, ", and \:

    • \\: escape the backslash itself

    • \,: escape comma which is not used to separate each parameter

    • \": escape double quotation mark which is not used to mark string input

    • \<any>: escape <any> character means that drop backslash symbol and only use <any> character

  • Escape is needed in AT commands only, not elsewhere. For example, when AT command port prints > and wait for your input, the input does not need to be escaped.
    AT+CWJAP="comma\,backslash\\ssid","1234567890"
    AT+MQTTPUB=0,"topic","\"{\"sensor\":012}\"",1,0
    
  • The default baud rate of AT command is 115200.

  • The length of each AT command should be no more than 256 bytes.

  • AT commands end with a new-line (CR-LF), so the serial tool should be set to “New Line Mode”.

  • Definitions of AT command error codes are provided in AT API Reference:

AT Commands with Configuration Saved in the Flash

Configuration settings entered by the following AT Commands will always be saved in the flash NVS Area, so they can be automatically restored on reset:

Saving of configuration settings by several other commands can be switched on or off with AT+SYSSTORE command, which is mentioned in the Note section of these commands.

Note

The parameters of AT commands are saved based on NVS library. Therefore, if the command is configured with the same parameter value, flash will not be written; If the command is configured with the different parameter value, flash will not be erased frequently.

AT Messages

ESP-AT returns two kinds of messages from the command port: ESP-AT responses and ESP-AT message reports.

ESP-AT Responses (passive)

Each ESP-AT command input returns response messages to tell the sender the result of the ESP-AT command. The last message in the response is either OK or ERROR.

AT Response

Description

OK

AT command process done and return OK

ERROR

AT command error or error occurred during the execution

+ERRNO

Error code +ERRNO:<error_code> when command execution fails

ERR CODE

Error code ERR CODE:<0x%08x> for a parameter error

SEND OK

Data has been sent to the protocol stack (specific to AT+CIPSEND and AT+CIPSENDEX command). It doesn’t mean that the data has been sent to the opposite end

SEND FAIL

Error occurred during sending the data to the protocol stack (specific to AT+CIPSEND, AT+CIPSENDL, and AT+CIPSENDEX command)

SET OK

The URL has been set successfully (specific to AT+HTTPURLCFG command)

+<Command Name>:...

Response to the sender that describes AT command process results in details

> Response

Waiting for the number of bytes specified by the command

> Response

When a command requires a fixed number of bytes, AT first returns > on the command port, then receives that many bytes.

If at least 3 bytes are still expected and the input contains only +++, AT stops receiving and the command returns ERROR. +++ mixed with other bytes in the same input is received as data, so the input cannot consist of only +++.

When the length to receive is 0, the command returns ERROR and does not return >. If a command defines 0 as clearing a configuration or sending no data, follow that command’s parameter description.

+ERRNO

+ERRNO:<error_code> is returned in a command response and is also reported as a URC. It is output only when AT+SYSLOG=1. The source of <error_code> depends on the command:

  • When TCP connection, UDP transmission, or SSL server fails, the error code is returned in priority order: first, the socket’s SO_ERROR; if SO_ERROR is 0, then LwIP’s errno; if errno is 0, then the error code defined by ESP-AT.

  • When SSL connection establishment fails, the error code is returned in priority order: first, certificate-related error code; if certificate-related error code is 0, then mbedTLS error code; if mbedTLS error code is 0, then esp-tls error code; if esp-tls error code is 0, then the error code defined by ESP-AT.

  • When AT+CIPSEND or AT+CIPSENDL fails to send, a TCP or UDP connection reports the absolute value of the socket errno, and an SSL connection reports the absolute value of the esp-tls error code. A full send buffer is ECONNABORTED, a closed socket is ENOTCONN, and a send timeout is ETIMEDOUT.

  • When AT+SYSMFG fails, the error code is the ESP-IDF esp_err_t. A parameter error does not output this message.

ERR CODE

ERR CODE:<0x%08x> is an early AT error code. It is output only when AT+SYSLOG=1. A parameter error usually returns this code. See AT+SYSLOG for the code definition.

ESP-AT Message Reports (active)

The following table lists URC messages that ESP-AT reports to indicate system state changes. Messages that need a longer description are documented after the table.

ESP-AT Message Reports

ESP-AT Message Report

Description

ready

The ESP-AT firmware is ready

busy p…

Busy processing. The system is in process of handling the previous command, thus CANNOT accept the new input

ERR CODE

Error code ERR CODE:<0x%08x> for a parameter error

Will force to restart!!!

Module restart right now

smartconfig type:<xxx>

Smartconfig type

Smart get wifi info

Smartconfig has got the SSID and PASSWORD information

+SCRD:<length>,<reserved data>

ESP-Touch v2 has got the reserved information

smartconfig connected wifi

Smartconfig done. ESP-AT has connected to the Wi-Fi

WIFI CONNECTED

Wi-Fi station interface has connected to an AP

WIFI GOT IP

Wi-Fi station interface has got the IPv4 address

WIFI GOT IPv6 LL

Wi-Fi station interface has got the IPv6 LinkLocal address

WIFI GOT IPv6 GL

Wi-Fi station interface has got the IPv6 Global address

WIFI DISCONNECT

Wi-Fi station interface has disconnected from an AP

+ETH_CONNECTED

Ethernet interface has connected

+ETH_GOT_IP

Ethernet interface has got the IPv4 address

+ETH_DISCONNECTED

Ethernet interface has disconnected

[<conn_id>,]CONNECT

A network connection of which ID is <conn_id> is established (ID=0 by default)

[<conn_id>,]CLOSED

A network connection of which ID is <conn_id> ends (ID=0 by default)

+ERRNO

Error code +ERRNO:<error_code> when command execution fails

+LINK_CONN

Detailed connection information of TCP/UDP/SSL

+STA_CONNECTED: <sta_mac>

A station has connected to the Wi-Fi softAP interface of ESP-AT

+DIST_STA_IP: <sta_mac>,<sta_ip>

The Wi-Fi softAP interface of ESP-AT distributes an IP address to the station

+STA_DISCONNECTED: <sta_mac>

A station disconnected from the Wi-Fi softAP interface of ESP-AT

Recv <xxx> bytes

ESP-AT has already received <xxx> bytes from the ESP-AT command port

+IPD

Data received from the network when AT is not in Passthrough Mode

The Data in Passthrough Mode

ESP-AT received the data from the network or Bluetooth when AT is in Passthrough Mode

SEND Canceled

Cancel to send in normal sending mode

Have <xxx> Connections

Has reached the maximum connection counts for server

+QUITT

ESP-AT quits from the Passthrough Mode

NO CERT FOUND

No valid device certificate found in custom partition

NO PRVT_KEY FOUND

No valid private key found in custom partition

NO CA FOUND

No valid CA certificate found in custom partition

+TIME_UPDATED

The system time has been updated. Only after sending the AT+CIPSNTPCFG command or power on will this message be outputted if the module fetches a new time from the SNTP server.

+MQTTCONNECTED

MQTT connected to the broker

+MQTTDISCONNECTED

MQTT disconnected from the broker

+MQTTSUBRECV

MQTT received the data from the broker

+MQTTPUB:FAIL

MQTT failed to publish data

+MQTTPUB:OK

MQTT publish data done

+BLECONN

A Bluetooth LE connection established

+BLEDISCONN

A Bluetooth LE connection ends

+READ

A read operation from Bluetooth LE connection

+WRITE

A write operation from Bluetooth LE connection

+NOTIFY

A notification from Bluetooth LE connection

+INDICATE

An indication from Bluetooth LE connection

+BLESECNTFYKEY

Bluetooth LE SMP key

+BLESECREQ:<conn_index>

Received an encrypted pairing request from a Bluetooth LE connection.

+BLEAUTHCMPL:<conn_index>,<enc_result>

Bluetooth LE SMP pairing completed

+SSID:<ssid>

In BluFi network configuration mode, the ESP32-C3 received the SSID sent from the phone.

+PASSWORD:<password>

In BluFi network configuration mode, the ESP32-C3 received the password sent from the phone.

+BLUFIDATA:<len>,<data>

The ESP32-C3 received customized data from the phone over BluFi.

+WS_DISCONNECTED:<link_id>

The WebSocket connection of ID <link_id> is disconnected.

+WS_CONNECTED:<link_id>

The WebSocket connection of ID <link_id> is established.

+WS_DATA:<link_id>,<data_len>,<data>

The WebSocket connection of ID <link_id> has received the data. You can use the AT+WSDATAFMT command to control the received data format.

+WS_CLOSED:<link_id>

The WebSocket connection of ID <link_id> is closed.

+BLESCANDONE

Scan finished

+BLESECKEYREQ:<conn_index>

The peer has accepted the pairing request, and the ESP device can enter the key.

+BLE_TT_MODE

Entered BLE passthrough mode.

+WRITE:<conn_index>

In passthrough mode, when enabling notify or indicate, the message prefixed with “+WRITE:” will be printed.

+IPD

When ESP-AT receives network data and is not in Passthrough Mode, it reports +IPD in one of the following formats:

  • +IPD,<length> if AT+CIPMUX=0 and AT+CIPRECVTYPE=1.

  • +IPD,<link_id>,<length> if AT+CIPMUX=1 and AT+CIPRECVTYPE=<link_id>,1.

  • +IPD,<length>:<data> if AT+CIPMUX=0, AT+CIPRECVTYPE=0, and AT+CIPDINFO=0.

  • +IPD,<link_id>,<length>:<data> if AT+CIPMUX=1, AT+CIPRECVTYPE=<link_id>,0, and AT+CIPDINFO=0.

  • +IPD,<length>,<"remote_ip">,<remote_port>:<data> if AT+CIPMUX=0, AT+CIPRECVTYPE=0, and AT+CIPDINFO=1.

  • +IPD,<link_id>,<length>,<"remote_ip">,<remote_port>:<data> if AT+CIPMUX=1, AT+CIPRECVTYPE=<link_id>,0, and AT+CIPDINFO=1.

link_id is the connection ID, length is the data length, remote_ip is the remote IP address, remote_port is the remote port, and data is the data.

For an SSL connection in passive receive mode (AT+CIPRECVTYPE=1), the length reported on the AT command port may differ from the readable SSL data length. AT first returns the readable length at the SSL layer. If that length is 0, AT returns the readable length at the socket layer.

If third-party cloud commands are used, ESP-AT will report cloud important state changes or messages in the system.

ESP-AT Message Report for Third-Party Cloud

ESP-AT Message Report

Description

RainMaker AT Messages

Please refer to ESP-AT RainMaker Message Reports (active)

AT Logs

Through the Log Output pin described in Hardware Connection, ESP-AT outputs rich log information to help you understand its runtime status. You can also enable different log configurations to view more detailed log information. The following table lists some common log messages and their explanations:

ESP-AT Logs

AT Log

Description

at-common: write dlen:0

The RX of the AT command port received unexpected data, usually containing multiple \0 characters. If you are communicating with the MCU via UART, please check the following:

  • Whether the UART RX pin of ESP32-C3 is correctly connected to the TX pin of the MCU

  • Whether the MCU is sending data not in AT command format

  • Whether the MCU is correctly configured for UART baud rate, data bits, stop bits, parity, and flow control

  • Whether the GND of the MCU is correctly connected to the GND pin of ESP32-C3

at-init: at param mode: <mode>

Parameter mode during AT initialization

  • 0: No parameters

  • 1: Use parameters in the mfg_nvs partition

  • 2: Use parameters in the factory_param partition

at-init: v4.1.0.0 (<src>)

AT firmware version number and the source of the corresponding firmware build

at-wifi: negotiated phy mode: <phy_mode>

PHY mode negotiated when Wi-Fi Station connects to AP

  • 0: Low Rate

  • 1: 11b

  • 2: 11g

  • 3: 11a

  • 4: HT20

  • 5: HT40

  • 6: HE20

  • 7: VHT20

alloc failed, size:<size> caps:<caps>

Memory allocation failed. The requested size is <size> and the capability is <caps>. Consider time-multiplexing features or reducing memory usage:

at-wifi: wifi disconnected, rc:<reason_code>

Wi-Fi station disconnection reason code

at-wifi: wifi reconnect..(<index>/<total_count>)

Wi-Fi station is reconnecting to AP

at-net: unknown host: <hostname>

Unable to resolve hostname <hostname>, please check DNS settings and network connection

at-net: send failed, s:<send_len> r:<ret_len>

Failed to send data: expected to send <send_len> bytes, but only <ret_len> bytes were sent. Please check network connection.

at-net: link is changed

When AT is acting as a server, the client connection was interrupted during data transmission, and a new client has connected to the server.

at-net: link:<link_id> is on netif:<netif_id>

Connection <link_id> was successfully established on network interface <netif_id>.

  • 1: Wi-Fi station interface

  • 2: Wi-Fi softAP interface

  • 3: Ethernet interface