Hide thumbs Also See for ESP32:
Table of Contents

Advertisement

Quick Links

ESP32 AT Instruction Set
and Examples
Version 1.1
Copyright © 2017

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the ESP32 and is the answer not in the manual?

Questions and answers

Subscribe to Our Youtube Channel

Summary of Contents for Espressif ESP32

  • Page 1 ESP32 AT Instruction Set and Examples 
 Version 1.1 Copyright © 2017...
  • 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.
  • Page 3: Table Of Contents

    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 ..................
  • Page 6: Overview

    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...
  • Page 8: Command Description

    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...
  • Page 9: Basic At Commands

    Default UART configuration, saved in flash. Sets the sleep mode. AT+SLEEP AT+SYSRAM Checks the remaining space of RAM. 3.2. Commands 3.2.1. AT—Tests AT Startup Execute Command Response Parameters 3.2.2. AT+RST—Restarts the Module Execute Command AT+RST Response Parameters Espressif ! /! 4 53 2017.02...
  • Page 10: At+Gmr-Checks Version Information

    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.
  • Page 11: At+Uart-Uart Configuration

    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...
  • Page 12: At+Uart_Cur-Current Uart Configuration, Not Saved In Flash

    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...
  • Page 13: At+Uart_Def-Default Uart Configuration, Saved In Flash

    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...
  • Page 14: At+Sleep-Sets The Sleep Mode

    ‣ 0: disable the sleep mode. ‣ 1: Modem-sleep mode. Example AT+SLEEP=0 3.2.11. AT+SYSRAM—Checks the Remaining Space of RAM Query Command AT+SYSRAM? +SYSRAM:<remaining RAM size> Response Parameters <remaining RAM size>: remaining space of RAM, unit: byte AT+SYSRAM? Example +SYSRAM:148408 Espressif ! /! 9 53 2017.02...
  • Page 15: Wi-Fi At Commands

    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.
  • Page 16: Commands

    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 ‣...
  • Page 17: At+Cwjap-Connects To An Ap

    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.
  • Page 18: At+Cwlapopt-Sets The Configuration For The Command At+Cwlap

    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...
  • Page 19: At+Cwlap-Lists The Available Aps

    <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...
  • Page 20: At+Cwsap-Configuration Of The Esp32 Softap

    ‣ 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) ‣...
  • Page 21: At+Cwlif-Ip Of Stations To Which The Esp32 Softap Is Connected

    <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.
  • Page 22: At+Cwdhcps-Sets The Ip Address Allocated By Esp32 Softap Dhcp (The Configuration Is Saved In Flash.)

    <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.
  • Page 23: At+Cipstamac-Sets The Mac Address Of The Esp32 Station

    • 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.
  • Page 24: At+Cipsta-Sets The Ip Address Of The Esp32 Station

    <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.
  • Page 25: At+Cwstartsmart-Starts Smartconfig

    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.
  • Page 26: At+Wps-Enables The Wps Function

    <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. •...
  • Page 27: Tcp/Ip-Related At Commands

    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.
  • Page 28: Commands

    • <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.
  • Page 29: At+Cipstart-Establishes Tcp Connection, Udp Transmission Or Ssl Connection

    [<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).
  • Page 31: At+Cipsend-Sends Data

    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...
  • Page 32: At+Cipsendex-Sends Data

    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...
  • Page 33: At+Cifsr-Gets The Local Ip Address

    <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>...
  • Page 34: At+Cipserver-Deletes/Creates Tcp Server

    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...
  • Page 35: At+Savetranslink-Saves The Transparent Transmission Link In Flash

    ‣ 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 •...
  • Page 36: At+Cipsto-Sets The Tcp Server Timeout

    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 •...
  • Page 37: At+Cipsntptime-Queries The Sntp Time

    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. •...
  • Page 38: Ipd-Receives Network Data

    +IPD command. • [<remote IP>]: remote IP, enabled by command AT+CIPDINFO=1. Parameters [<remote port>]: remote port, enabled by command AT+CIPDINFO=1. • • <link ID>: ID number of connection. <len>: data length. • • <data>: data received. Espressif 33 53 2017.02...
  • Page 39: At Commands With Configuration Saved In The Nvs Area

    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: NVS parameter area is 0xFA000 ~ 0x110000, and it is 88 KB in size. Espressif 34 53 2017.02...
  • Page 40: At Commands Examples

    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...
  • Page 41: Udp Transmission

    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...
  • Page 42: Udp (With Fixed Remote Ip And Port)

    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...
  • Page 43: Udp (With Changeable Remote Ip And Port)

    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 •...
  • Page 44: Transparent Transmission

    "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...
  • Page 47: Udp Transmission (Uart-Wi-Fi Passthroughtransmission)

    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...
  • Page 50: Esp32 As A Tcp Server In Multiple Connections

    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.
  • Page 52: Ota Update

    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...
  • Page 57: Q & A

    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 •...
  • Page 58 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. Copyright © 2017 Espressif Inc. All rights reserved. www.espressif.com...

Table of Contents