Page 2
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: Chapter Title Content Provides instructions on user-defined AT commands Chapter 1 Overview and downloading of AT firmware.
AT+CWLAPOPT—Sets the Configuration for the Command AT+CWLAP ........4.2.4. AT+CWLAP—Lists the Available APs ..................4.2.5. AT+CWQAP—Disconnects from the AP ..................4.2.6. AT+CWSAP—Configuration of the ESP32 SoftAP ..............AT+CWLIF—IP of Stations to Which the ESP32 SoftAP is Connected ........4.2.7. 4.2.8. AT+CWDHCP—Enables/Disables DHCP ..................
Page 4
AT+CWDHCPS—Sets the IP Address Allocated by ESP32 SoftAP DHCP (The configuration is 4.2.9. saved in Flash.) ............................4.2.10. AT+CWAUTOCONN—Auto-Connects to the AP or Not ............. 4.2.11. AT+CIPSTAMAC—Sets the MAC Address of the ESP32 Station ..........4.2.12. AT+CIPAPMAC—Sets the MAC Address of the ESP32 SoftAP ..........
Page 5
UDP (with Changeable Remote IP and Port) ................7.3. Transparent Transmission ......................... 7.3.1. ESP32 as a TCP Client in UART-Wi-Fi Passthrough (Single Connection Mode) ......UDP Transmission (UART-Wi-Fi PassthroughTransmission) ............7.3.2. 7.4. ESP32 as a TCP Server in Multiple Connections ..................
1.2. Downloading AT Firmware into Flash Please refer to esp-at/README.md for instructions on how to download AT firmware into flash. Please use Espressif’s official Flash Download Tools to download the firmware. Make sure you select the corresponding flash size. Espressif’s official Flash Download Tools: ...
Page 7
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 ! /! 2 53 2017.02...
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 ! /! 3 53 2017.02...
Set Command AT+GSLP=<time> <time> Response <time>: the duration of ESP32’s sleep. Unit: ms. Parameters ESP32 will wake up after Deep-sleep for as many milliseconds (ms) as <time> indicates. 3.2.5. ATE—AT Commands Echoing Execute Command Response • ATE0: Switches echo off.
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 ! /! 6 53 2017.02...
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 ! /! 7 53 2017.02...
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 ! /! 8 53 2017.02...
AT+CWQAP Disconnects from the AP. AT+CWSAP Sets the configuration of the ESP32 SoftAP. AT+CWLIF Gets the Station IP to which the ESP32 SoftAP is connected. AT+CWDHCP Enables/disables DHCP. Sets the IP range of the ESP32 SoftAP DHCP server. AT+CWDHCPS Saves the setting in flash.
Query Command: Set Command: Test Command: AT+CWMODE? AT+CWMODE=<mode> Commands AT+CWMODE=? Function: to query the current Wi-Fi Function: to set the current Wi-Fi mode of ESP32. mode of ESP32. +CWMODE:<mode> +CWMODE:<mode> Response <mode>: ‣ 1: Station mode Parameters ‣ 2: SoftAP mode ‣...
AT+CWJAP—Connects to an AP Query Command: Set Command: AT+CWJAP? AT+CWJAP=<ssid>,<pwd>[,<bssid>] Commands Function: to query the AP to which the ESP32 Function: to set the AP to which the ESP32 Station Station is already connected. needs to be connected. +CWJAP:<ssid>,<bssid>,<channel>,<rssi> Response +CWJAP:<error code> ERROR <ssid>: the SSID of the target AP.
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 13 53 2017.02...
<ssid>: string parameter, SSID of the AP. • <rssi>: signal strength. • <mac>: string parameter, MAC address 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" 4.2.5. AT+CWQAP—Disconnects from the AP Execute Command AT+CWQAP Response Parameters Espressif 14 53 2017.02...
‣ 4: WPA_WPA2_PSK This command is only available when SoftAP is active. [<max conn>] (optional): maximum number of • Stations to which ESP32 SoftAP can be connected; within the range of [1, 10]. • [<ssid hidden>] (optional): ‣ 0: SSID is broadcast. (the default setting) ‣...
<mac>: MAC address of Stations to which ESP32 SoftAP is connected. • This command cannot get a static IP. It only works when both DHCPs of the ESP32 SoftAP, and of Note the Station to which ESP32 is connected, are enabled.
<lease time>: lease time, unit: minute, range [1, 2880]. • <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.
• 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.
<ip>: string parameter, the IP address of the • ⚠ Notice: ESP32 Station. Parameters [<gateway>]: gateway. Only when the ESP32 Station is connected to an AP • can its IP address be queried. [<netmask>]: netmask. • The configuration changes will be saved in the NVS area.
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.
<enable>: Parameters ‣ 1: enable WPS/Wi-Fi Protected Setup (implemented by PBC/Push Button Configuration). ‣ 0: disable WPS (implemented by PBC). WPS must be used when the ESP32 Station is enabled. • Notes WPS does not support WEP/Wired-Equivalent Privacy encryption. •...
Deletes/Creates TCP server. AT+CIPSERVER Configures the transmission mode. AT+CIPMODE Saves the transparent transmission link in flash. AT+SAVETRANSLINK Sets timeout when ESP32 runs as a TCP server. AT+CIPSTO Updates the software through Wi-Fi. AT+CIUPDATE Shows remote IP and remote port with +IPD. AT+CIPDINFO Configures the time domain and SNTP server.
• <stat>: status of the ESP32 Station interface. ‣ 2: The ESP32 Station is connected to an AP and its IP is obtained. ‣ 3: The ESP32 Station has created a TCP or UDP transmission. ‣ 4: The TCP or UDP transmission of ESP32 Station is disconnected.
[<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 For more information please see Chapter 7: AT Command Examples. Establish UDP Transmission...
Page 30
[<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). ESP32 can only set one SSL connection at most. • Notes • SSL connection does not support UART-Wi-Fi passthrough mode (transparent transmission).
When the requirement of data length is met, the transmission of data starts. When a single packet containing +++ is received, ESP32 returns to normal command mode. If the connection cannot be established or gets Please wait for at least one second before...
AT+CIPCLOSE—Closes TCP/UDP/SSL Connection Set Command (for multiple connections): Execute Command (for single connection): Commands AT+CIPCLOSE=<link ID> AT+CIPCLOSE Function: to close TCP/UDP connection. Response <link ID>: ID number of connections to be closed; when ID=5, all Parameters connections will be closed. Espressif 27 53 2017.02...
<IP address> Parameters IP address of the ESP32 SoftAP; IP address of the ESP32 Station. Notes Only when the ESP32 Station is connected to an AP can the Station IP can be queried. 5.2.8. AT+CIPMUX—Enables/Disables Multiple Connections Set Command: Query Command: Commands AT+CIPMUX=<mode>...
During the UART-Wi-Fi passthrough transmission, if the TCP connection breaks, ESP32 will keep Notes 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...
‣ 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 •...
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 •...
ERROR will be returned if the upgrade fails due to unfavourable network conditions. Please wait • for some time before retrying. If using Espressif’s AT BIN (/esp-idf/bin/at), AT+CIUPDATE will download a new AT BIN from the • Espressif Cloud. •...
2. Connect to the router: AT+CWJAP="SSID","password" // SSID and password of router Response: 3. Query the device’s IP: AT+CIFSR 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 35 53 2017.02...
2. Connect to the router: AT+CWJAP="SSID","password" // SSID and password of router Response: 3. Query the device’s IP: AT+CIFSR 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 36 53 2017.02...
A specific ID is given to such a connection, ensuring that the data sender and receiver will not be replaced by other devices. 1. Enable multiple connections: AT+CIPMUX=1 Response: 2. Create a UDP transmission, with the ID being 4, for example. AT+CIPSTART=4,"UDP","192.168.101.110",8080,1112,0 Response: 4,CONNECT Espressif 37 53 2017.02...
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 •...
"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.
Page 45
AT+CIFSR 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...
Page 46
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: +++; • Do NOT select Send With Enter; • • Click Send Command. Espressif 41 53 2017.02...
AT+CIPCLOSE Response: CLOSED 7.3.2. UDP Transmission (UART-Wi-Fi PassthroughTransmission) Here is an example of the ESP32 working as a SoftAP in UDP transparent transmission. 1. Set the Wi-Fi mode: AT+CWMODE=3 // SoftAP+Station mode Response: 2. Connect the PC to the ESP32 SoftAP: 3. Use a network tool on PC to create a UDP.
Page 48
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: 5. Enable the transparent transmission mode: AT+CIPMODE=1 Response: 6. Send data: AT+CIPSEND Response: > // from now on, data received from UART will be transparent transmitted to server 7. Stop sending data: If a packet of data that contains only +++ is received, the transparent transmission process will be stopped.
Page 49
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. 9. Exit the transparent transmission mode: AT+CIPMODE=0 Response: 10. Close the UDP transmission: AT+CIPCLOSE Response: CLOSED Espressif 44 53 2017.02...
ESP32. Below is an example showing how a TCP server is established when ESP32 works in the SoftAP mode. If ESP32 works as a Station, set up a server in the same way after connecting ESP32 to the router.
Page 51
⚠ 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.
8. OTA Update 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.
Page 53
8. OTA Update 4. A key is generated when the device is successfully created, as the figure below shows. Espressif 48 53 2017.02...
Page 54
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 49 53 2017.02...
Page 55
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 50 53 2017.02...
Page 56
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 51 53 2017.02...
9. Q & A Q & A If you have any questions about the execution of AT commands, please contact us via Espressif Inquiries. Please describe the issues that you might encounter, including any relevant details, Technical as follows: AT Version information or AT Command: You can use command AT+GMR to acquire information •...
Need help?
Do you have a question about the ESP32 and is the answer not in the manual?
Questions and answers