AT+CIPV6: Enable/disable the network of Internet Protocol Version 6 (IPv6).
AT+CIPSTATE: Obtain the TCP/UDP/SSL connection information.
AT+CIPDOMAIN: Resolve a Domain Name.
AT+CIPSTART: Establish TCP connection, UDP transmission, or SSL connection.
AT+CIPSTARTEX: Establish TCP connection, UDP transmission, or SSL connection with an automatically assigned ID.
[Data Mode Only] +++: Exit from the data mode.
AT+SAVETRANSLINK: Set whether to enter Wi-Fi Passthrough Mode on power-up.
AT+CIPSEND: Send data in the normal transmission mode or Wi-Fi normal transmission mode.
AT+CIPSENDL: Send long data in parallel in the normal transmission mode.
AT+CIPSENDLCFG: Set the configuration for the command AT+CIPSENDL.
AT+CIPSENDEX: Send data in the normal transmission mode in expanded ways.
AT+CIPCLOSE: Close TCP/UDP/SSL connection.
AT+CIFSR: Obtain the local IP address and MAC address.
AT+CIPMUX: Enable/disable the multiple connections mode.
AT+CIPSERVER: Delete/create a TCP/SSL server.
AT+CIPSERVERMAXCONN: Query/Set the maximum connections allowed by a server.
AT+CIPMODE: Query/Set the transmission mode.
AT+CIPSTO: Query/Set the local TCP Server Timeout.
AT+CIPSNTPCFG: Query/Set the time zone and SNTP server.
AT+CIPSNTPTIME: Query the SNTP time.
AT+CIPSNTPINTV: Query/Set the SNTP time synchronization interval.
AT+CIPFWVER: Query the existing AT firmware version on the server.
AT+CIUPDATE: Upgrade the firmware through Wi-Fi.
AT+CIPDINFO: Set â+IPDâ message mode.
AT+CIPSSLCCONF: Query/Set SSL clients.
AT+CIPSSLCCIPHER: Query/Set the cipher suite of the SSL client.
AT+CIPSSLCCN: Query/Set the Common Name of the SSL client.
AT+CIPSSLCSNI: Query/Set SSL client Server Name Indication (SNI).
AT+CIPSSLCALPN: Query/Set SSL client Application Layer Protocol Negotiation (ALPN).
AT+CIPSSLCPSK: Query/Set SSL client Pre-shared Key (PSK) in string format.
AT+CIPSSLCPSKHEX: Query/Set SSL client Pre-shared Key (PSK) in hexadecimal format.
AT+CIPRECONNINTV: Query/Set the TCP/UDP/SSL reconnection interval for the Wi-Fi normal transmission mode.
AT+CIPRECVTYPE: Query/Set socket receiving mode.
AT+CIPRECVDATA: Obtain socket data in passive receiving mode.
AT+CIPRECVLEN: Obtain socket data length in passive receiving mode.
AT+PING: Ping the remote host.
AT+CIPDNS: Query/Set DNS server information.
AT+MDNS: Configure the mDNS function.
AT+CIPTCPOPT: Query/Set the socket options.
Important
The default AT firmware supports all the AT commands mentioned on this page. If you need to modify the commands supported by ESP32 by default, please compile the ESP-AT project by following the steps in Compile ESP-AT Project Locally documentation. In the project configuration during the fifth step, make the following selections (Each item below is independent. Choose it according to your needs):
Disable OTA commands (AT+CIUPDATE and AT+CIPFWVER): Component config
-> AT
-> AT OTA command support
Disable PING commands (AT+PING): Component config
-> AT
-> AT ping command support
Disable mDNS commands (AT+MDNS): Component config
-> AT
-> AT MDNS command support
Disable TCP/IP commands (Not recommended. Once disabled, all TCP/IP functions will be unavailable and you will need to implement these AT commands yourself): Component config
-> AT
-> AT net command support
Function:
Query whether IPv6 is enabled.
Command:
Response:
Set CommandïFunction:
Enable/Disable IPv6 network.
Command:
Response:
Parametersï<enable>: status of IPv6 network. Default: 0.
0: disable IPv6 network.
1: enable IPv6 network.
The configuration changes will be saved in the NVS partition if AT+SYSSTORE=1
.
You should enable IPv6 network before using IPv6 related upper layer AT commands (TCP/UDP/SSL/PING/DNS based on IPv6 network, also known as TCP6/UDP6/SSL6/PING6/DNS6 or TCPv6/UDPv6/SSLv6/PINGv6/DNSv6).
Command:
Response:
When there is a connection, AT returns:
+CIPSTATE:<link ID>,<"type">,<"remote IP">,<remote port>,<local port>,<tetype> OK
When there is no connection, AT returns:
Parametersï<link ID>: ID of the connection (0~4), used for multiple connections.
<âtypeâ>: string parameter showing the type of transmission: âTCPâ, âTCPv6â, âUDPâ, âUDPv6â, âSSLâ, or âSSLv6â.
<âremote IPâ>: string parameter showing the remote IPv4 address or IPv6 address.
<remote port>: the remote port number.
<local port>: the local port number.
<tetype>:
0: ESP32 runs as a client.
1: ESP32 runs as a server.
Command:
AT+CIPDOMAIN=<"domain name">[,<ip network>][,<timeout>]
Response:
+CIPDOMAIN:<"IP address"> OKParameterï
<âdomain nameâ>: the domain name.
<ip network>: preferred IP network. Default: 1.
1: preferred resolution of IPv4 address
2: resolve IPv4 address only
3: resolve IPv6 address only
<âIP addressâ>: the resolved IPv4 address or IPv6 address.
<timeout>: Command timeout. Unit: milliseconds. Default value: 0. Range: [0,60000]. When set to 0, the command timeout depends on the network and lwIP protocol stack; when set to a non-zero value, the command will return within the specified timeout, but it will consume about 5 KB more heap space.
AT+CWMODE=1 // set the station mode AT+CWJAP="SSID","password" // access to the internet AT+CIPDOMAIN="iot.espressif.cn" // Domain Name Resolution function // Domain Name Resolution Function for IPv4 address only AT+CIPDOMAIN="iot.espressif.cn",2 // Domain Name Resolution Function for IPv6 address only AT+CIPDOMAIN="ipv6.test-ipv6.com",3 // Domain Name Resolution Function for compatible IP address AT+CIPDOMAIN="ds.test-ipv6.com",1AT+CIPSTART: Establish TCP Connection, UDP Transmission, or SSL Connectionï Establish TCP Connectionï Set Commandï
Command:
// Single connection (AT+CIPMUX=0): AT+CIPSTART=<"type">,<"remote host">,<remote port>[,<keep_alive>][,<"local IP">][,<timeout>] // Multiple Connections (AT+CIPMUX=1): AT+CIPSTART=<link ID>,<"type">,<"remote host">,<remote port>[,<keep_alive>][,<"local IP">][,<timeout>]
Response:
For single connection, it returns:
For multiple connections, it returns:
Parametersï<link ID>: ID of network connection (0~4), used for multiple connections. The range of this parameter depends on two configuration items in menuconfig
. One is AT_SOCKET_MAX_CONN_NUM
of the AT
component, and its default value is 5. The other is LWIP_MAX_SOCKETS
of the LWIP
component, and its default value is 10. To modify the range of this parameter, you need to set AT_SOCKET_MAX_CONN_NUM
and make sure it is no larger than the value of LWIP_MAX_SOCKETS
. (See Compile ESP-AT Project Locally for details on configuring and build ESP-AT projects.)
<âtypeâ>: string parameter showing the type of transmission: âTCPâ, or âTCPv6â. Default: âTCPâ.
<âremote hostâ>: IPv4 address, IPv6 address, or domain name of remote host. The maximum length is 64 bytes. If you need to use a domain name and the length of the domain name exceeds 64 bytes, use the AT+CIPDOMAIN command to obtain the IP address corresponding to the domain name, and then use the IP address to establish a connection.
<remote port>: the remote port number.
<keep_alive>: It configures the SO_KEEPALIVE option for socket. Unit: second.
Range: [0,7200].
0: disable keep-alive function (default).
1 ~ 7200: enable keep-alive function. TCP_KEEPIDLE value is <keep_alive>, TCP_KEEPINTVL value is 1, and TCP_KEEPCNT value is 3.
This parameter of this command is the same as the <keep_alive>
parameter of AT+CIPTCPOPT command. It always takes the value set later by either of the two commands. If it is omitted or not set, the last configured value is used by default.
<âlocal IPâ>: the local IPv4 address or IPv6 address that the connection binds. This parameter is useful when you are using multiple network interfaces or multiple IP addresses. By default, it is disabled. If you want to use it, you should specify it first. Null is also valid.
<timeout>: Command timeout. Unit: milliseconds. Default value: 0. Range: [0,60000]. When set to 0, the command timeout depends on the network and lwIP protocol stack; when set to a non-zero value, the command will return within the specified timeout, but it will consume about 5 KB more heap space.
To establish a TCP connection based on an IPv6 network, do as follows:
Make sure that the AP supports IPv6
Set AT+CIPV6=1
Obtain an IPv6 address through the AT+CWJAP command
(Optional) Check whether ESP32 has obtained an IPv6 address using the AT+CIPSTA? command
AT+CIPSTART="TCP","iot.espressif.cn",8000 AT+CIPSTART="TCP","192.168.101.110",1000 AT+CIPSTART="TCP","192.168.101.110",2500,60 AT+CIPSTART="TCP","192.168.101.110",1000,,"192.168.101.100" // Connect to GitHub's TCP server with a 5-second timeout AT+CIPSTART="TCP","www.github.com",80,,,5000 AT+CIPSTART="TCPv6","test-ipv6.com",80 AT+CIPSTART="TCPv6","fe80::860d:8eff:fe9d:cd90",1000,,"fe80::411c:1fdb:22a6:4d24" // esp-at has obtained an IPv6 global address by AT+CWJAP before AT+CIPSTART="TCPv6","2404:6800:4005:80b::2004",80,,"240e:3a1:2070:11c0:32ae:a4ff:fe80:65ac"Establish UDP Transmissionï Set Commandï
Command:
// Single connection (AT+CIPMUX=0): AT+CIPSTART=<"type">,<"remote host">,<remote port>[,<local port>,<mode>,<"local IP">][,<timeout>] // Multiple connections (AT+CIPMUX=1): AT+CIPSTART=<link ID>,<"type">,<"remote host">,<remote port>[,<local port>,<mode>,<"local IP">][,<timeout>]
Response:
For single connection, it returns:
For multiple connections, it returns:
Parametersï<link ID>: ID of network connection (0~4), used for multiple connections.
<âtypeâ>: string parameter showing the type of transmission: âUDPâ, or âUDPv6â. Default: âTCPâ.
<âremote hostâ>: IPv4 address, IPv6 address, or domain name of remote host. The maximum length is 64 bytes. If you need to use a domain name and the length of the domain name exceeds 64 bytes, use the AT+CIPDOMAIN command to obtain the IP address corresponding to the domain name, and then use the IP address to establish a connection.
<remote port>: remote port number.
<local port>: UDP port of ESP32.
<mode>: In the UDP Wi-Fi passthrough, the value of this parameter has to be 0.
0: After UDP data is received, the parameters <"remote host">
and <remote port>
will stay unchanged (default).
1: Only the first time that UDP data is received from an IP address and port that are different from the initially set value of parameters <remote host>
and <remote port>
, will they be changed to the IP address and port of the device that sends the data.
2: Each time UDP data is received, the <"remote host">
and <remote port>
will be changed to the IP address and port of the device that sends the data.
<âlocal IPâ>: the local IPv4 address or IPv6 address that the connection binds. This parameter is useful when you are using multiple network interfaces or multiple IP addresses. By default, it is disabled. If you want to use it, you should specify it first. Null is also valid.
<timeout>: Command timeout. Unit: milliseconds. Default value: 0. Range: [0,60000]. When set to 0, the command timeout depends on the network and lwIP protocol stack; when set to a non-zero value, the command will return within the specified timeout, but it will consume about 5 KB more heap space.
If the remote host over the UDP is an IPv4 multicast address (224.0.0.0 ~ 239.255.255.255), the ESP32 will send and receive the UDPv4 multicast.
If the remote host over the UDP is an IPv4 broadcast address (255.255.255.255), the ESP32 will send and receive the UDPv4 broadcast.
If the remote host over the UDP is an IPv6 multicast address (FF00:0:0:0:0:0:0:0 ~ FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF), the ESP32 will send and receive the UDP multicast based on IPv6 network.
To use the parameter <mode>
, parameter <local port>
must be set first.
To establish an UDP transmission based on an IPv6 network, do as follows:
Make sure that the AP supports IPv6
Set AT+CIPV6=1
Obtain an IPv6 address through the AT+CWJAP command
(Optional) Check whether ESP32 has obtained an IPv6 address using the AT+CIPSTA? command
If you want to receive a UDP packet longer than 1460 bytes, please compile the firmware on your own by following Compile ESP-AT Project and choosing the following configurations in the Step 5. Configure: Component config
-> LWIP
-> Enable reassembly incoming fragmented IP4 packets
.
// UDP unicast AT+CIPSTART="UDP","192.168.101.110",1000,1002,2 AT+CIPSTART="UDP","192.168.101.110",1000,,,"192.168.101.100" // Establish UDP transmission with pool.ntp.org, set 5-second timeout AT+CIPSTART="UDP","pool.ntp.org",123,,,,5000 // UDP unicast based on IPv6 network AT+CIPSTART="UDPv6","fe80::32ae:a4ff:fe80:65ac",1000,,,"fe80::5512:f37f:bb03:5d9b" // UDP multicast based on IPv6 network AT+CIPSTART="UDPv6","FF02::FC",1000,1002,0Establish SSL Connectionï Set Commandï
Command:
// Single connection (AT+CIPMUX=0): AT+CIPSTART=<"type">,<"remote host">,<remote port>[,<keep_alive>,<"local IP">][,<timeout>] // Multiple connections (AT+CIPMUX=1): AT+CIPSTART=<link ID>,<"type">,<"remote host">,<remote port>[,<keep_alive>,<"local IP">][,<timeout>]
Response:
For single connection, it returns:
For multiple connections, it returns:
Parametersï<link ID>: ID of network connection (0~4), used for multiple connections.
<âtypeâ>: string parameter showing the type of transmission: âSSLâ, or âSSLv6â. Default: âTCPâ.
<âremote hostâ>: IPv4 address, IPv6 address, or domain name of remote host. The maximum length is 64 bytes. If you need to use a domain name and the length of the domain name exceeds 64 bytes, use the AT+CIPDOMAIN command to obtain the IP address corresponding to the domain name, and then use the IP address to establish a connection.
<remote port>: the remote port number.
<keep_alive>: It configures the SO_KEEPALIVE option for socket. Unit: second.
Range: [0,7200].
0: disable keep-alive function (default).
1 ~ 7200: enable keep-alive function. TCP_KEEPIDLE value is <keep_alive>, TCP_KEEPINTVL value is 1, and TCP_KEEPCNT value is 3.
This parameter of this command is the same as the <keep_alive>
parameter of AT+CIPTCPOPT command. It always takes the value set later by either of the two commands. If it is omitted or not set, the last configured value is used by default.
<âlocal IPâ>: the local IPv4 address or IPv6 address that the connection binds. This parameter is useful when you are using multiple network interfaces or multiple IP addresses. By default, it is disabled. If you want to use it, you should specify it first. Null is also valid.
<timeout>: Command timeout. Unit: milliseconds. Default value: 0. Range: [0,60000]. When set to 0, the command timeout depends on the network and lwIP protocol stack; when set to a non-zero value, the command will return within the specified timeout, but it will consume about 5 KB more heap space.
The number of SSL connections depends on available memory and the maximum number of connections.
SSL connection needs a large amount of memory. Insufficient memory may cause the system reboot.
If the AT+CIPSTART
is based on an SSL connection and the timeout of each packet is 10 s, the total timeout will be much longer depending on the number of handshake packets.
Some SSL servers require the SSL client to support the SNI extension field during connection. Please configure SNI using the AT+CIPSSLCSNI command before establishing an SSL connection. Typically, the value of SNI is the domain name of the server.
To establish a SSL connection based on an IPv6 network, do as follows:
Make sure that the AP supports IPv6
Set AT+CIPV6=1
Obtain an IPv6 address through the AT+CWJAP command
(Optional) Check whether ESP32 has obtained an IPv6 address using the AT+CIPSTA? command
AT+CIPSTART="SSL","iot.espressif.cn",8443 AT+CIPSTART="SSL","192.168.101.110",1000,,"192.168.101.100" // Connect to Microsoft Bing's SSL server with a 5-second timeout AT+CIPSTART="SSL","www.bing.com",443,,,5000 // esp-at has obtained an IPv6 global address by AT+CWJAP before AT+CIPSTART="SSLv6","240e:3a1:2070:11c0:6972:6f96:9147:d66d",1000,,"240e:3a1:2070:11c0:55ce:4e19:9649:b75"AT+CIPSTARTEX: Establish TCP connection, UDP transmission, or SSL connection with an Automatically Assigned IDï
This command is similar to AT+CIPSTART except that you do not need to assign an ID by yourself in multiple connections mode (AT+CIPMUX=1). The system will assign an ID to the new connection automatically.
[Data Mode Only] +++: Exit from Data Modeï Special Execute CommandïFunction:
Exit from Data Mode and enter the Command Mode.
Command:
// Only for data mode +++Notesï
This special execution command consists of three identical +
characters (0x2b ASCII), and no CR-LF appends to the command tail.
Make sure there is more than 20 ms interval before the first +
character, more than 20 ms interval after the third +
character, less than 20 ms interval among the three +
characters. Otherwise, the +
characters will be sent out as normal data.
This command returns no reply.
Please wait for at least one second before sending the next AT command.
Function:
Set the data length to be send in the Normal Transmission Mode. If the length of data you need to send exceeds 8192 bytes, please use the AT+CIPSENDL command.
Command:
// Single connection: (AT+CIPMUX=0) AT+CIPSEND=<length> // Multiple connections: (AT+CIPMUX=1) AT+CIPSEND=<link ID>,<length> // Remote host and port can be set for UDP transmission: AT+CIPSEND=[<link ID>,]<length>[,<"remote host">,<remote port>]
Response:
This response indicates that AT is ready for receiving serial data. You should enter the data, and when the data length reaches the <length>
value, the transmission of data starts.
If the connection cannot be established or is disrupted during data transmission, the system returns:
If the data has been successfully sent to the protocol stack (It does not mean that the data has been sent to the opposite end), the system returns:
Execute CommandïFunction:
Enter the Wi-Fi Passthrough Mode.
Command:
Response:
or
Enter the Wi-Fi Passthrough Mode. The ESP32 can receive 8192 bytes and send 2920 bytes at most each time. If the data received by ESP32 reaches or exceeds 2920 bytes, the data will be immediately sent in chunks of 2920 bytes. Otherwise, it will wait for 20 milliseconds before being sent (You can configure this interval using AT+TRANSINTVL command). When a single packet containing +++ is received, the ESP32 will exit the data sending mode under the Wi-Fi Passthrough Mode. Please wait for at least one second before sending the next AT command.
This command can only be used for single connection in the Wi-Fi Passthrough Mode. For UDP Wi-Fi passthrough, the <mode>
parameter has to be 0 when using AT+CIPSTART.
<link ID>: ID of the connection (0~4), for multiple connections.
<length>: data length. Maximum: 8192 bytes.
<âremote hostâ>: IPv4 address, IPv6 address, or domain name of remote host. It can be set in UDP transmission.
<remote port>: the remote port number.
You can use AT+CIPTCPOPT command to configure socket options for each TCP connection. For example, setting <so_sndtimeo> to 5000 will enable TCP send operation to return results within 5 seconds, regardless of success or failure. This can save the time that the MCU waits for AT command response.
Function:
In the Normal Transmission Mode, set the data length to be sent, and then send data to remote host in parallel (the AT command port receives data in parallel with the AT sending data to the remote host). You can use the AT+CIPSENDLCFG command to configure this command. If the length of data you need to send is less than 8192 bytes, you also can use the AT+CIPSEND command.
Command:
// Single connection: (AT+CIPMUX=0) AT+CIPSENDL=<length> // Multiple connections: (AT+CIPMUX=1) AT+CIPSENDL=<link ID>,<length> // Remote host and port can be set for UDP transmission: AT+CIPSENDL=[<link ID>,]<length>[,<"remote host">,<remote port>]
Response:
This response indicates that AT enters the Data Mode and AT command port is ready to receive data. You can enter the data now. Once the port receives data, it will be pushed to underlying protocol stack and the transmission starts.
If the transmission starts, the system reports message according to AT+CIPSENDLCFG configuration:
+CIPSENDL:<had sent len>,<port recv len>
If the transmission is cancelled by +++ command, the system returns:
If not all the data has been sent out, the system finally returns:
If the data has been successfully sent to the protocol stack (It does not mean that the data has been sent to the opposite end), the system finally returns:
When the connection is disconnected, you can send +++ command to cancel the transmission, then the ESP32 will exit from the Data Mode, otherwise, the Data Mode will not end until the AT command port receives all the data of the specified <length>
.
<link ID>: ID of the connection (0~4), for multiple connections.
<length>: data length. Maximum: 2 31 - 1 bytes.
<âremote hostâ>: IPv4 address, IPv6 address, or domain name of remote host. It can be set in UDP transmission.
<remote port>: the remote port number.
<had sent len>: the length of data successfully sent to the underlying protocol stack.
<port recv len>: data length received by AT command port.
It is recommended to use UART flow control, because if the UART receives data at a faster rate than the network sends, data loss may occur.
You can use AT+CIPTCPOPT command to configure socket options for each TCP connection. For example, setting <so_sndtimeo> to 5000 will enable TCP send operation to return results within 5 seconds, regardless of success or failure. This can save the time that the MCU waits for AT command response.
Function:
Query the configuration of AT+CIPSENDL.
Command:
Response:
+CIPSENDLCFG:<report size>,<transmit size> OKSet Commandï
Function:
Set the configuration of AT+CIPSENDL.
Command:
AT+CIPSENDLCFG=<report size>[,<transmit size>]
Response:
Parametersï<report size>: report block size for AT+CIPSENDL. Default: 1024. Range: [100,2 20]. For example, set <report size>
to 100, <had sent len>
report sequence in the response of AT+CIPSENDL will be (100, 200, 300, 400, â¦). The final <had sent len>
report is always equal to the data length that had been sent out.
<transmit size>: transmit block size of AT+CIPSENDL. It specifies the size of the data block sent to the underlying protocol stack. Default: 2920. Range: [100,2920]. If the data received by ESP32 reaches or exceeds <transmit size>
bytes, the data will be immediately sent in chunks of <transmit size>
bytes. Otherwise, it will wait for 20 milliseconds before being sent (You can configure this interval using AT+TRANSINTVL command).
For devices with small throughput but high real-time requirements, it is recommended to set a smaller <transmit size>
. It is also recommended to set TCP_NODELAY
by AT+CIPTCPOPT command.
For devices with large throughput, it is recommended to set a larger <transmit size>
. It is also recommended to read How to Improve ESP-AT Throughput Performance first.
Function:
Set the data length to be send in Normal Transmission Mode, or use \0
(0x5c, 0x30 ASCII) to trigger data transmission.
Command:
// Single connection: (AT+CIPMUX=0) AT+CIPSENDEX=<length> // Multiple connections: (AT+CIPMUX=1) AT+CIPSENDEX=<link ID>,<length> // Remote host and port can be set for UDP transmission: AT+CIPSENDEX=[<link ID>,]<length>[,<"remote host">,<remote port>]
Response:
This response indicates that AT is ready for receiving data. You should enter the data of designated length. When the data length reaches the <length>
value, or when the string \0
appears in the data, the transmission starts.
If the connection cannot be established or gets disconnected during transmission, the system returns:
If the data has been successfully sent to the protocol stack (It does not mean that the data has been sent to the opposite end), the system returns:
Parametersï<link ID>: ID of the connection (0~4), for multiple connections.
<length>: data length. Maximum: 8192 bytes.
<âremote hostâ>: IPv4 address, IPv6 address, or domain name of remote host. It can be set in UDP transmission.
<remote port>: remote port can be set in UDP transmission.
When the requirement of data length is met, or when the string \0
(0x5c, 0x30 in ASCII) appears, the transmission of data starts. Go back to the normal command mode and wait for the next AT command.
If the data contains the \<any>
, it means that drop backslash symbol and only use <any>
character.
When sending \0
, please use a backslash to escape it as \\0
.
You can use AT+CIPTCPOPT command to configure socket options for each TCP connection. For example, setting <so_sndtimeo> to 5000 will enable TCP send operation to return results within 5 seconds, regardless of success or failure. This can save the time that the MCU waits for AT command response.
Function:
Close TCP/UDP/SSL connection in the multiple connections mode.
Command:
Response:
Execute CommandïFunction:
Close TCP/UDP/SSL connection in the single connection mode.
Response:
Parameterï<link ID>: ID of the connection that you want to close. If you set it to 5, all connections will be closed.
Command:
Response:
+CIFSR:APIP,<"APIP"> +CIFSR:APIP6LL,<"APIP6LL"> +CIFSR:APIP6GL,<"APIP6GL"> +CIFSR:APMAC,<"APMAC"> +CIFSR:STAIP,<"STAIP"> +CIFSR:STAIP6LL,<"STAIP6LL"> +CIFSR:STAIP6GL,<"STAIP6GL"> +CIFSR:STAMAC,<"STAMAC"> +CIFSR:ETHIP,<"ETHIP"> +CIFSR:ETHIP6LL,<"ETHIP6LL"> +CIFSR:ETHIP6GL,<"ETHIP6GL"> +CIFSR:ETHMAC,<"ETHMAC"> OKParametersï
<âAPIPâ>: IPv4 address of Wi-Fi softAP interface
<âAPIP6LLâ>: Linklocal IPv6 address of Wi-Fi softAP interface
<âAPIP6GLâ>: Global IPv6 address of Wi-Fi softAP interface
<âAPMACâ>: MAC address of Wi-Fi softAP interface
<âSTAIPâ>: IPv4 address of Wi-Fi station interface
<âSTAIP6LLâ>: Linklocal IPv6 address of Wi-Fi station interface
<âSTAIP6GLâ>: Global IPv6 address of Wi-Fi station interface
<âSTAMACâ>: MAC address of Wi-Fi station interface
<âETHIPâ>: IPv4 address of ethernet interface
<âETHIP6LLâ>: Linklocal IPv6 address of ethernet interface
<âETHIP6GLâ>: Global IPv6 address of ethernet interface
<âETHMACâ>: MAC address of ethernet interface
Only when the ESP32 has the valid interface information can you query its IP address and MAC address.
Function:
Query the connection type.
Command:
Response:
Set CommandïFunction:
Set the connection type.
Command:
Response:
Parameterï<mode>: connection mode. Default: 0.
0: single connection.
1: multiple connections.
This mode can only be changed after all connections are disconnected.
If you want to set the multiple connections mode, ESP32 should be in the Normal Transmission Mode (AT+CIPMODE=0).
If you want to set the single connection mode when the TCP/SSL server is running, you should delete the server first. (AT+CIPSERVER=0).
When transmitting large amounts of data in parallel over multiple connections, memory peaks may be insufficient. Please test according to your productâs actual situation and implement MCU handling for insufficient memory.
Function:
Query the TCP/SSL server status.
Command:
Response:
+CIPSERVER:<mode>[,<port>,<"type">,<CA enable>,<netif>] OKSet Commandï
Command:
AT+CIPSERVER=<mode>[,<param2>][,<"type">][,<CA enable>][,<netif>]
Response:
Parametersï<mode>:
0: delete a server.
1: create a server.
<param2>: It means differently depending on the parameter <mode>
:
If
<mode>
is 1,<param2>
represents the port number. Default: 333.If
<mode>
is 0,<param2>
represents whether the server closes all connections. Default: 0.
0: shutdown the server and keep existing connections.
1: shutdown the server and close all connections.
<âtypeâ>: server type: âTCPâ, âTCPv6â, âSSLâ, or âSSLv6â. Default: âTCPâ.
<CA enable>:
0: disable CA.
1: enable CA.
<netif>: Specify the network interface for the server to listen on. Default: 0.
0: all network interfaces
1: Wi-Fi station interface
2: Wi-Fi SoftAP interface
3: Ethernet interface
A TCP/SSL server can only be created when multiple connections are activated (AT+CIPMUX=1).
A server monitor will be created automatically when the server is created. Only one server can be created at most.
When a client is connected to the server, it will take up one connection and be assigned an ID.
If you want to create a TCP/SSL server based on IPv6 network, set AT+CIPV6=1 first, and obtain an IPv6 address.
Parameters <"type">
and <CA enable>
must be omitted when delete a server.
// To create a TCP server AT+CIPMUX=1 AT+CIPSERVER=1,80 // To create an SSL server AT+CIPMUX=1 AT+CIPSERVER=1,443,"SSL",1 // To create an SSL server based on IPv6 network AT+CIPMUX=1 AT+CIPSERVER=1,443,"SSLv6",0 // To delete an server and close all clients AT+CIPSERVER=0,1AT+CIPSERVERMAXCONN: Query/Set the Maximum Connections Allowed by a Serverï Query Commandï
Function:
Obtain the maximum number of clients allowed to connect to the TCP/SSL server.
Command:
Response:
+CIPSERVERMAXCONN:<num> OKSet Commandï
Function:
Set the maximum number of clients allowed to connect to the TCP/SSL server.
Command:
AT+CIPSERVERMAXCONN=<num>
Response:
Parameterï<num>: the maximum number of clients allowed to connect to the TCP/SSL server. Range: [1,5]. For how to change the upper limit of this range, please refer to the description of the <link ID>
parameter of the AT+CIPSTART command.
You should call the command AT+CIPSERVERMAXCONN=<num>
before creating a server.
AT+CIPMUX=1 AT+CIPSERVERMAXCONN=2 AT+CIPSERVER=1,80AT+CIPMODE: Query/Set the Transmission Modeï Query Commandï
Function:
Query the transmission mode.
Command:
Response:
Set CommandïFunction:
Set the transmission mode.
Command:
Response:
Parameterï<mode>:
1: Wi-Fi Passthrough Receiving Mode, or called transparent receiving transmission, which can only be enabled in TCP single connection mode, UDP mode when the remote host and port do not change, or SSL single connection mode.
The configuration changes will NOT be saved in flash.
After the ESP32 enters the Wi-Fi Passthrough Receiving Mode, no Bluetooth function can be used.
Function:
Query the local TCP/SSL server timeout.
Command:
Response:
Set CommandïFunction:
Set the local TCP/SSL server timeout.
Command:
Response:
Parameterï<time>: local TCP/SSL server timeout. Unit: second. Range: [0,7200].
When a TCP/SSL client does not communicate with the ESP32 server within the <time>
value, the server will terminate this connection.
If you set <time>
to 0, the connection will never timeout. This configuration is not recommended.
When the client initiates a communication with the server or the server initiate a communication with the client within the set time, the timer will restart. After the timeout expires, the client is closed.
AT+CIPMUX=1 AT+CIPSERVER=1,1001 AT+CIPSTO=10AT+CIPSNTPCFG: Query/Set the Time Zone and the SNTP Serverï Query Commandï
Command:
Response:
+CIPSNTPCFG:<enable>,<timezone>[,<"SNTP server1">][,<"SNTP server2">][,<"SNTP server3">] OKSet Commandï
Command:
AT+CIPSNTPCFG=<enable>[,<timezone>][,<"SNTP server1">][,<"SNTP server2">][,<"SNTP server3">]
Response:
Parametersï<enable>: configure the SNTP server:
1: the SNTP server is configured.
0: the SNTP server is not configured.
<timezone>: support the following two formats:
The first format range is [-12,14]. It marks most of the time zones by offset from Coordinated Universal Time (UTC) in whole hours (UTCâ12:00 to UTC+14:00).
The second format is UTC offset
. The UTC offset
specifies the time value you must add to the UTC time to get a local time value. It has syntax like [+|-][hh]mm
. This is negative if the local time zone is on the west of the Prime Meridian and positive if it is on the east. The hour(hh) must be between -12 and 14, and the minute(mm) between 0 and 59. For example, if you want to set the timezone to New Zealand (Chatham Islands) which is in UTC+12:45
, you should set the parameter <timezone>
to 1245
. Please refer to UTC offset wiki for more information.
[<âSNTP server1â>]: the first SNTP server.
[<âSNTP server2â>]: the second SNTP server.
[<âSNTP server3â>]: the third SNTP server.
If the three SNTP servers are not configured, one of the following default servers will be used: âcn.ntp.org.cnâ, ântp.sjtu.edu.cnâ, and âus.pool.ntp.orgâ.
For the query command, <timezone>
parameter in the response may be different from the <timezone>
parameter in set command. Because the <timezone>
parameter supports the second UTC offset
format, for example, set AT+CIPSNTPCFG=1,015
, for query command, ESP-AT ignores the leading zero of the <timezone>
parameter, and the valid value is 15
. It does not belong to the first format, so it is parsed according to the second UTC offset
format, that is, UTC+00:15
, that is, timezone
is 0 in the response.
Since SNTP operates over the UDP protocol for sending requests and receiving replies, if there is packet loss in the network, the time synchronization of ESP32 may be delayed. Once the AT command output shows +TIME_UPDATED, it indicates that the time has been synchronized, and you can then send the AT+CIPSNTPTIME? command to query the current time.
// Enable SNTP server, set timezone to China (UTC+08:00) AT+CIPSNTPCFG=1,8,"cn.ntp.org.cn","ntp.sjtu.edu.cn" or AT+CIPSNTPCFG=1,800,"cn.ntp.org.cn","ntp.sjtu.edu.cn" // Enable SNTP server, set timezone to New York of the United States (UTCâ05:00) AT+CIPSNTPCFG=1,-5,"0.pool.ntp.org","time.google.com" or AT+CIPSNTPCFG=1,-500,"0.pool.ntp.org","time.google.com" // Enable SNTP server, set timezone to New Zealand (Chatham Islands, UTC+12:45) AT+CIPSNTPCFG=1,1245,"0.pool.ntp.org","time.google.com"AT+CIPSNTPTIME: Query the SNTP Timeï Query Commandï
Command:
Response:
+CIPSNTPTIME:<asctime style time> OKNoteï
The asctime style time is defined at asctime man page.
When ESP32 enters Light-sleep or Deep-sleep mode and then wakes up, the system time may become inaccurate. It is recommended to resend the AT+CIPSNTPCFG command to obtain the new time from the NTP server.
The time obtained from SNTP is stored in the RTC area, so it will not be lost after a software reset (chip does not lose power).
AT+CWMODE=1 AT+CWJAP="1234567890","1234567890" AT+CIPSNTPCFG=1,8,"cn.ntp.org.cn","ntp.sjtu.edu.cn" AT+CIPSNTPTIME? +CIPSNTPTIME:Tue Oct 19 17:47:56 2021 OK or AT+CWMODE=1 AT+CWJAP="1234567890","1234567890" AT+CIPSNTPCFG=1,530 AT+CIPSNTPTIME? +CIPSNTPTIME:Tue Oct 19 15:17:56 2021 OKAT+CIPSNTPINTV: Query/Set the SNTP time synchronization intervalï Query Commandï
Command:
Response:
+CIPSNTPINTV:<interval second> OKSet Commandï
Command:
AT+CIPSNTPINTV=<interval second>
Response:
Parametersï<interval second>: the SNTP time synchronization interval. Unit: second. Range: [15,4294967].
It configures interval for synchronization, which means that it sets interval how often ESP32 connects to NTP servers to get new time.
AT+CIPSNTPCFG=1,8,"cn.ntp.org.cn","ntp.sjtu.edu.cn" OK // synchronize SNTP time every hour AT+CIPSNTPINTV=3600 OKAT+CIPFWVER: Query the Existing AT Firmware Version on the Serverï Query Commandï
Function:
Query the existing ESP32 AT firmware version on the server.
Command:
Response:
Parametersï<âversionâ>: ESP32 AT firmware version.
When selecting the OTA version to be upgraded, it is strongly not recommended to upgrade from a high version to a low version.
ESP-AT upgrades firmware at runtime by downloading the new firmware from a specific server through Wi-Fi and then flash it into some partitions.
Query CommandïFunction:
Query ESP32 upgrade status.
Command:
Response:
Execute CommandïFunction:
Upgrade OTA the latest version of firmware via TCP from the server in blocking mode.
Command:
Response:
Please refer to the response in the set command.
Set CommandïFunction:
Upgrade the specified version of firmware from the server.
Command:
AT+CIUPDATE=<ota mode>[,<"version">][,<"firmware name">][,<nonblocking>]
Response:
If OTA succeeds in blocking mode, the system returns:
+CIPUPDATE:1 +CIPUPDATE:2 +CIPUPDATE:3 +CIPUPDATE:4 OK
If OTA succeeds in non-blocking mode, the system returns:
OK +CIPUPDATE:1 +CIPUPDATE:2 +CIPUPDATE:3 +CIPUPDATE:4
If OTA fails in blocking mode, the system returns:
If OTA fails in non-blocking mode, the system returns:
OK +CIPUPDATE:<state> +CIPUPDATE:-1Parametersï
<ota mode>:
0: OTA via HTTP.
1: OTA via HTTPS. If it does not work, please check whether
./build.py menuconfig
>Component config
>AT
>OTA based upon ssl
is enabled. For more information, please refer to Compile ESP-AT Project Locally.
<version>: AT version, such as, v1.2.0.0
, v1.1.3.0
, v1.1.2.0
.
<âfirmware nameâ>: firmware to upgrade, such as, ota
, mqtt_ca
, client_ca
or other custom partition in at_customize.csv
.
<nonblocking>:
0: OTA by blocking mode. In this mode, you can not send AT command until OTA completes successfully or fails.
1: OTA by non-blocking mode. You need to manually restart after upgrade done (+CIPUPDATE:4).
<state>:
1: Server found.
2: Connected to the server.
3: Got the upgrade version.
4: Upgrade done.
-1: OTA fails in non-blocking mode.
The speed of the upgrade depends on the network status.
If the upgrade fails due to unfavorable network conditions, AT will return ERROR
. Please wait for some time before retrying.
If you use Espressifâs AT BIN, AT+CIUPDATE
will download a new AT BIN from the Espressif Cloud.
If you use a user-compiled AT BIN, you need to implement your own AT+CIUPDATE FOTA function or use AT+USEROTA or AT+WEBSERVER command. ESP-AT project provides an example of FOTA.
After you upgrade the AT firmware, you are suggested to call the command AT+RESTORE to restore the factory default settings.
The timeout of OTA process is 3
minutes.
The response OK
in non-blocking mode does not necessarily come before the response +CIPUPDATE:<state>
. It may be output before +CIPUPDATE:<state>
or after it.
Downgrading to an older version is not recommended due to potential compatibility issues and the risk of operational failure. If you still prefer downgrading to an older version, please test and verify the functionality based on your product.
Please refer to How to Implement OTA Upgrade for more OTA commands.
AT+CWMODE=1 AT+CWJAP="1234567890","1234567890" AT+CIUPDATE AT+CIUPDATE=1 AT+CIUPDATE=1,"v1.2.0.0" AT+CIUPDATE=1,"v2.2.0.0","mqtt_ca" AT+CIUPDATE=1,"v2.2.0.0","ota",1 AT+CIUPDATE=1,,,1 AT+CIUPDATE=1,,"ota",1 AT+CIUPDATE=1,"v2.2.0.0",,1AT+CIPDINFO: Set â+IPDâ Message Modeï Query Commandï
Command:
Response:
or
Set CommandïCommand:
Response:
Parametersï<mode>:
0: does not show the remote host and port in â+IPDâ and â+CIPRECVDATAâ messages.
1: show the remote host and port in â+IPDâ and â+CIPRECVDATAâ messages.
Function:
Query the configuration of each connection where the ESP32 runs as an SSL client.
Command:
Response:
+CIPSSLCCONF:<link ID>,<auth_mode>,<pki_number>,<ca_number> OKSet Commandï
Command:
// Single connection: (AT+CIPMUX=0) AT+CIPSSLCCONF=<auth_mode>[,<pki_number>][,<ca_number>] // Multiple connections: (AT+CIPMUX=1) AT+CIPSSLCCONF=<link ID>,<auth_mode>[,<pki_number>][,<ca_number>]
Response:
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 authentication. In this case <pki_number>
and <ca_number>
are not required.
1: the client provides the client certificate for the server to verify.
2: the client loads CA certificate to verify the serverâs certificate.
3: mutual authentication.
<pki_number>: the index of certificate and private key. If there is only one certificate and private key, the value should be 0.
<ca_number>: the index of CA. If there is only one CA, the value should be 0.
If you want this configuration to take effect immediately, run this command before establishing an SSL connection.
The configuration changes will be saved in the NVS partition. If you set the command AT+SAVETRANSLINK to enter SSL Wi-Fi Passthrough Mode on power-up, the ESP32 will establish an SSL connection based on this configuration when powered up next time.
If you want to use your own certificate at runtime, use the AT+SYSMFG command to update the SSL certificate. If you want to pre-burn your own certificate, please refer to How to Update PKI Configuration.
If <auth_mode>
is configured to 2 or 3, in order to check the server certificate validity period, please make sure ESP32 has obtained the current time before sending the AT+CIPSTART command. (You can send AT+CIPSNTPCFG command to configure SNTP and obtain the current time, and send AT+CIPSNPTIME? command to query the current time.)
Function:
Query the cipher suites supported by ESP32 as an SSL client.
Command:
Response:
+CIPSSLCCIPHER:<idx>,<cipher_suite> OKSet Commandï
Command:
// Single connection: (AT+CIPMUX=0) AT+CIPSSLCCIPHER=<counts>[,<cipher_suite>][...][,<cipher_suite>] // Multiple connections: (AT+CIPMUX=1) AT+CIPSSLCCIPHER=<link ID>,<counts>[,<cipher_suite>][...][,<cipher_suite>]
Response:
Parametersï<idx>: the index number of the cipher suite, starting from 0.
<link ID>: network connection ID (0 ~ max). For multiple connections, if the value is max, it means all connections. The default value is 5.
<counts>: number of cipher suites. The maximum value is limited by the maximum command length of 256 bytes.
0: Clear the configured cipher suites.
Others: Set the number of cipher suites.
<cipher_suite>: the cipher suite in ClientHello. The corresponding values are defined in ssl_ciphersuites.h.
If you want this configuration to take effect immediately, run this command before establishing the SSL connection.
// Single connection: (AT+CIPMUX=0), cipher suites are TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256 and TLS_ECDHE_ECDSA_WITH_AES_256_CCM AT+CIPSSLCCIPHER=2,0xC023,0xC0AD // Multiple connections: (AT+CIPMUX=1), cipher suites are TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256 and TLS_ECDHE_ECDSA_WITH_AES_256_CCM AT+CIPSSLCCIPHER=0,2,0xC023,0xC0ADAT+CIPSSLCCN: Query/Set the Common Name of the SSL Clientï Query Commandï
Function:
Query the common name of the SSL client of each connection.
Command:
Response:
+CIPSSLCCN:<link ID>,<"common name"> OKSet Commandï
Command:
// Single connection: (AT+CIPMUX=0) AT+CIPSSLCCN=<"common name"> // Multiple connections: (AT+CIPMUX=1) AT+CIPSSLCCN=<link ID>,<"common name">
Response:
Parametersï<link ID>: ID of the connection (0 ~ max). For the single connection, the link ID is 0. For multiple connections, if the value is max, it means all connections. Max is 5 by default.
<âcommon nameâ>: this parameter is used to verify the Common Name in the certificate sent by the server. The maximum length of common name
is 64 bytes.
If you want this configuration to take effect immediately, run this command before establishing the SSL connection.
Function:
Query the SNI configuration of each connection.
Command:
Response:
+CIPSSLCSNI:<link ID>,<"sni"> OKSet Commandï
Command:
Single connection: (AT+CIPMUX=0) AT+CIPSSLCSNI=<"sni"> Multiple connections: (AT+CIPMUX=1) AT+CIPSSLCSNI=<link ID>,<"sni">
Response:
Parametersï<link ID>: ID of the connection (0 ~ max). For the single connection, the link ID is 0. For multiple connections, if the value is max, it means all connections. Max is 5 by default.
<âsniâ>: the Server Name Indication in ClientHello. The maximum length of sni
is 64 bytes.
If you want this configuration to take effect immediately, run this command before establishing the SSL connection.
Function:
Query the ALPN configuration of each connection where the ESP32 runs as an SSL client.
Command:
Response:
+CIPSSLCALPN:<link ID>[,<"alpn">][,<"alpn">][,<"alpn">] OKSet Commandï
Command:
// Single connection: (AT+CIPMUX=0) AT+CIPSSLCALPN=<counts>[,<"alpn">][,<"alpn">][,<"alpn">] // Multiple connections: (AT+CIPMUX=1) AT+CIPSSLCALPN=<link ID>,<counts>[,<"alpn">][,<"alpn">][,<"alpn">]
Response:
Parametersï<link ID>: ID of the connection (0 ~ max). For the single connection, the link ID is 0. For multiple connections, if the value is max, it means all connections. Max is 5 by default.
<counts>: the number of ALPNs. Range: [0,5].
0: clean the ALPN configuration.
[1,5]: set the ALPN configuration.
<âalpnâ>: a string paramemter showing the ALPN in ClientHello. The maximum length of alpn is limited by the command length.
If you want this configuration to take effect immediately, run this command before establishing the SSL connection.
Function:
Query the automatic connect interval for the Wi-Fi Passthrough Mode.
Command:
Response:
+CIPRECONNINTV:<interval> OKSet Commandï
Function:
Set the automatic reconnecting interval when TCP/UDP/SSL transmission breaks in the Wi-Fi Passthrough Mode.
Command:
AT+CIPRECONNINTV=<interval>
Response:
Parameterï<interval>: the duration between automatic reconnections. Unit: 100 milliseconds. Default: 1. Range: [1,36000].
The configuration changes will be saved in the NVS partition if AT+SYSSTORE=1.
Function:
Query the socket receiving mode.
Command:
Response:
+CIPRECVTYPE:<link ID>,<mode> OKSet Commandï
Command:
// Single connection: (AT+CIPMUX=0) AT+CIPRECVTYPE=<mode> // Multiple connections: (AT+CIPMUX=1) AT+CIPRECVTYPE=<link ID>,<mode>
Response:
Parameterï<link ID>: ID of the connection (0 ~ max). For a single connection, <link ID> is 0. For multiple connections, if the value is max, it means all connections. Max is 5 by default.
<mode>: the receive mode of socket data. Default: 0.
0: active mode. ESP-AT will send all the received socket data instantly to the host MCU with the header â+IPDâ. (The socket receive window is 5760 bytes by default. The maximum valid bytes sent to MCU is 2920 bytes each time.)
1: passive mode. ESP-AT will keep the received socket data in an internal buffer (socket receive window, 5760 bytes by default), and wait for the host MCU to read. If the buffer is full, the socket transmission will be blocked for TCP/SSL connections, or data will be lost for UDP connections.
The configuration can not be used in the Wi-Fi Passthrough Mode. If it is a UDP transmission in passive mode, data will be lost when the buffer is full.
When ESP-AT receives socket data in passive mode, it will prompt the following messages in different scenarios:
For multiple connections 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 the buffer.
You should read data by running AT+CIPRECVDATA once there is a +IPD
reported. Otherwise, the next +IPD
will not be reported to the host MCU until the previous +IPD
has been read.
In case of disconnection, the buffered socket data will still be there and can be read by the MCU until you send AT+CIPCLOSE (AT as client) or AT+CIPSERVER=0,1 (AT as server). In other words, if +IPD
has been reported, the message CLOSED
of this connection will never come until you send AT+CIPCLOSE or AT+CIPSERVER=0,1 or read all data by command AT+CIPRECVDATA.
When a large amount of network data is expected to be received and the MCU cannot process it timely, you can refer to example and use the passive receive data mode.
// Set passive mode in single connection mode AT+CIPRECVTYPE=1 // Set all connections to passive mode in multiple connections mode AT+CIPRECVTYPE=5,1AT+CIPRECVDATA: Obtain Socket Data in Passive Receiving Modeï Set Commandï
Command:
// Single connection: (AT+CIPMUX=0) AT+CIPRECVDATA=<len> // Multiple connections: (AT+CIPMUX=1) AT+CIPRECVDATA=<link_id>,<len>
Response:
+CIPRECVDATA:<actual_len>,<data> OK
or
+CIPRECVDATA:<actual_len>,<"remote IP">,<remote port>,<data> OKParametersï
<link_id>: connection ID in multiple connections mode.
<len>: the max value is 0x7fffffff. If the actual length of the received data is less than len
, the actual length will be returned.
<actual_len>: length of the data you actually obtain.
<data>: the data you want to obtain.
<âremote IPâ>: string parameter showing the remote IPv4 address or IPv6 address, enabled by the command AT+CIPDINFO=1.
<remote port>: the remote port number, enabled by the command AT+CIPDINFO=1.
The command needs to be executed in passive receive mode. Otherwise, ERROR is returned. You can verify whether AT is in passive receive mode by using the AT+CIPRECVTYPE command.
When this command is executed without any data available to read, it will directly return ERROR. You can verify if there is readable data at that time by using the AT+CIPRECVLEN? command.
When executing the command AT+CIPRECVDATA=<len>
, at least <len> + 128
bytes of memory are required. You can use the command AT+SYSRAM? to check the current available memory. When insufficient memory leads to a memory allocation failure, this command will also return ERROR. You can review the AT log output for alloc fail
or similar print messages to confirm whether a memory allocation failure has occurred.
AT+CIPRECVTYPE=1 // For example, if host MCU gets a message of receiving 100-byte data in connection with No.0, // the message will be "+IPD,0,100". // Then you can read those 100-byte data by using the command below. AT+CIPRECVDATA=0,100AT+CIPRECVLEN: Obtain Socket Data Length in Passive Receiving Modeï Query Commandï
Function:
Query the length of the entire data buffered for the connection.
Command:
Response:
+CIPRECVLEN:<data length of link>[...][,<data length of link>] OKParametersï
<data length of link>: length of the entire data buffered for the connection.
For SSL connections, the data length returned by ESP-AT may be less than the actual data length.
AT+CIPRECVLEN? +CIPRECVLEN:100,,,,, OKAT+PING: Ping the Remote Hostï Set Commandï
Function:
Ping the remote host.
Command:
Response:
or
+PING:TIMEOUT // esp-at returns this response only when the domain name resolution failure or ping timeout ERRORParametersï
<âhostâ>: string parameter showing the host IPv4 address or IPv6 address or domain name.
<time>: the response time of ping. Unit: millisecond.
To ping a remote host based on an IPv6 network, do as follows:
Make sure that the AP supports IPv6
Set AT+CIPV6=1
Obtain an IPv6 address through the AT+CWJAP command
(Optional) Check whether ESP32 has obtained an IPv6 address using the AT+CIPSTA? command
If the remote host is a domain name string, ping will first resolve the domain name (IPv4 address preferred) from DNS (domain name server), and then ping the remote IP address.
AT+PING="192.168.1.1" AT+PING="www.baidu.com" // China Future Internet Engineering Center AT+PING="240c::6666"AT+CIPDNS: Query/Set DNS Server Informationï Query Commandï
Function:
Query the current DNS server information.
Command:
Response:
+CIPDNS:<enable>[,<"DNS IP1">][,<"DNS IP2">][,<"DNS IP3">] OKSet Commandï
Function:
Set DNS server information.
Command:
AT+CIPDNS=<enable>[,<"DNS IP1">][,<"DNS IP2">][,<"DNS IP3">]
Response:
or
Parametersï<enable>: configure DNS server settings
0: Enable automatic DNS server settings from DHCP. The DNS will be restored to 208.67.222.222
, 114.114.114.114
and 8.8.8.8
. Only when the ESP32 station completes the DHCP process, the DNS server of the ESP32 station could be updated.
1: Enable manual DNS server settings. If you do not set a value for <DNS IPx>
, it will use 208.67.222.222
, 114.114.114.114
and 8.8.8.8
by default.
<âDNS IP1â>: the first DNS server IP address. For the set command, this parameter only works when you set <enable> to 1, i.e. enable manual DNS settings. If you set <enable> to 1 and a value for this parameter, the ESP-AT will return this parameter as the current DNS setting when you run the query command.
<âDNS IP2â>: the second DNS server IP address. For the set command, this parameter only works when you set <enable> to 1, i.e. enable manual DNS settings. If you set <enable> to 1 and a value for this parameter, the ESP-AT will return this parameter as the current DNS setting when you run the query command.
<âDNS IP3â>: the third DNS server IP address. For the set command, this parameter only works when you set <enable> to 1, i.e. enable manual DNS settings. If you set <enable> to 1 and a value for this parameter, the ESP-AT will return this parameter as the current DNS setting when you run the query command.
The configuration changes will be saved in the NVS partition if AT+SYSSTORE=1.
The three parameters cannot be set to the same server.
When <enable>
is set to 0, the DNS server may change according to the configuration of the router which the ESP32 is connected to.
AT+CIPDNS=0 AT+CIPDNS=1,"208.67.222.222","114.114.114.114","8.8.8.8" // first DNS Server based on IPv6: China Future Internet Engineering Center // second DNS Server based on IPv6: google-public-dns-a.google.com // third DNS Server based on IPv6: main DNS Server based on IPv6 in JiangSu Province, China AT+CIPDNS=1,"240c::6666","2001:4860:4860::8888","240e:5a::6666"AT+MDNS: Configure the mDNS Functionï Set Commandï
Command:
AT+MDNS=<enable>[,<"hostname">,<"service_type">,<port>][,<"instance">][,<"proto">][,<txt_number>][,<"key">,<"value">][...]
Response:
Parametersï<enable>:
1: Enable the mDNS function. The following parameters need to be set.
0: Disable the mDNS function. Please do not set the following parameters.
<âhostnameâ>: mDNS host name.
<âservice_typeâ>: mDNS service type.
<port>: mDNS service port.
<âinstanceâ>: mDNS instance name. Default: <"hostname">
.
<âprotoâ>: mDNS service protocol. Recommended values: _tcp
or _udp
. Default: _tcp
.
<txt_number>: the number of key-value pairs in the TXT record. Range: [1,10].
<âkeyâ>: key of the TXT record.
<âvalueâ>: value of the TXT record.
[â¦]: repeat the key-value pairs of TXT record according to the <txt_number>
.
// Enable mDNS function. Set the hostname to "espressif", service type to "_iot", and port to 8080. AT+MDNS=1,"espressif","_iot",8080 // Disable mDNS function AT+MDNS=0
Detailed examples can be found in: mDNS Example.
AT+CIPTCPOPT: Query/Set the Socket Optionsï Query CommandïFunction:
Query current socket options.
Command:
Response:
+CIPTCPOPT:<link_id>,<so_linger>,<tcp_nodelay>,<so_sndtimeo>,<keep_alive> OKSet Commandï
Command:
// Single TCP connection (AT+CIPMUX=0): AT+CIPTCPOPT=[<so_linger>],[<tcp_nodelay>],[<so_sndtimeo>][,<keep_alive>] // Multiple TCP Connections (AT+CIPMUX=1): AT+CIPTCPOPT=<link ID>,[<so_linger>],[<tcp_nodelay>],[<so_sndtimeo>][,<keep_alive>]
Response:
or
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.
<so_linger>: configure the SO_LINGER
options for the socket (refer to SO_LINGER description). Unit: second. Default: -1.
= -1: off
= 0: on, linger time = 0
> 0: on, linger time = <so_linger>
<tcp_nodelay>: configure the TCP_NODELAY
option for the socket (refer to TCP_NODELAY description). Default: 0.
0: disable TCP_NODELAY
1: enable TCP_NODELAY
<so_sndtimeo>: configure the SO_SNDTIMEO
option for socket (refer to SO_SNDTIMEO description). Unit: millisecond. Default: 0.
<keep_alive>: configure the SO_KEEPALIVE option for socket. Unit: second.
Range: [0,7200].
0: disable keep-alive function (default).
1 ~ 7200: enable keep-alive function. TCP_KEEPIDLE value is <keep_alive>, TCP_KEEPINTVL value is 1, and TCP_KEEPCNT value is 3.
This parameter of this command is the same as the <keep_alive>
parameter of AT+CIPSTART command. It always takes the value set later by either of the two commands. If it is omitted or not set, the last configured value is used by default.
The configuration changes will be saved in the NVS partition if AT+SYSSTORE=1
.
Before configuring these socket options, please make sure you fully understand the function of them and the possible impact after configuration.
It is not recommended to set a large value for the SO_LINGER option. For example, if SO_LINGER is set to 60, the AT+CIPCLOSE command may block for up to 60 seconds if ESP32 does not receive a TCP FIN packet from the remote TCP peer due to network issues. During this period, ESP32 will be unable to respond to any other AT commands. Therefore, it is recommended to keep the SO_LINGER option at its default value.
The TCP_NODELAY option is used for situations with low throughput but high real-time requirements. When enabled, LwIP will speed up TCP transmission. However, in poor network conditions, this may lead to increased retransmissions and reduced throughput. Therefore, it is recommended to keep the TCP_NODELAY option at its default value.
The SO_SNDTIMEO option is used for situations where the keepalive parameter is not configured in AT+CIPSTART command. After this option is configured, AT+CIPSEND, AT+CIPSENDL, and AT+CIPSENDEX commands will exit within this timeout, regardless of whether data are sent successfully or not. Here, SO_SNDTIMEO is recommended to be set to 5 ~ 10 seconds.
The SO_KEEPALIVE option is used for actively and regularly detecting whether the connection is disconnected. It is generally recommended to configure this option when AT is used as a TCP server. After this option is configured, additional network bandwidth will be cost. Recommended value of SO_KEEPALIVE should be not less than 60 seconds.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4