ESP8266 AT Commands
ESP8266 AT Commands
ESP8266 AT Commands
1. AT Commands List
AT : Tests AT startup.
AT+RST : Restarts a module.
AT+GMR : Checks version information.
AT+GSLP : Enters Deep-sleep mode.
ATE : Configures echoing of AT commands.
AT+RESTORE : Restores the factory default settings of the module.
AT+UART_CUR : Current UART configuration.
AT+UART_DEF : Default UART configuration, saved in flash.
AT+SLEEP : Sets the sleep mode.
AT+SYSRAM : Checks the remaining space of RAM.
AT+SYSMSG : Set message format.
AT+RFPOWER : Set RF TX Power.
AT+SYSROLLBACK : Roll back to the previous firmware.
AT+SYSTIMESTAMP: Set local time stamp.
AT+SYSLOG : Enable or disable the AT error code prompt.
AT+SYSLSPCFG : Config the light-sleep wakeup source.
AT+SYSLSP : Enters light-sleep mode.
2. Basic AT Commands
Execute Command:
AT
Response:
OK
Execute Command:
AT+RST
Response:
OK
Execute Command:
AT+GMR
Response:
OK
Parameters:
Set Command:
AT+GSLP=<time>
Response:
<time>
OK
Parameters:
Execute Command:
ATE
Response:
OK
Parameters:
Execute Command:
AT+RESTORE
Response:
OK
Note:
The execution of this command will reset all parameters saved in flash, and restore the factory default
settings of the module.
The chip will be restarted when this command is executed.
Query Command:
AT+UART_CUR?
Response:
+UART_CUR:<baudrate>,<databits>,<stopbits>,<parity>,<flow control>
OK
Note:
Command AT+UART_CUR? will return the actual value of UART configuration parameters, which may
have allowable errors compared with the set value because of the clock division.
Set Command:
AT+UART_CUR=<baudrate>,<databits>,<stopbits>,<parity>,<flow control>
Response:
OK
Parameters:
Notes:
Example:
AT+UART_CUR=115200,8,1,0,3
Query Command:
AT+UART_DEF?
Response:
+UART_DEF:<baudrate>,<databits>,<stopbits>,<parity>,<flow control>
OK
Set Command:
AT+UART_DEF=<baudrate>,<databits>,<stopbits>,<parity>,<flow control>
Response:
OK
Parameters:
Notes:
The configuration changes will be saved in the NVS area, and will still be valid when the chip is powered
on again.
The use of flow control requires the support of hardware:
IO15 is UART0 CTS
IO14 is UART0 RTS
The range of baud rates supported: 80 ~ 5000000.
Example:
AT+UART_DEF=115200,8,1,0,3
Set Command:
AT+SLEEP=<sleep mode>
Response:
OK
Parameters:
sleep mode:
0: disable the sleep mode.
1: Modem-sleep mode.
Example:
AT+SLEEP=0
2.10 AT+SYSRAM—Checks the Remaining Space of RAM
Query Command:
AT+SYSRAM?
Response:
Parameters:
Example:
AT+SYSRAM?
+SYSRAM:148408
OK
Query Command:
AT+SYSMSG?
Function:
Query the current system message state.
Response:
+SYSMSG:<state>
OK
Set Command:
AT+SYSMSG=<state>
Function:
Control to use new or old information.
Response:
OK
Parameters:
state:
Bit0: Quit transparent transmission 0: Quit transparent transmission no information. 1: Quit
transparent transmission will supply information.
Bit1: Connection info 0: Use old connection info. 1: Use new connection info.
Notes:
If set Bit1 to 1 will impact the infomation of command AT+CIPSTART and AT+CIPSERVER ,
// Use new connection info and quit transparent transmission no information AT+SYSMSG=2
Query Command:
AT+RFPOWER?
Function: to query the RF TX Power.
Response:
+RFPOWER:<wifi_power>,<ble_adv_power>,<ble_scan_power>,<ble_conn_power>
OK
Set Command:
AT+RFPOWER=<wifi_power>[,<ble_adv_power>,<ble_scan_power>,<ble_conn_power>]
Response:
OK
Parameters:
wifi_power: range [40, 82], the unit is 0.25dBm, for example, if the value is 78, then RF max power is
78*0.25 dBm=19.5dBm
0:7dBm
1:4dBm
2:1dBm
3:-2 dBm
4:-5 dBm
5:-8 dBm
6:-11 dBm
7:-14 dBm
ble_scan_power: RF TX Power of BLE scanning, range: [0, 7], the same as ble_adv_power
ble_conn_power : RF TX Power of BLE connecting, range: [0, 7], the same as ble_adv_power
Notes: Since the RF TX power is actually divided into several levels, and each level has its own value range, so
the wifi_power value queried by the esp_wifi_get_max_tx_power may differ from the value set by
esp_wifi_set_max_tx_power . And the query value will not be larger than the set one.
Execute Command:
AT+SYSROLLBACK
Response:
OK
Note:
This command will not upgrade via OTA, only roll back to the firmware which is in the other ota partition.
Query Command:
AT+SYSTIMESTAMP?
Function: to query the time stamp.
Response:
+SYSTIMESTAMP:<Unix_timestamp>
OK
Set Command:
AT+SYSTIMESTAMP=<Unix_timestamp>
Function: to set local time stamp. It will be the same as SNTP time
when the SNTP time updated.
Response:
OK
Parameters:
Example:
Query Command:
AT+SYSLOG?
Function: to query the AT error code prompt for whether it is enabled or disabled.
Response:
+SYSLOG:<status>
OK
Set Command:
AT+SYSLOG=<status>
Function: Enable or disable the AT error code prompt.
Response:
OK
Parameters:
- status: : enable or disable - 0: disable - 1: enable
Example:
If enable AT error code prompt:
AT+SYSLOG=1
OK
AT+FAKE
ERR CODE:0x01090000
ERROR
If disable AT error code prompt:
AT+SYSLOG=0
OK
AT+FAKE
//No `ERR CODE:0x01090000`
ERROR
3 Wi-Fi AT Commands
Query Command:
AT+CWMODE?
Function: to query the Wi-Fi mode of ESP.
Response:
+CWMODE:<mode>
OK
Set Command:
AT+CWMODE=<mode>
Function: to set the Wi-Fi mode of ESP.
Response:
OK
Parameters:
mode :
0: Null mode, WiFi RF will be disabled
1: Station mode
2: SoftAP mode
3: SoftAP+Station mode
Note:
Example:
AT+CWMODE=3
3.2 AT+CWJAP—Connects to an AP
Query Command:
AT+CWJAP?
Function: to query the AP to which the ESP Station is already connected.
Response:
+CWJAP:<ssid>,<bssid>,<channel>,<rssi>,<pci_en>,<reconn>,<lisnten_interval>
OK
Parameters:
Set Command:
AT+CWJAP=<ssid>,<pwd>[,<bssid>][,<pci_en>][,<reconn>][,<listen_interval>]
Function: to set the AP to which the ESP Station needs to be connected.
Response:
OK
Note:
Examples:
AT+CWJAP="abc","0123456789"
- For example, if the target AP's SSID is "ab\,c" and the password
is "0123456789"\", the command is as follows:
AT+CWJAP="ab\\\,c","0123456789\"\\"
- If multiple APs have the same SSID as "abc", the target AP can be
found by BSSID:
AT+CWJAP="abc","0123456789","ca:d7:19:d8:a6:44"
Set Command:
AT+CWLAPOPT=<sort_enable>,<mask>
Response:
OK
Parameters:
sort_enable: determines whether the result of command AT+CWLAP will be listed according to RSSI:
0: the result is not ordered according to RSSI.
1: the result is ordered according to RSSI.
mask: determines the parameters shown in the result of AT+CWLAP ;
0 means not showing the parameter corresponding to the bit, and 1 means showing it.
bit 0: determines whether \ will be shown in the result of AT+CWLAP .
bit 1: determines whether \ will be shown in the result of AT+CWLAP .
bit 2: determines whether \ will be shown in the result of AT+CWLAP .
bit 3: determines whether \ will be shown in the result of AT+CWLAP .
bit 4: determines whether \ will be shown in the result of AT+CWLAP .
Example:
AT+CWLAPOPT=1,31
- The first parameter is 1, meaning that the result of the command AT+CWLAP will be
ordered according to RSSI;
- The second parameter is 31, namely 0x1F, meaning that the corresponding bits of <mask>
are set to 1. All parameters will be shown in the result of AT+CWLAP.
Set Command:
AT+CWLAP=[<ssid>,<mac>,<channel>,<scan_type>,<scan_time_min>,<scan_time_max>]
Function: to query the APs with specific SSID and MAC on a specific channel.
Execute Command:
AT+CWLAP
Function: to list all available APs.
Response:
+CWLAP:<ecn>,<ssid>,<rssi>,<mac>,<channel>
OK
Parameters:
Examples:
AT+CWLAP="Wi-Fi","ca:d7:19:d8:a6:44",6,0,400,1000
Or search for APs with a designated SSID:
AT+CWLAP="Wi-Fi"
Execute Command:
AT+CWQAP
Response:
OK
Query Command:
AT+CWSAP?
Function: to obtain the configuration parameters of the ESP SoftAP.
Response:
Set Command:
Response:
OK
Parameters:
Note:
Example:
AT+CWSAP="ESP","1234567890",5,3
Execute Command:
AT+CWLIF
Response:
<ip addr>,<mac>
OK
Parameters:
Note:
This command cannot get a static IP. It only works when both DHCPs of the ESP SoftAP, and of the
Station to which ESP is connected, are enabled.
Execute Command:
AT+CWQIF
Function: Disconnect all stations that connected to the ESP SoftAP.
Response:
OK
Set Command:
AT+CWQIF=<mac>
Function: Disconnect the station whose mac is "<mac>" from the ESP SoftAP.
Response:
OK
Parameters:
Query Command:
AT+CWDHCP?
Response: state
Set Command:
AT+CWDHCP=<operate>,<mode>
Function: to enable/disable DHCP.
Response:
OK
Parameters:
operate :
0: disable
1: enable
mode :
Bit0: Station DHCP
Bit1: SoftAP DHCP
state:DHCP disabled or enabled now? Bit0: 0: Station DHCP is disabled. 1: Station DHCP is enabled. Bit1:
0: SoftAP DHCP is disabled. 1: SoftAP DHCP is enabled. Notes:
Examples:
AT+CWDHCP=1,1 //Enable Station DHCP. If the last DHCP mode is 2, then the current
//DHCP mode will be 3.
AT+CWDHCP=0,2 //Disable SoftAP DHCP. If the last DHCP mode is 3, then the current
//DHCP mode will be 1.
3.10 AT+CWDHCPS —Sets the IP Address Allocated by ESP SoftAP DHCP (The configuration is
saved in Flash.)
Query Command:
AT+CWDHCPS?
Response:
Set Command:
Response:
OK
Parameters:
enable:
0: Disable the settings and use the default IP range.
1: Enable setting the IP range, and the parameters below have to be set.
lease time: lease time, unit: minute, range [1, 2880].
start IP: start IP of the IP range that can be obtained from ESP SoftAP DHCP server.
end IP: end IP of the IP range that can be obtained from ESP SoftAP DHCP server.
Notes:
Examples:
AT+CWDHCPS=1,3,"192.168.4.10","192.168.4.15"
or
AT+CWDHCPS=0 //Disable the settings and use the default IP range.
Set Command:
AT+CWAUTOCONN=<enable>
Response:
OK
Parameters:
enable:
0: does NOT auto-connect to AP on power-up.
1: connects to AP automatically on power-up.
Note:
Example:
AT+CWAUTOCONN=1
Query Command:
AT+CIPSTAMAC?
Function: to obtain the MAC address of the ESP Station.
Response:
+CIPSTAMAC:<mac>
OK
Set Command:
AT+CIPSTAMAC=<mac>
Function: to set the MAC address of the ESP Station.
Response:
OK
Parameters:
Notes:
Example:
AT+CIPSTAMAC="1a:fe:35:98:d3:7b"
Query Command:
AT+CIPAPMAC?
Function: to obtain the MAC address of the ESP SoftAP.
Response:
+CIPAPMAC:<mac>
OK
Set Command:
AT+CIPAPMAC=<mac>
Function: to set the MAC address of the ESP SoftAP.
Response:
OK
Parameters:
mac: string parameter, MAC address of the ESP8266 SoftAP.
Notes:
Example:
AT+CIPAPMAC="18:fe:35:98:d3:7b"
Query Command:
AT+CIPSTA?
Function: to obtain the IP address of the ESP Station.
Notice: Only when the ESP Station is connected to an AP can its IP address be queried.
Response:
+CIPSTA:<ip>
OK
Set Command:
AT+CIPSTA=<ip>[,<gateway>,<netmask>]
Function: to set the IP address of the ESP Station.
Response:
OK
Parameters:
Notes:
Example:
AT+CIPSTA="192.168.6.100","192.168.6.1","255.255.255.0"
Query Command:
AT+CIPAP?
Function: to obtain the IP address of the ESP SoftAP.
Response:
+CIPAP:<ip>,<gateway>,<netmask>
OK
Set Command:
AT+CIPAP=<ip>[,<gateway>,<netmask>]
Function: to set the IP address of the ESP SoftAP.
Response:
OK
Parameters:
Notes:
Example:
AT+CIPAP="192.168.5.1","192.168.5.1","255.255.255.0"
Execute Command:
AT+CWSTARTSMART
Function: to start SmartConfig. (The type of SmartConfig is ESP-TOUCH + AirKiss.
Set Command:
AT+CWSTARTSMART=<type>
Function: to start SmartConfig of a designated type.
Response:
OK
Parameters:
type:
1: ESP-TOUCH
2: AirKiss
3: ESP-TOUCH+AirKiss
Notes:
Example:
AT+CWMODE=1
AT+CWSTARTSMART
Execute Command:
AT+CWSTOPSMART
Response:
OK
Note:
Irrespective of whether SmartConfig succeeds or not, before executing any other AT commands, please
always call AT+CWSTOPSMART to release the internal memory taken up by SmartConfig.
Example:
AT+CWMODE=1
AT+CWSTARTSMART
AT+CWSTOPSMART
Set Command:
AT+WPS=<enable>
Response:
OK
Parameters:
enable:
1: enable WPS/Wi-Fi Protected Setup (implemented by PBC/Push Button Configuration).
0: disable WPS (implemented by PBC).
Notes:
Example:
AT+CWMODE=1
AT+WPS=1
Set Command:
AT+MDNS=<enable>[,<hostname>,<service_name>,<port>]
Response:
OK
Parameters:
enable:
1: enables the MDNS function; the following three parameters need to be set.
0: disables the MDNS function; the following three parameters need not to be set.
hostname: MDNS host name
service_name : MDNS service name
port: MDNS port
Example:
AT+MDNS=1,"espressif","_iot",8080
AT+MDNS=0
Query Command:
AT+CWJEAP?
Function: to query the Enterprise AP to which the ESP Station is already connected.
Response:
+CWJEAP:<ssid>,<method>,<identity>,<username>,<password>,<security>
OK
Set Command:
AT+CWJEAP=<ssid>,<method>,<identity>,<username>,<password>,<security>
Function: to set the Enterprise AP to which the ESP Station needs to be connected.
Response:
OK
Example:
1. Connect to EAP-TLS mode enterprise AP, set identity, verify server certificate
and load client certificate
AT+CWJEAP="dlink11111",0,"[email protected]",,,3
2. Connect to EAP-PEAP mode enterprise AP, set identity, username and password,
not verify server certificate and not load client certificate
AT+CWJEAP="dlink11111",1,"[email protected]","espressif","test11",0
Note:
Query Command:
AT+CWHOSTNAME?
Function: Checks the host name of ESP Station.
Response:
+CWHOSTNAME:<hostname>
OK
Set Command:
AT+CWHOSTNAME=<hostname>
Function: Sets the host name of ESP Station.
Response:
OK
ERROR
Parameters:
hostname: the host name of the ESP Station, the maximum length is 32 bytes.
Note:
Example:
AT+CWMODE=3
AT+CWHOSTNAME="my_test"
4. TCP/IP-Related AT Commands
Execute Command:
AT+CIPSTATUS
Response:
STATUS:<stat>
+CIPSTATUS:<link ID>,<type>,<remote IP>,<remote port>,<local port>,<tetype>
Parameters:
Execute Command:
AT+CIPDOMAIN=<domain name>
Response:
+CIPDOMAIN:<IP address>
Parameter:
Example:
Set Command:
Response:
OK
Or if the TCP connection is already established, the response is: ALREADY CONNECTTED ERROR Parameters:
TCP keep alive(optional parameter): detection time interval when TCP is kept alive; this function is
disabled by default.
local IP(optional parameter): select which IP want to use, this is useful when using both ethernet and
WiFi; this parameter is disabled by default. If you want to use this parameter, must be specified firstly,
null also is valid.
Examples:
AT+CIPSTART="TCP","iot.espressif.cn",8000
AT+CIPSTART="TCP","192.168.101.110",1000
AT+CIPSTART="TCP","192.168.101.110",1000,,"192.168.101.100"
Set Command:
Response:
OK
Or if the UDP transmission is already established, the response is: ALREADY CONNECTTED ERROR
Parameters:
Notice:
Example:
AT+CIPSTART="UDP","192.168.101.110",1000,1002,2
AT+CIPSTART="UDP","192.168.101.110",1000,,,"192.168.101.100"
Set Command:
Response:
OK
Or if the TCP connection is already established, the response is: ALREADY CONNECTTED ERROR Parameters:
Notes:
Example:
AT+CIPSTART="SSL","iot.espressif.cn",8443
AT+CIPSTART="SSL","192.168.101.110",1000,,"192.168.101.100"
4.4 AT+CIPSTARTEX—Establishes TCP connection, UDP transmission or SSL connection with
automatically assigned ID
This command is similar to AT+CIPSTART, but you need not to assign an ID by yourself when it is the multiple
connections mode (AT+CIPMUX=1), the system will assign an ID to the new connection automatically.
Set Command:
Response:
OK
>
Begin receiving serial data. When the requirement of data length is met, the transmission of data starts. If the
connection cannot be established or gets disrupted during data transmission, the system returns:
ERROR
SEND OK
Execute Command:
AT+CIPSEND
Function: to start sending data in transparent transmission mode.
Response:
OK
>
Enter transparent transmission, with a 20-ms interval between each packet, and a maximum of 2048 bytes per
packet. When a single packet containing +++ is received, ESP returns to normal command mode. Please wait
for at least one second before sending the next AT command. This command can only be used in transparent
transmission mode which requires single connection. For UDP transparent transmission, the value of has to be
0 when using AT+CIPSTART.
Or
ERROR
Parameters:
Set Command:
Response:
OK
>
Send data of designated length. Wrap return > after the set command. Begin receiving serial data. When the
requirement of data length, determined by , is met, or when \0 appears in the data, the transmission starts. If
connection cannot be established or gets disconnected during transmission, the system returns:
ERROR
AT+CIPCLOSE=<link ID>
Function: to close TCP/UDP connection.
Parameters:
link ID: ID number of connections to be closed; when ID=5, all connections will be closed.
AT+CIPCLOSE
Response:
OK
Execute Command:
AT+CIFSR
Response:
+CIFSR:<SoftAP IP address>
+CIFSR:<Station IP address>
OK
Parameters:
IP address:
IP address of the ESP SoftAP;
IP address of the ESP Station.
Notes:
Only when the ESP Station is connected to an AP can the Station IP can be queried.
Query Command:
AT+CIPMUX?
Function: to query the connection type.
Response:
+CIPMUX:<mode>
OK
Set Command:
AT+CIPMUX=<mode>
Function: to set the connection type.
Response:
OK
Parameters:
mode :
0: single connection
1: multiple connections
Notes:
Example:
AT+CIPMUX=1
Set Command:
AT+CIPSERVER=<mode>[,<port>]
Response:
OK
Parameters:
mode :
0: delete server.
1: create server.
port: port number; 333 by default.
Notes:
A TCP server can only be created when multiple connections are activated (AT+CIPMUX=1 ).
A server monitor will automatically be created when the TCP server is created. And only one server is
allowed.
When a client is connected to the server, it will take up one connection and be assigned an ID.
Example:
Query Command:
AT+CIPSERVERMAXCONN?
Function: obtain the maximum number of clients allowed to connect to the TCP
or SSL server.
Response:
+CIPSERVERMAXCONN:<num>
OK
Set Command:
AT+CIPSERVERMAXCONN=<num>
Function: set the maximum number of clients allowed to connect to the TCP
or SSL server.
Response:
OK
Parameters:
num: the maximum number of clients allowed to connect to the TCP or SSL server.
Notes:
To set this configuration, you should call the command AT+CIPSERVERMAXCONN=<num> before creating
a server.
Example:
AT+CIPMUX=1
AT+CIPSERVERMAXCONN=2
AT+CIPSERVER=1,80
Query Command:
AT+CIPMODE?
Function: to obtain information about transmission mode.
Response:
+CIPMODE:<mode>
OK
Set Command:
AT+CIPMODE=<mode>
Function: to set the transmission mode.
Response:
OK
Parameters:
mode :
0: normal transmission mode.
1: UART-Wi-Fi passthrough mode (transparent transmission), which can only be enabled in TCP
single connection mode or in UDP mode when the remote IP and port do not change.
Notes:
Example:
AT+CIPMODE=1
Set Command:
Response:
OK
Parameters:
mode :
0: normal mode, ESP will NOT enter UART-WiFi passthrough mode on power-up.
1: ESP will enter UART-WiFi passthrough mode on power-up.
remote IP: remote IP or domain name.
remote port: remote port.
type(optional parameter): TCP or UDP, TCP by default.
TCP keep alive(optional parameter): TCP is kept alive. This function is disabled by default.
0: disables the TCP keep-alive function.
1 ~ 7200: keep-alive detection time interval; unit: second (s).
Notes:
This command will save the UART-WiFi passthrough mode and its link in the NVS area. ESP will enter
the UART-WiFi passthrough mode on any subsequent power cycles.
As long as the remote IP (or domain name) and port are valid, the configuration will be saved in flash.
Example:
AT+SAVETRANSLINK=1,"192.168.6.110",1002,"TCP"
Set Command:
Response:
OK
Parameters:
mode :
0: normal mode; ESP will NOT enter UART-WiFi passthrough mode on power-up.
1: ESP enters UART-WiFi passthrough mode on power-up.
remote IP: remote IP or domain name.
remote port: remote port.
type(optional parameter): UDP, TCP by default.
UDP local port(optional parameter): local port when UDP transparent transmission is enabled on power-
up.
Notes:
This command will save the UART-WiFi passthrough mode and its link in the NVS area. ESP will enter
the UART-WiFi passthrough mode on any subsequent power cycles.
As long as the remote IP (or domain name) and port are valid, the configuration will be saved in flash.
Example:
AT+SAVETRANSLINK=1,"192.168.6.110",1002,"UDP",1005
Query Command:
AT+CIPSTO?
Function: to check the TCP server timeout.
Response:
+CIPSTO:<time>
OK
Set Command:
AT+CIPSTO=<time>
Function: to set the TCP server timeout.
Response:
OK
Parameter:
Notes:
ESP configured as a TCP server will disconnect from the TCP client that does not communicate with it
until timeout.
If AT+CIPSTO=0 , the connection will never time out. This configuration is not recommended.
Example:
AT+CIPMUX=1
AT+CIPSERVER=1,1001
AT+CIPSTO=10
4.15 AT+CIPSNTPCFG —Sets the Time Zone and the SNTP Server
Query Command:
AT+CIPSNTPCFG?
Response:
Execute Command:
AT+CIPSNTPCFG
Function: to clear the SNTP server information.
Response:
OK
Set Command:
Response:
OK
Parameters:
enable:
1: the SNTP server is configured.
0: the SNTP server is not configured.
timezone: time zone, range: [-11,13].
SNTP server1: the first SNTP server.
SNTP server2: the second SNTP server.
SNTP server3: the third SNTP server.
Note:
If the three SNTP servers are not configured, the following default configuration is used: "cn.ntp.org.cn",
"ntp.sjtu.edu.cn", "us.pool.ntp.org".
Example:
AT+CIPSNTPCFG=8,"cn.ntp.org.cn","ntp.sjtu.edu.cn"
Query Command:
AT+CIPSNTPTIME?
Response:
+CIPSNTPTIME:SNTP time
OK
Example:
AT+CIPSNTPCFG=8,"cn.ntp.org.cn","ntp.sjtu.edu.cn"
OK
AT+CIPSNTPTIME?
+CIPSNTPTIME:Mon Dec 12 02:33:32 2016
OK
Execute Command:
AT+CIUPDATE
Function: OTA the lastest version via TCP from server.
Response:
+CIPUPDATE:<n>
OK
Execute Command:
AT+CIUPDATE=<ota mode>[,version]
Function: OTA the specified version from server.
Response:
+CIPUPDATE:<n>
OK
Parameters:
ota mode:
0: OTA via TCP
1: OTA via SSL, please ensure make menuconfig > Component config > AT > OTA based
upon ssl is enabled.
version: AT version, for example, v1.2.0.0 , v1.1.3.0 , v1.1.2.0
n:
1: find the server.
2: connect to server.
3: get the software version.
4: start updating.
Example:
AT+CIUPDATE
Or
AT+CIUPDATE=1,"v1.2.0.0"
Notes:
Notice:
If using Espressif's AT BIN, AT+CIUPDATE will download a new AT BIN from the Espressif Cloud.
If using a user-compiled AT BIN, users need to implement their own AT+CIUPDATE FOTA function. esp-
at project provides an example of FOTA.
It is suggested that users call AT+RESTORE to restore the factory default settings after upgrading the
AT firmware.
Set Command:
AT+CIPDINFO=<mode>
Response:
OK
Parameters:
mode :
0: does not show the remote IP and port with "+IPD" and "+CIPRECVDATA".
1: shows the remote IP and port with "+IPD" and "+CIPRECVDATA".
Example:
AT+CIPDINFO=1
Command:
Single connection:
(+CIPMUX=0)+IPD,<len>[,<remote IP>,<remote port>]:<data>
multiple connections:
(+CIPMUX=1)+IPD,<link ID>,<len>[,<remote IP>,<remote port>]:<data>
Parameters:
Note:
The command is valid in normal command mode. When the module receives network data, it will send
the data through the serial port using the +IPD command.
Query Command:
AT+CIPSSLCCONF?
Function: to get the configuration of each link that running as SSL client.
Response:
+CIPSSLCCONF:<link ID>,<auth_mode>,<pki_number>,<ca_number>
OK
Set Command:
Response:
OK
Parameters:
link ID: ID of the connection (0~max), for multiple connections, if the value is max, it means all
connections. By default, max is 5.
auth_mode:
0: no authorization.
1: load cert and private key for server authorization.
2: load CA for client authorize server cert and private key.
3: both authorization.
pki_number: the index of cert and private key, if only one cert and private key, the value should be 0.
ca_number: the index of CA, if only one CA, the value should be 0.
Notes:
Call this command before establish SSL connection if you want configuration take effect immediately.
The configuration changes will be saved in the NVS area. If you use AT+SAVETRANSLINK to set SSL
passthrough mode, the ESP will establish an SSL connection based on this configuration after next
power on.
Set Command:
AT+CIPRECONNINTV=<interval>
Function: to set the interval of auto reconnecting when the TCP/UDP/SSL transmission
broke in UART-WiFi transparent mode.
Parameters:
interval : Time interval for automatic reconnection, default is 1, range is 1~36000, unit is 100ms.
Example:
AT+CIPRECONNINTV=10
4.22 +IPD—Receives Network Data
Command:
Single connection:
(+CIPMUX=0)+IPD,<len>[,<remote IP>,<remote port>]:<data>
multiple connections:
(+CIPMUX=1)+IPD,<link ID>,<len>[,<remote IP>,<remote port>]:<data>
Parameters:
Note:
The command is valid in normal command mode. When the module receives network data, it will send
the data through the serial port using the +IPD command.
Query Command:
AT+CIPRECVMODE?
Function: to query socket receive mode.
Response:
+CIPRECVMODE:<mode>
OK
Set Command:
AT+CIPRECVMODE=<mode>
Response:
OK
Parameters: - mode : the receive mode of socket data is active mode by default. - 0: active mode - ESP AT will
send all the received socket data instantly to host MCU through UART with header “+IPD". - 1: passive mode -
ESP AT will keep the received socket data in an internal buffer (default is 5840 bytes), and wait for host MCU
to read the data. If the buffer is full, the socket transmission will be blocked.
Example:
AT+CIPRECVMODE=1
Notes:
The configuration is for TCP and SSL transmission only, and can not be used on WiFi-UART
passthrough mode. If it is a UDP transmission in passive mode data will be missed when buffer full.
If the passive mode is enabled, when ESP AT receives socket data, it will prompt the following message
in different scenarios:
for multiple connection mode (AT+CIPMUX=1), the message is: +IPD,<link ID>,<len>
for single connection mode (AT+CIPMUX=0), the message is: +IPD,<len>
<len> is the total length of socket data in buffer
Set Command:
Response:
+CIPRECVDATA:<actual_len>,<data>
OK
or
Parameters: - link_id: connection ID in multiple connection mode. -len : data length that you want to get, max is
2048 bytes per time. - actual_len: length of the data you actually get -data: the data you get - remote IP: remote
IP string, enabled by command AT+CIPDINFO=1 . - remote port: remote port, enabled by command
AT+CIPDINFO=1 .
Example:
AT+CIPRECVMODE=1
For example, if host MCU gets a message of receiving 100 bytes data in connection
with No.0, the message will be as following: +IPD,0,100
then you can read those 100 bytes by using the command below
AT+CIPRECVDATA=0,100
Notes:
In a case of disconnection, the buffered Socket data will still be there and can be read by MCU until you
send AT+CIPCLOSE , or a new connection occupied the previous link_id instead.
Query Command:
AT+CIPRECVLEN?
Function: query the length of the entire data buffered for the link.
Response:
Parameters: - data length of link: length of the entire data buffered for the link
Example:
AT+CIPRECVLEN?
+CIPRECVLEN:100,,,,,
OK
Notes:
For ssl link, it will return the length of encrypted data, so the returned length will be more than the real
data length.
Set Command:
AT+PING=<IP>
Function: Ping packets.
Response:
+PING:<time>
OK
or
+timeout
ERROR
Parameters: - IP : string; host IP or domain name -time: the response time of ping, unit: millisecond.
Example:
AT+PING="192.168.1.1"
AT+PING="www.baidu.com"
Query Command:
AT+CIPDNS?
Function: to obtain current Domain Name System information.
Response:
Set Command:
Response:
OK
or
ERROR
Parameters: - enable: - 0: Enable automatic DNS settings from DHCP, the DNS will be restore to
222.222.67.208 , only when DHCP is updated will it take effect. - 1: Enable manual DNS settings, if not set
DNS IP , It will use 222.222.67.208 by default. - DNS IP1: the first DNS IP. For set command, only for
manual DNS settings; for query command, it is current DNS setting. - DNS IP2: the second DNS IP. For set
command, only for manual DNS settings; for query command, it is current DNS setting. - DNS IP3: the third
DNS IP. For set command, only for manual DNS settings; for query command, it is current DNS setting.
Example:
AT+CIPDNS=0
AT+CIPDNS=1,"222.222.67.208","114.114.114.114","8.8.8.8"
Notes:
Set Command:
AT+MQTTUSERCFG=<LinkID>,<scheme>,<"client_id">,<"username">,<"password">,<cert_key_ID>,
<CA_ID>,<"path">
Function:
Response:
OK
Parameters:
Note:
The total length of the entire AT command should be less than 256Bytes.
Set Command:
AT+MQTTCLIENTID=<LinkID><"client_id">
Function:
Set MQTT Client ID, will cover the parameter client_id in AT+MQTTUSERCFG
User can set a long client id by AT+MQTTCLIENTID.
Response:
OK
Parameters:
Note:
The total length of the entire AT command should be less than 256Bytes.
AT+MQTTCLIENTID command only could be set after AT+MQTTUSERCFG command
Set Command:
AT+MQTTUSERNAME=<LinkID><"client_id">
Function:
Set MQTT Username, will cover the parameter username in AT+MQTTUSERCFG
User can set a long username by AT+MQTTUSERNAME.
Response:
OK
Parameters:
Note:
The total length of the entire AT command should be less than 256Bytes.
AT+MQTTUSERNAME command only could be set after AT+MQTTUSERCFG command
Set Command:
AT+MQTTPASSWORD=<LinkID><"password">
Function:
Response:
OK
Parameters:
Note:
The total length of the entire AT command should be less than 256Bytes.
AT+MQTTPASSWORD command only could be set after AT+MQTTUSERCFG command
Set Command:
AT+MQTTCONNCFG=<LinkID>,<keepalive>,<disable_clean_session>,<"lwt_topic">,<"lwt_msg">,
<lwt_qos>,<lwt_retain>
Function:
Response:
OK
Parameters:
Set Command:
AT+MQTTCONN=<LinkID>,<"host">,<port>,<reconnect>
Function:
Response:
OK
Query Command:
AT+MQTTCONN?
Function:
Get the MQTT broker that the ESP chip connected to.
Response:
+MQTTCONN:<LinkID>,<state>,<scheme><"host">,<port>,<"path">,<reconnect>
OK
Parameters:
Set Command:
AT+MQTTPUB=<LinkID>,<"topic">,<"data">,<qos>,<retain>
Function:
Publish MQTT message in string to defined topic. If you need to publish message
in binary, please use command `AT+MQTTPUBRAW` instead.
Response:
OK
Parameters:
Note:
The total length of the entire AT command should be less than 256Bytes.
This command cannot send data \0 , if you need to send \0 , please use command AT+MQTTPUBRAW
instead.
Set Command:
AT+MQTTPUBRAW=<LinkID>,<"topic">,<length>,<qos>,<retain>
Function:
Response:
OK
>
Wrap return > after the Set Command. Begin receiving serial data. The AT firmware will keep waiting until the
data length defined by is met, all data received will be considered as the MQTT publish message. When the
data is met, the transmission of data starts. And then it will respond as the following message.
+MQTTPUB:FAIL
Or
+MQTTPUB:OK
Parameters:
Set Command:
AT+MQTTSUB=<LinkID>,<"topic">,<qos>
Function:
Response:
OK
+MQTTSUBRECV:<LinkID>,<"topic">,<data_length>,data
Query Command:
AT+MQTTSUB?
Function:
Response:
+MQTTSUB:<LinkID>,<state>,<"topic1">,<qos>
+MQTTSUB:<LinkID>,<state>,<"topic2">,<qos>
+MQTTSUB:<LinkID>,<state>,<"topic3">,<qos>
...
OK
Parameters:
Set Command:
AT+MQTTUNSUB=<LinkID>,<"topic">
Function:
Unsubscribe the client from defined topic. This command can be called multiple times
to unsubscribe from differrent topics.
Response:
OK
Parameters:
Note:
If the topic has not been subscribed, then the AT log will promptNO UNSUBSCRIBE . And the AT
command will still respond OK .
AT+MQTTCLEAN=<LinkID>
Function:
Response:
OK
Parameters:
AT_MQTT_NO_CONFIGURED, // 0x6001
AT_MQTT_NOT_IN_CONFIGURED_STATE, // 0x6002
AT_MQTT_UNINITIATED_OR_ALREADY_CLEAN, // 0x6003
AT_MQTT_ALREADY_CONNECTED, // 0x6004
AT_MQTT_MALLOC_FAILED, // 0x6005
AT_MQTT_NULL_LINK, // 0x6006
AT_MQTT_NULL_PARAMTER, // 0x6007
AT_MQTT_PARAMETER_COUNTS_IS_WRONG, // 0x6008
AT_MQTT_TLS_CONFIG_ERROR, // 0x6009
AT_MQTT_PARAM_PREPARE_ERROR, // 0x600A
AT_MQTT_CLIENT_START_FAILED, // 0x600B
AT_MQTT_CLIENT_PUBLISH_FAILED, // 0x600C
AT_MQTT_CLIENT_SUBSCRIBE_FAILED, // 0x600D
AT_MQTT_CLIENT_UNSUBSCRIBE_FAILED, // 0x600E
AT_MQTT_CLIENT_DISCONNECT_FAILED, // 0x600F
AT_MQTT_LINK_ID_READ_FAILED, // 0x6010
AT_MQTT_LINK_ID_VALUE_IS_WRONG, // 0x6011
AT_MQTT_SCHEME_READ_FAILED, // 0x6012
AT_MQTT_SCHEME_VALUE_IS_WRONG, // 0x6013
AT_MQTT_CLIENT_ID_READ_FAILED, // 0x6014
AT_MQTT_CLIENT_ID_IS_NULL, // 0x6015
AT_MQTT_CLIENT_ID_IS_OVERLENGTH, // 0x6016
AT_MQTT_USERNAME_READ_FAILED, // 0x6017
AT_MQTT_USERNAME_IS_NULL, // 0x6018
AT_MQTT_USERNAME_IS_OVERLENGTH, // 0x6019
AT_MQTT_PASSWORD_READ_FAILED, // 0x601A
AT_MQTT_PASSWORD_IS_NULL, // 0x601B
AT_MQTT_PASSWORD_IS_OVERLENGTH, // 0x601C
AT_MQTT_PASSWORD_IS_OVERLENGTH, // 0x601C
AT_MQTT_CERT_KEY_ID_READ_FAILED, // 0x601D
AT_MQTT_CERT_KEY_ID_VALUE_IS_WRONG, // 0x601E
AT_MQTT_CA_ID_READ_FAILED, // 0x601F
AT_MQTT_CA_ID_VALUE_IS_WRONG, // 0x6020
AT_MQTT_CA_LENGTH_ERROR, // 0x6021
AT_MQTT_CA_READ_FAILED, // 0x6022
AT_MQTT_CERT_LENGTH_ERROR, // 0x6023
AT_MQTT_CERT_READ_FAILED, // 0x6024
AT_MQTT_KEY_LENGTH_ERROR, // 0x6025
AT_MQTT_KEY_READ_FAILED, // 0x6026
AT_MQTT_PATH_READ_FAILED, // 0x6027
AT_MQTT_PATH_IS_NULL, // 0x6028
AT_MQTT_PATH_IS_OVERLENGTH, // 0x6029
AT_MQTT_VERSION_READ_FAILED, // 0x602A
AT_MQTT_KEEPALIVE_READ_FAILED, // 0x602B
AT_MQTT_KEEPALIVE_IS_NULL, // 0x602C
AT_MQTT_KEEPALIVE_VALUE_IS_WRONG, // 0x602D
AT_MQTT_DISABLE_CLEAN_SESSION_READ_FAILED, // 0x602E
AT_MQTT_DISABLE_CLEAN_SESSION_VALUE_IS_WRONG, // 0x602F
AT_MQTT_LWT_TOPIC_READ_FAILED, // 0x6030
AT_MQTT_LWT_TOPIC_IS_NULL, // 0x6031
AT_MQTT_LWT_TOPIC_IS_OVERLENGTH, // 0x6032
AT_MQTT_LWT_MSG_READ_FAILED, // 0x6033
AT_MQTT_LWT_MSG_IS_NULL, // 0x6034
AT_MQTT_LWT_MSG_IS_OVERLENGTH, // 0x6035
AT_MQTT_LWT_QOS_READ_FAILED, // 0x6036
AT_MQTT_LWT_QOS_VALUE_IS_WRONG, // 0x6037
AT_MQTT_LWT_RETAIN_READ_FAILED, // 0x6038
AT_MQTT_LWT_RETAIN_VALUE_IS_WRONG, // 0x6039
AT_MQTT_HOST_READ_FAILED, // 0x603A
AT_MQTT_HOST_IS_NULL, // 0x603B
AT_MQTT_HOST_IS_OVERLENGTH, // 0x603C
AT_MQTT_PORT_READ_FAILED, // 0x603D
AT_MQTT_PORT_VALUE_IS_WRONG, // 0x603E
AT_MQTT_RECONNECT_READ_FAILED, // 0x603F
AT_MQTT_RECONNECT_VALUE_IS_WRONG, // 0x6040
AT_MQTT_TOPIC_READ_FAILED, // 0x6041
AT_MQTT_TOPIC_IS_NULL, // 0x6042
AT_MQTT_TOPIC_IS_OVERLENGTH, // 0x6043
AT_MQTT_DATA_READ_FAILED, // 0x6044
AT_MQTT_DATA_IS_NULL, // 0x6045
AT_MQTT_DATA_IS_OVERLENGTH, // 0x6046
AT_MQTT_QOS_READ_FAILED, // 0x6047
AT_MQTT_QOS_VALUE_IS_WRONG, // 0x6048
AT_MQTT_RETAIN_READ_FAILED, // 0x6049
AT_MQTT_RETAIN_VALUE_IS_WRONG, // 0x604A
AT_MQTT_PUBLISH_LENGTH_READ_FAILED, // 0x604B
AT_MQTT_PUBLISH_LENGTH_VALUE_IS_WRONG, // 0x604C
AT_MQTT_RECV_LENGTH_IS_WRONG, // 0x604D
AT_MQTT_RECV_LENGTH_IS_WRONG, // 0x604D
AT_MQTT_CREATE_SEMA_FAILED, // 0x604E
AT_MQTT_CREATE_EVENT_GROUP_FAILED, // 0x604F
In general, AT MQTT commands will be responded within 10s, except command AT+MQTTCONN .For
example, if the router fails to access to the internet, the command AT+MQTTPUB will respond within 10s.
But the command AT+MQTTCONN may need more time due to the packet retransmission in bad network
environment.
If the AT+MQTTCONN is based on a TLS connection, the timeout of each packet is 10s, then the total
timeout will be much longer depending on the handshake packets count.
When the MQTT connection ends, it will prompt message +MQTTDISCONNECTED:<LinkID>
When the MQTT connection established, it will prompt message +MQTTCONNECTED:<LinkID>,
<scheme>,<"host">,port,<"path">,<reconnect>
Create a local MQTT broker. For example, the MQTT broker's IP address is "192.168.31.113", port 1883. Then
the example of communicating with the MQTT broker will be as the following steps.
AT+MQTTUSERCFG=0,1,"ESP","espressif","1234567890",0,0,""
AT+MQTTCONN=0,"192.168.31.113",1883,0
AT+MQTTSUB=0,"topic",1
AT+MQTTPUB=0,"topic","test",1,0
AT+MQTTCLEAN=0
Create a local MQTT broker. For example, the MQTT broker's IP address is "192.168.31.113", port 1883. Then
the example of communicating with the MQTT broker will be as the following steps.
AT+CIPSNTPCFG=1,8,"ntp1.aliyun.com"
AT+CIPSNTPTIME?
AT+MQTTUSERCFG=0,3,"ESP","espressif","1234567890",0,0,""
AT+MQTTCONNCFG=0,0,0,"lwtt","lwtm",0,0
AT+MQTTCONN=0,"192.168.31.113",1883,0
AT+MQTTSUB=0,"topic",1
AT+MQTTPUB=0,"topic","test",1,0
AT+MQTTCLEAN=0
This is an example of communicating with MQTT broker: iot.eclipse.org, of which port is 443.
AT+CIPSNTPCFG=1,8,"ntp1.aliyun.com"
AT+CIPSNTPTIME?
AT+MQTTUSERCFG=0,7,"ESP","espressif","1234567890",0,0,"wss"
AT+MQTTCONN=0,"iot.eclipse.org",443,0
AT+MQTTSUB=0,"topic",1
AT+MQTTPUB=0,"topic","test",1,0
AT+MQTTCLEAN=0