Esp32 at Instruction Set and Examples en
Esp32 at Instruction Set and Examples en
Esp32 at Instruction Set and Examples en
and Examples
Version 1.1
Copyright © 2017
About This Guide
This document introduces the ESP32 AT commands, explains how to use them and provides
examples of several common AT commands. The document is structured as follows:
Release Notes
7. AT Commands Examples....................................................................................................................35
7.1. ESP32 as a TCP Client in Single Connection ........................................................................................... 35
7.2. UDP Transmission.....................................................................................................................................36
7.2.1. UDP (with Fixed Remote IP and Port) ......................................................................................... 37
7.2.2. UDP (with Changeable Remote IP and Port)...............................................................................38
7.3. Transparent Transmission ......................................................................................................................... 39
7.3.1. ESP32 as a TCP Client in UART-Wi-Fi Passthrough (Single Connection Mode) ........................ 39
7.3.2. UDP Transmission (UART-Wi-Fi PassthroughTransmission) ....................................................... 42
7.4. ESP32 as a TCP Server in Multiple Connections ..................................................................................... 45
9. Q & A ....................................................................................................................................................52
1. Overview
!
1. Overview
This document introduces the ESP32 AT commands, and explains how to use them.
The AT command set is divided into different categories: Basic AT commands, Wi-Fi AT commands,
TCP/IP AT commands, etc.
📖 Note:
Espressif ! /!53
1 2017.02
1. Overview
!
⚠ Notice:
Change the UART interface for AT commands to GPIO16 and GPIO17. Use GPIO16 as ESP32’s Rx and GPIO17 as
ESP32’s Tx.
Espressif ! /!53
2 2017.02
2. Command Description
!
2. Command Description
Each command set contains four types of AT commands.
⚠ Notice:
• Square brackets [ ] designate the default value; it is either not required or may not appear.
• String values need to be included in double quotation marks, for example: AT+CWSAP="ESP756290","21030826",
1,4.
• The default baud rate is 115200. The configuration of serial options is shown in Figure 2-1.
• AT commands have to be capitalized, and must end with \r\n, as Figure 2-2 shows.
!
Figure 2-1. Configuration of Serial Options
!
Figure 2-2. New Line Mode
Espressif ! /!53
3 2017.02
3. Basic AT Commands
!
3. Basic AT Commands
3.1. Overview
Commands Description
AT Tests AT startup.
3.2. Commands
3.2.1. AT—Tests AT Startup
Execute Command AT
Response OK
Parameters -
Response OK
Parameters -
Espressif ! /!53
4 2017.02
3. Basic AT Commands
!
OK
<time>
Response
OK
Response OK
Response OK
The execution of this command will reset all parameters saved in flash, and restore the
Parameters factory default settings of the module. The chip will be restarted when this command is
executed.
Espressif ! /!53
5 2017.02
3. Basic AT Commands
!
Response OK
‣ 5: 5-bit data
‣ 6: 6-bit data
‣ 7: 7-bit data
‣ 8: 8-bit data
• <stopbits>: stop bits
‣ 0: None
‣ 1: Odd
‣ 2: Even
• <flow control>: flow control
1. The configuration changes will be saved in the NVS area, and will still be valid when the
chip is powered on again.
2. The use of flow control requires the support of hardware:
Notes
‣ IO15 is UART0 CTS
‣ IO14 is UART0 RTS
3. The range of baud rates supported: 80 ~ 5000000.
Example AT+UART=115200,8,1,0,3
Espressif ! /!53
6 2017.02
3. Basic AT Commands
!
Response OK
‣ 5: 5-bit data
‣ 6: 6-bit data
‣ 7: 7-bit data
‣ 8: 8-bit data
• <stopbits>: stop bits
‣ 0: None
‣ 1: Odd
‣ 2: Even
• <flow control>: flow control
Example AT+UART=115200,8,1,0,3
Espressif ! /!53
7 2017.02
3. Basic AT Commands
!
Response OK
‣ 5: 5-bit data
‣ 6: 6-bit data
‣ 7: 7-bit data
‣ 8: 8-bit data
• <stopbits>: stop bits
‣ 0: None
‣ 1: Odd
‣ 2: Even
• <flow control>: flow control
1. The configuration changes will be saved in the NVS area, and will still be valid when the
chip is powered on again.
2. The use of flow control requires the support of hardware:
Notes
‣ IO15 is UART0 CTS
‣ IO14 is UART0 RTS
3. The range of baud rates supported: 80 ~ 5000000.
Example AT+UART=115200,8,1,0,3
Espressif ! /!53
8 2017.02
3. Basic AT Commands
!
OK
Response or
ERROR
<sleep mode>:
Parameters
‣ 0: disable the sleep mode.
‣ 1: Modem-sleep mode.
Example AT+SLEEP=0
AT+SYSRAM?
Example +SYSRAM:148408
OK
Espressif ! /!53
9 2017.02
4. Wi-Fi AT Commands
!
4. Wi-Fi AT Commands
4.1. Overview
Commands Description
Espressif ! /! 53
10 2017.02
4. Wi-Fi AT Commands
!
4.2. Commands
4.2.1. AT+CWMODE—Sets the Wi-Fi Mode (Station/SoftAP/Station+SoftAP)
+CWMODE:<mode> +CWMODE:<mode>
Response OK
OK OK
<mode>:
Example AT+CWMODE=3
Espressif ! /! 53
11 2017.02
4. Wi-Fi AT Commands
!
4.2.2. AT+CWJAP—Connects to an AP
OK
+CWJAP:<ssid>,<bssid>,<channel>,<rssi> or
Response
OK +CWJAP:<error code>
ERROR
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:
Examples
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"
Espressif ! /! 53
12 2017.02
4. Wi-Fi AT Commands
!
OK
Response or
ERROR
• <sort_enable>: determines whether the result of command AT+CWLAP will be listed according to
RSSI:
‣ 0: the result is ordered according to RSSI.
‣ 1: the result is not ordered according to RSSI.
• <mask>: determines the parameters shown in the result of AT+CWLAP; 0 means not showing the
Parameters parameter corresponding to the bit, and 1 means showing it.
‣ bit 0: determines whether <ecn> will be shown in the result of AT+CWLAP.
‣ bit 1: determines whether <ssid> will be shown in the result of AT+CWLAP.
‣ bit 2: determines whether <rssi> will be shown in the result of AT+CWLAP.
‣ bit 3: determines whether <mac> will be shown in the result of AT+CWLAP.
‣ bit 4: determines whether <ch> will be shown in the result of AT+CWLAP.
AT+CWLAPOPT=1,31
The first parameter is 1, meaning that the result of the command AT+CWLAP will be ordered
Example 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.
Espressif ! /! 53
13 2017.02
4. Wi-Fi AT Commands
!
Set Command:
Execute Command:
Commands AT+CWLAP=<ssid>[,<mac>,<ch>]
AT+CWLAP
Function: to query the APs with specific SSID and
Function: to list all available APs.
MAC on a specific channel.
+CWLAP:<ecn>,<ssid>,<rssi>,<mac>,<ch>
OK +CWLAP:<ecn>,<ssid>,<rssi>,<mac>,<ch>
Response
or OK
ERROR
‣ 0: OPEN
‣ 1: WEP
‣ 2: WPA_PSK
‣ 3: WPA2_PSK
Parameters ‣ 4: WPA_WPA2_PSK
‣ 5: WPA2_Enterprise (AT can NOT connect to WPA2_Enterprise AP for now.)
• <ssid>: string parameter, SSID of the AP.
AT+CWLAP="Wi-Fi","ca:d7:19:d8:a6:44",6
Examples or search for APs with a designated SSID:
AT+CWLAP="Wi-Fi"
Response OK
Parameters -
Espressif ! /! 53
14 2017.02
4. Wi-Fi AT Commands
!
OK
+CWSAP:<ssid>,<pwd>,<chl>,<ecn>,<max conn>,<ssid
Response or
hidden>
ERROR
Example AT+CWSAP="ESP32","1234567890",5,3
Espressif ! /! 53
15 2017.02
4. Wi-Fi AT Commands
!
Execute
AT+CWLIF
Command
<ip addr>,<mac>
Response
OK
Note This command cannot get a static IP. It only works when both DHCPs of the ESP32 SoftAP, and of
the Station to which ESP32 is connected, are enabled.
Set Command:
Query Command:
Commands AT+CWDHCP=<operate>,<mode>
AT+CWDHCP?
Function: to enable/disable DHCP.
• Bit0: • <operate>:
AT+CWDHCP=1,1
Enable Station DHCP. If the last DHCP mode is 2, then the current DHCP mode will be 3.
Examples
AT+CWDHCP=0,2
Disable SoftAP DHCP. If the last DHCP mode is 3, then the current DHCP mode will be 1.
Espressif ! /! 53
16 2017.02
4. Wi-Fi AT Commands
!
4.2.9. AT+CWDHCPS—Sets the IP Address Allocated by ESP32 SoftAP DHCP (The configuration is
saved in Flash.)
Set Command:
Query Command: AT+CWDHCPS=<enable>,<lease time>,<start IP>,<end IP>
Commands
AT+CWDHCPS? Function: sets the IP address range of the ESP32 SoftAP
DHCP server.
+CWDHCPS=<lease time>,<start
Response OK
IP>,<end IP>
• <enable>:
• <start IP>: start IP of the IP range that can be obtained from ESP32 SoftAP DHCP server.
• <end IP>: end IP of the IP range that can be obtained from ESP32 SoftAP DHCP server.
AT+CWDHCPS=1,3,"192.168.4.10","192.168.4.15"
Examples or
AT+CWDHCPS=0 //Disable the settings and use the default IP range.
Response OK
<enable>:
Example AT+CWAUTOCONN=1
Espressif ! /! 53
17 2017.02
4. Wi-Fi AT Commands
!
Set Command:
Query Command:
Commands AT+CIPSTAMAC=<mac>
AT+CIPSTAMAC?
Function: to set the MAC address of the ESP32 Station.
+CIPSTAMAC:<mac>
Response OK
OK
• The MAC address of ESP32 SoftAP is different from that of the ESP32 Station. Please make sure that
you do not set the same MAC address for both of them.
Notes
• Bit 0 of the ESP32 MAC address CANNOT be 1. For example, a MAC address can be “1a:…” but not
“15:…”.
• FF:FF:FF:FF:FF:FF and 00:00:00:00:00:00 are invalid MAC and cannot be set.
Example AT+CIPSTAMAC="18:fe:35:98:d3:7b"
+CIPAPMAC:<mac>
Response OK
OK
• The MAC address of ESP32 SoftAP is different from that of the ESP32 Station. Please make sure you
do not set the same MAC address for both of them.
Notes
• Bit 0 of the ESP32 MAC address CANNOT be 1. For example, a MAC address can be “18:…” but not
“15:…”.
• FF:FF:FF:FF:FF:FF and 00:00:00:00:00:00 are invalid MAC and cannot be set.
Example AT+CIPAPMAC="1a:fe:36:97:d5:7b"
Espressif ! /! 53
18 2017.02
4. Wi-Fi AT Commands
!
+CIPSTA:<ip>
Response OK
OK
Example AT+CIPSTA="192.168.6.100","192.168.6.1","255.255.255.0"
+CIPAP:<ip>,<gateway>,<netmask>
Response OK
OK
• [<netmask>]: netmask.
Notes • The set command interacts with DHCP-related AT commands (AT+CWDHCP-related commands):
Example AT+CIPAP="192.168.5.1","192.168.5.1","255.255.255.0"
Espressif ! /! 53
19 2017.02
4. Wi-Fi AT Commands
!
Response OK
<type>:
Parameters ‣ 1: ESP-TOUCH
‣ 2: AirKiss
‣ 3: ESP-TOUCH+AirKiss
• The message Smart get Wi-Fi info means that SmartConfig has successfully acquired the AP
Notes
information. ESP32 will try to connect to the target AP.
• Message Smartconfig connected Wi-Fi is printed if the connection is successful. Use command AT
+CWSTOPSMART to stop SmartConfig before running other commands. Please make sure that you do
not execute other commands during SmartConfig.
AT+CWMODE=1
Example
AT+CWSTARTSMART
Response OK
Parameters -
Example AT+CWSTOPSMART
Espressif ! /! 53
20 2017.02
4. Wi-Fi AT
!
OK
Response or
ERROR
<enable>:
Parameters
‣ 1: enable WPS/Wi-Fi Protected Setup (implemented by PBC/Push Button Configuration).
‣ 0: disable WPS (implemented by PBC).
AT+CWMODE=1
Example
AT+WPS=1
Espressif ! /! 53
21 2017.02
5. TCP/IP-Related AT Commands
!
5. TCP/IP-Related AT Commands
5.1. Overview
Commands Description
AT+CIPSENDEX Sends data when length of data is <length>, or when \0 appears in the data.
Espressif ! /! 53
22 2017.02
5. TCP/IP-Related AT Commands
!
5.2. Commands
5.2.1. AT+CIPSTATUS—Gets the Connection Status
STATUS:<stat>
Response
+CIPSTATUS:<link ID>,<type>,<remote IP>,<remote port>,<local port>,<tetype>
• <tetype>:
Espressif ! /! 53
23 2017.02
5. TCP/IP-Related AT Commands
!
OK
Response or
ERROR
• <type>: string parameter indicating the connection type: "TCP", "UDP" or "SSL".
• [<TCP keep alive>]: detection time interval when TCP is kept alive; this function is disabled by
default.
‣ 0: disable TCP keep-alive.
‣ 1 ~ 7200: detection time interval; unit: second (s).
AT+CIPSTART="TCP","iot.espressif.cn",8000
Examples AT+CIPSTART="TCP","192.168.101.110",1000
OK
or
Response ERROR
If TCP is already connected, the response is:
ALREADY CONNECT
Espressif ! /! 53
24 2017.02
5. TCP/IP-Related AT Commands
!
• <type>: string parameter indicating the connection type: "TCP", "UDP" or "SSL".
Parameters • [<TCP keep alive>]: detection time interval when TCP is kept alive; this function is disabled by
default.
‣ 0: disable the TCP keep-alive function.
‣ 1 ~ 7200: detection time interval, unit: second (s).
⚠ Notice:
AT+CIPSTART="UDP","192.168.101.110",1000,1002,2
Example
For more information please see Chapter 7: AT Command Examples.
Set
AT+CIPSTART=[<link ID>,]<type>,<remote IP>,<remote port>[,<TCP keep alive>]
Command
OK
or
Response ERROR
• <type>: string parameter indicating the connection type: "TCP", "UDP" or "SSL".
• [<TCP keep alive>]: detection time interval when TCP is kept alive; this function is disabled by
default.
‣ 0: disable the TCP keep-alive function.
‣ 1 ~ 7200: detection time interval, unit: second (s).
Notes • SSL connection does not support UART-Wi-Fi passthrough mode (transparent transmission).
• SSL connection needs a large amount of memory; otherwise, it may cause system reboot.
Example AT+CIPSTART="SSL","iot.espressif.cn",8443
Espressif ! /! 53
25 2017.02
5. TCP/IP-Related AT Commands
!
Set Command:
Espressif ! /! 53
26 2017.02
5. TCP/IP-Related AT Commands
!
Set Command:
Wrap return > after the set command. Begin receiving serial data. When the requirement of data length,
determined by <length>, is met, or when \0 appears in the data, the transmission starts.
Response If connection cannot be established or gets disconnected during transmission, the system returns:
ERROR
Parameters • When the requirement of data length, determined by <length>, is met, or when \0 appears, the
transmission of data starts. Go back to the normal command mode and wait for the next AT
command.
• When sending \0, please send it as \\0.
Response OK
Espressif ! /! 53
27 2017.02
5. TCP/IP-Related AT Commands
!
Execute
AT+CIFSR
Command
+CIFSR:<SoftAP IP address>
Response +CIFSR:<Station IP address>
OK
<IP address>:
Parameters IP address of the ESP32 SoftAP;
Notes Only when the ESP32 Station is connected to an AP can the Station IP can be queried.
Set Command:
Query Command:
Commands AT+CIPMUX=<mode>
AT+CIPMUX?
Function: to set the connection type.
+CIPMUX:<mode>
Response OK
OK
<mode>:
Parameters
‣ 0: single connection
‣ 1: multiple connections
• The default mode is single connection mode.
• Multiple connections can only be set when transparent transmission is disabled (AT+CIPMODE=0).
Notes • This mode can only be changed after all connections are disconnected.
• If the TCP server is running, it must be deleted (AT+CIPSERVER=0) before the single connection mode is
activated.
Example AT+CIPMUX=1
Espressif ! /! 53
28 2017.02
5. TCP/IP-Related AT Commands
!
Response OK
• <mode>:
Parameters
‣ 0: delete server.
‣ 1: create server.
• <port>: port number; 333 by default.
• A TCP server can only be created when multiple connections are activated (AT+CIPMUX=1).
Notes • A server monitor will automatically be created when the TCP server is created.
• When a client is connected to the server, it will take up one connection and be assigned an ID.
Query Command:
Set Command:
AT+CIPMODE?
Commands AT+CIPMODE=<mode>
Function: to obtain information about transmission
Function: to set the transmission mode.
mode.
+CIPMODE:<mode>
Response OK
OK
<mode>:
Parameters ‣ 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 • During the UART-Wi-Fi passthrough transmission, if the TCP connection breaks, ESP32 will keep
trying to reconnect until +++ is input to exit the transmission. If it is a normal TCP transmission and the
TCP connection breaks, ESP32 will give a prompt and will not attempt to reconnect.
Example AT+CIPMODE=1
Espressif ! /! 53
29 2017.02
5. TCP/IP-Related AT Commands
!
OK
Response or
ERROR
• <mode>:
‣ 0: normal mode, ESP32 will NOT enter UART-Wi-Fi passthrough mode on power-up.
‣ 1: ESP32 will enter UART-Wi-Fi passthrough mode on power-up.
• <remote IP>: remote IP or domain name.
Parameters • <remote port>: remote port.
• [<type>] (optional): TCP or UDP, TCP by default.
• [<TCP keep alive>] (optional): 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).
• This command will save the UART-Wi-Fi passthrough mode and its link in the NVS area. ESP32 will
enter the UART-Wi-Fi passthrough mode on any subsequent power cycles.
Notes
• 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"
OK
Response or
ERROR
• <mode>:
‣ 0: normal mode; ESP32 will NOT enter UART-Wi-Fi passthrough mode on power-up.
‣ 1: ESP32 enters UART-Wi-Fi passthrough mode on power-up.
• <remote IP>: remote IP or domain name.
Parameters
• <remote port>: remote port.
• [<type>] (optional): UDP, TCP by default.
• [<UDP local port>] (optional): local port when UDP transparent transmission is enabled on
power-up.
Espressif ! /! 53
30 2017.02
5. TCP/IP-Related AT Commands
!
• This command will save the UART-Wi-Fi passthrough mode and its link in the NVS area. ESP32 will
enter the UART-Wi-Fi passthrough mode on any subsequent power cycles.
Notes
• 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
Function: to check the TCP server timeout. Function: to set the TCP server timeout.
+CIPSTO:<time>
Response OK
OK
AT+CIPMUX=1
Example AT+CIPSERVER=1,1001
AT+CIPSTO=10
+CIPSNTPCFG:<enable>,<timezone>
,<SNTP server1>[,<SNTP
Response server2>,<SNTP server3>] OK OK
OK
Espressif ! /! 53
31 2017.02
5. TCP/IP-Related AT Commands
!
Example AT+CIPSNTPCFG=8,"cn.ntp.org.cn","ntp.sjtu.edu.cn"
Query
AT+CIPSNTPTIME?
Command
+CIPSNTPTIME:SNTP time
Response
OK
Parameters -
AT+CIPSNTPCFG=8,"cn.ntp.org.cn","ntp.sjtu.edu.cn"
OK
Example AT+CIPSNTPTIME?
+CIPSNTPTIME:Mon Dec 12 02:33:32 2016
OK
Execute
AT+CIUPDATE
Command
+CIPUPDATE:<n>
Response
OK
• <n>:
‣ 1: find the server.
Parameters
‣ 2: connect to server.
‣ 3: get the software version.
‣ 4: start updating.
• If using Espressif’s AT BIN (/esp-idf/bin/at), AT+CIUPDATE will download a new AT BIN from the
Espressif Cloud.
Notice • If using a user-compiled AT BIN, users need to make their own AT+CIUPDATE upgrade. Espressif
provides a demo as a reference for local upgrade (/esp-idf/example/at).
• It is suggested that users call AT+RESTORE to restore the factory default settings after upgrading
the AT firmware.
Response OK
Espressif ! /! 53
32 2017.02
5. TCP/IP-Related AT Commands
!
<mode>:
Parameters
‣ 0: does not show the remote IP and port with "+IPD".
‣ 1: shows the remote IP and port with "+IPD".
Example AT+CIPDINFO=1
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.
Espressif ! /! 53
33 2017.02
6. AT Commands with Configuration Saved in the NVS Area
!
AT+UART AT+UART=115200,8,1,0,3
AT+UART_DEF AT+UART_DEF=115200,8,1,0,3
AT+CWDHCP AT+CWDHCP=1,1
AT+CIPSTAMAC AT+CIPSTAMAC="18:fe:35:98:d3:7b"
AT+CIPAPMAC AT+CIPAPMAC="1a:fe:36:97:d5:7b"
AT+CIPSTA AT+CIPSTA="192.168.6.100"
AT+CIPAP AT+CIPAP="192.168.5.1"
AT+CWDHCPS AT+CWDHCPS=1,3,"192.168.4.10","192.168.4.15"
AT+SAVETRANSLINK AT+SAVETRANSLINK=1,"192.168.6.10",1001
AT+CWMODE AT+CWMODE=3
AT+CWJAP AT+CWJAP="abc","0123456789"
AT+CWSAP AT+CWSAP="ESP32","12345678",5,3
AT+CWAUTOCONN AT+CWAUTOCONN=1
⚠ Notice:
Espressif ! /! 53
34 2017.02
7. AT Commands Examples
!
7. AT Commands Examples
Herein we introduce some examples of how to use Espressif’s AT Commands.
Response:
OK
Response:
OK
Response:
192.168.3.106 // device got an IP from router
4. Connect the PC to the same router which ESP32 is connected to. Use a network tool on the PC to
create a TCP server.
Espressif ! /! 53
35 2017.02
7. AT Commands Examples
!
6. Send data:
AT+CIPSEND=4 // set date, such as 4 bytes
>DGFY // enter the data, no CR
Response:
SEND OK
⚠ Notice:
If the number of bytes sent is bigger than the size defined (n), the response will be busy. After sending the first n number
of bytes, SEND OK will be returned.
7. Receive data:
+IPD,n:xxxxxxxxxx // received n bytes, data=xxxxxxxxxxx
Response:
OK
Response:
OK
Response:
+CIFSR:STAIP,"192.168.101.104" // IP address of ESP32 Station
4. Connect the PC to the same router which ESP32 is connected to. Use a network tool on the PC to
create UDP transmission.
Espressif ! /! 53
36 2017.02
7. AT Commands Examples
!
!
Below are two examples of UDP transmission:
Response:
OK
Response:
4,CONNECT
OK
Espressif ! /! 53
37 2017.02
7. AT Commands Examples
!
📖 Notes:
• "192.168.101.110" and 8080 are the remote IP and port of UDP transmission on the remote side, i.e., the UDP
configuration set by PC.
• 1112 is the local port number of ESP32. Users can define this port number. The value of this parameter will be random if
it is not defined beforehand.
• 0 means that the remote IP and port are fixed and cannot be changed. For example, if another PC also creates a UDP
entity and sends data to ESP32 port 1112, ESP32 can receive the data sent from UDP port 1112. But when data are
sent using AT command AT+CIPSEND=4,X, it will still be sent to the first PC end. If parameter 0 is not used, the data will
be sent to the new PC.
3. Send data:
AT+CIPSEND=4,5 // send 5 bytes to transmission NO.4
>DGFYQ // enter the data, no CR
Response:
SEND OK
⚠ Notice:
If the number of bytes sent is bigger than the size defined as n, the response would be busy. After sending the first n
number of bytes, SEND OK will be returned.
4. Receive data:
+IPD,4,n:xxxxxxxxxx // received n bytes, data=xxxxxxxxxxx
Response:
4,CLOSED
OK
Response:
CONNECT
OK
Espressif ! /! 53
38 2017.02
7. AT Commands Examples
!
📖 Notes:
• "192.168.101.110" and 8080 here refer to the IP and port of the remote UDP transmission terminal which is created on
a PC in Section 7.2.1.
• 1112 is the local port of ESP32. Users can define this port. The value of this parameter will be random if it is not defined
beforehand.
• 2 means the means the opposite terminal of UDP transmission can be changed. The remote IP and port will be
automatically changed to those of the last UDP connection to ESP32.
2. Send data:
AT+CIPSEND=5 // send 5 bytes
>DGFYQ // enter the data, no CR
Response:
SEND OK
⚠ Notice:
If the number of bytes sent is bigger than the size defined as n, the response would be busy. After sending the first n
number of bytes, SEND OK will be returned.
3. If you want to send data to any other UDP terminals, please designate the IP and port of the target
terminal in the command.
AT+CIPSEND=6,"192.168.101.111",1000 // send six bytes
>abcdef // enter the data, no CR
Response:
SEND OK
4. Receive data:
+IPD,n:xxxxxxxxxx // received n bytes, data=xxxxxxxxxxx
Response:
CLOSED
OK
Espressif ! /! 53
39 2017.02
7. AT Commands Examples
!
Response:
OK
Response:
OK
Response:
192.168.101.105 // device's IP that got from router
4. Connect the PC to the same router to which ESP32 is connected. Use a network tool on the PC to
create a TCP server.
!
5. Connect the device to the TCP server as a TCP client:
AT+CIPSTART="TCP","192.168.101.110",8080 // protocol, server IP & port
Response:
OK
Response:
OK
7. Send data:
AT+CIPSEND
Response:
> // From now on, data received from UART will be transparent transmitted to server
Espressif ! /! 53
40 2017.02
7. AT Commands Examples
!
!
8. Stop sending data:
If a packet of data that contains only +++ is received, the transparent transmission process will be
stopped. Please wait for at least one second before sending the next AT command.
Please note that if you input +++ directly by typing, the +++, may not be recognized as three
consecutive + because of the time needed for typing it. It is recommended that users deploy the
following software:
!
• Input String: +++;
Espressif ! /! 53
41 2017.02
7. AT Commands Examples
!
⚠ Notice:
The aim of ending the packet with +++ is to exit transparent transmission and to accept normal AT commands, while TCP
still remains connected. However, users can also deploy command AT+CIPSEND to go back into transparent transmission.
Response:
OK
Response:
CLOSED
OK
Response:
OK
!
3. Use a network tool on PC to create a UDP.
Espressif ! /! 53
42 2017.02
7. AT Commands Examples
!
!
4. Create a UDP transmission between ESP32 and the PC with a fixed remote IP and port.
AT+CIPSTART="UDP","192.168.4.2",1001,2233,0
Response:
OK
Response:
OK
6. Send data:
AT+CIPSEND
Response:
> // from now on, data received from UART will be transparent transmitted to server
Espressif ! /! 53
43 2017.02
7. AT Commands Examples
!
Please note that if you input +++ directly by typing, the +++ may not be recognized as three
consecutive + because of the prolonged time needed for typing this. It is recommended that users
deploy the following software:
!
• Input String: +++;
⚠ Notice:
The aim of ending the packet with +++ is to exit transparent transmission and to accept normal AT commands, while TCP
still remains connected. However, users can also use command AT+CIPSEND to go back into transparent transmission.
Response:
OK
Response:
CLOSED
OK
Espressif ! /! 53
44 2017.02
7. AT Commands Examples
!
Response:
OK
Response:
OK
Response:
OK
!
5. Connect the device to the PC, with the PC working as a TCP client:
Espressif ! /! 53
45 2017.02
7. AT Commands Examples
!
⚠ Notice:
When ESP32 works as a TCP server, there is a timeout mechanism. If the TCP client is connected to the ESP32 TCP
server, while there is no data transmission for a period of time, the server will disconnect from the client. To avoid such a
problem, please set up a data transmission cycle every two seconds.
6. Send data:
// ID number of connection is defaulted to be 0
AT+CIPSEND=0,4 // send 4 bytes to connection NO.0
>iopd // enter the data, no CR
Response:
SEND OK
⚠ Notice:
If the number of sent bytes is bigger than the size defined as n, the response will be busy. After sending the first n number
of bytes, SEND OK will be returned.
7. Receive data:
+IPD,0,n:xxxxxxxxxx // received n bytes, data = xxxxxxxxxx
Response:
0,CLOSED
OK
Espressif ! /! 53
46 2017.02
8. OTA Update
!
8. OTA Update
The following steps guide the users in creating a device on iot.espressif.cn and updating the OTA BIN
on it.
1. Open the website iot.espressif.cn.
!
2. Click “Join” in the upper right corner of the webpage, and enter your name, email address, and
password.
!
3. Click on “Device” in the upper right corner of the webpage, and click on “Create” to create a
device.
Espressif ! /! 53
47 2017.02
8. OTA Update
!
!
4. A key is generated when the device is successfully created, as the figure below shows.
Espressif ! /! 53
48 2017.02
8. OTA Update
!
!
5. Use the key to compile your own OTA BIN. The process of configuring the AT OTA token key is as
follows:
Espressif ! /! 53
49 2017.02
8. OTA Update
!
!
6. Click on “Product” to enter the webpage, as shown below. Click on the device created. Enter
version and corename under “ROM Deploy”. Rename the BIN compiled in Step 5 as “ota.bin” and
save the configuration.
Espressif ! /! 53
50 2017.02
8. OTA Update
!
!
7. Click on the ota.bin to save it as the current version.
!
8. Run the command AT+CIUPDATE. If the network is connected, OTA update w.
Espressif ! /! 53
51 2017.02
9. Q & A
!
9. Q&A
If you have any questions about the execution of AT commands, please contact us via Espressif
Technical Inquiries. Please describe the issues that you might encounter, including any relevant details,
as follows:
• AT Version information or AT Command: You can use command AT+GMR to acquire information
on your current AT command version.
• Hardware Module information: for example, ESP-WROOM-32.
!
• If possible, please provide the printed log information, such as:
Guru Meditation Error of type StoreProhibited occurred on core 0. Exception was unhandled.
Register dump:
PC : 40135735 PS : 00060f30 A0 : 800f913b A1 : 3ffd66c0
A2 : 00000000 A3 : 3ffd6828 A4 : 00000b68 A5 : b33f0000
A6 : b33fffff A7 : 3ffb004c A8 : 00000003 A9 : 3ffd66a0
A10 : 3ffd6828 A11 : 00000b69 A12 : 00060020 A13 : 3ffc2d30
A14 : 00000003 A15 : 00060023 SAR : 00000000 EXCCAUSE: 0000001d
EXCVADDR: 00000038 LBEG : 00000000 LEND : 00000000 LCOUNT : 00000000
Rebooting...
Espressif ! /! 53
52 2017.02
Disclaimer and Copyright Notice
Information in this document, including URL references, is subject to change without
notice.
THIS DOCUMENT IS PROVIDED AS IS WITH NO WARRANTIES WHATSOEVER,
INCLUDING ANY WARRANTY OF MERCHANTABILITY, NON-INFRINGEMENT, FITNESS
FOR ANY PARTICULAR PURPOSE, OR ANY WARRANTY OTHERWISE ARISING OUT
OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.
All liability, including liability for infringement of any proprietary rights, relating to the use of
information in this document, is disclaimed. No licenses express or implied, by estoppel or
otherwise, to any intellectual property rights are granted herein.
The Wi-Fi Alliance Member logo is a trademark of the Wi-Fi Alliance. The Bluetooth logo is
a registered trademark of Bluetooth SIG.
All trade names, trademarks and registered trademarks mentioned in this document are
Espressif IOT Team property of their respective owners, and are hereby acknowledged.
www.espressif.com Copyright © 2017 Espressif Inc. All rights reserved.