(ESP32-AT) (v2 2 0 0) User-Guide
(ESP32-AT) (v2 2 0 0) User-Guide
1 Get Started 3
1.1 What is ESP-AT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.2 Hardware Connection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.3 Downloading Guide . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
2 AT Binary Lists 23
2.1 Released Firmware . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
2.2 Released Firmware . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
2.3 Released Firmware . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
2.4 Released Firmware . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
3 AT Command Set 27
3.1 Basic AT Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
3.2 Wi-Fi AT Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
3.3 TCP/IP AT Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
3.4 [ESP32 Only] Bluetooth® Low Energy AT Commands . . . . . . . . . . . . . . . . . . . . . . . . . 113
3.5 [ESP32 Only] Classic Bluetooth® AT Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . 154
3.6 MQTT AT Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172
3.7 HTTP AT Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183
3.8 [ESP32 Only] Ethernet AT Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187
3.9 [ESP8266 Only] Signaling Test AT Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190
3.10 Web server AT Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190
3.11 [ESP32 & ESP32-S2 & ESP32-C3] Driver AT Commands . . . . . . . . . . . . . . . . . . . . . . . 191
3.12 AT Command Set Comparison . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201
3.13 AT Command Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 206
3.14 AT Commands with Configuration Saved in the Flash . . . . . . . . . . . . . . . . . . . . . . . . . 207
3.15 AT Messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208
i
5.2 How to Set AT Port Pins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261
5.3 How to add user-defined AT commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 265
5.4 How To Create Factory Parameter Bin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 277
5.5 How To Customize ble services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 280
5.6 The Secondary Partitions Table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281
5.7 How to use ESP-AT Classic Bluetooth . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 282
5.8 How to enable ESP-AT Ethernet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 284
5.9 How to Add a New Platform . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 285
5.10 ESP32 SDIO AT Guide . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 286
5.11 SPI AT Guide . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 288
5.12 How to implement OTA update . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 292
5.13 How to update the esp-idf version . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295
5.14 How to understand the differences of each type of module . . . . . . . . . . . . . . . . . . . . . . . 296
5.15 AT API Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 300
Index 317
ii
ESP-AT User Guide
[]
This is the documentation for the ESP-AT.
Contents 1
ESP-AT User Guide
2 Contents
CHAPTER 1
Get Started
[]
This Get Started guide provides users with detailed information on what is ESP-AT, how to connect hardware, and
how to download and flash AT firmware. It consists of the following parts:
Note: Currently, ESP-AT is based on ESP-IDF or ESP8266_RTOS_SDK, not ESP8266 NonOS SDK.
AT commands start with “AT”, which stand for “Attention”, and end with a new line (CR LF). Every time you send
a command, you will reveive an OK or ERROR, which indicates the final execution status of the current command.
Please be noted that all commands are executed serially, which means only one AT command can be executed at a
time. Therefore, you should wait for the previous command to be executed before sending out the next one. Otherwise,
you will receive busy P.... For more details about AT commands, please refer to AT Command Set.
By default, the host MCU connects to the ESP board via UART, and sends/receives AT commands/responses through
UART. But you can also use other interfaces, such as SDIO, according to your actual use scenario.
You can develop your own AT commands based on our ESP-AT project and implement more features according to
your actual use scenario.
3
ESP-AT User Guide
Please note that in the above picture, four jump wires are used to connect the ESP board and USB to serial converter.
If you don’t use hardware flow control, two wires connecting TX/RX and a simpler converter will be enough.
ESP32 AT uses two UART ports: UART0 is used to download firmware and log output; UART1 is used to send AT
commands and receive AT responses.
All ESP32 modules use GPIO1 and GPIO3 as UART0, but they use different GPIOs as UART1. The following sections
illustrate which GPIOs you should connect for each ESP32 series of modules.
For more details of ESP32 modules and boards, please refer to ESP32 Modules and Boards.
ESP32-WROOM-32 Series
AT command/response 2
UART1 USB to serial converter
• GPIO16 (RX) • TX
• GPIO17 (TX) • RX
• GPIO15 (CTS) • RTS
• GPIO14 (RTS) • CTS
Note 1: Connection between individual pins of the ESP board and the PC is already established internally on the ESP
board. You only need to provide USB cable between the board and PC.
Note 2: Connection between CTS/RTS is optional, depending on whether you want to use hardware flow control.
If you want to connect your device directly with ESP32-WROOM-32 rather than the ESP board that integrates it,
please refer to ESP32-WROOM-32 Datasheet for more details.
ESP32-WROVER Series
AT command/response 2
UART1 USB to serial converter
• GPIO19 (RX) • TX
• GPIO22 (TX) • RX
• GPIO15 (CTS) • RTS
• GPIO14 (RTS) • CTS
Note 1: Connection between individual pins of the ESP board and the PC is already established internally on the ESP
board. You only need to provide USB cable between the board and PC.
Note 2: Connection between CTS/RTS is optional, depending on whether you want to use hardware flow control.
If you want to connect your device directly with ESP32-WROVER rather than the ESP board that integrates it, please
refer to ESP32-WROVER Datasheet for more details.
ESP32-PICO Series
AT command/response 2
UART1 USB to serial converter
• GPIO19 (RX) • TX
• GPIO22 (TX) • RX
• GPIO15 (CTS) • RTS
• GPIO14 (RTS) • CTS
Note 1: Connection between individual pins of the ESP board and the PC is already established internally on the ESP
board. You only need to provide USB cable between the board and PC.
Note 2: Connection between CTS/RTS is optional, depending on whether you want to use hardware flow control.
If you want to connect your device directly with ESP32-PICO-D4 rather than the ESP board that integrates it, please
refer to ESP32-PICO-D4 Datasheet for more details.
ESP32-SOLO Series
AT command/response 2
UART1 USB to serial converter
• GPIO16 (RX) • TX
• GPIO17 (TX) • RX
• GPIO15 (CTS) • RTS
• GPIO14 (RTS) • CTS
Note 1: Connection between individual pins of the ESP board and the PC is already established internally on the ESP
board. You only need to provide USB cable between the board and PC.
Note 2: Connection between CTS/RTS is optional, depending on whether you want to use hardware flow control.
If you want to connect your device directly with ESP32-SOLO-1 rather than the ESP board that integrates it, please
refer to ESP32-SOLO-1 Datasheet for more details.
ESP32-S2 AT uses two UART ports: UART0 is used to download firmware and log output; UART1 is used to send
AT commands and receive AT responses.
AT command/response 2
UART1 USB to serial converter
• GPIO21 (RX) • TX
• GPIO17 (TX) • RX
• GPIO20 (CTS) • RTS
• GPIO19 (RTS) • CTS
Note 1: Connection between individual pins of the ESP board and the PC is already established internally on the ESP
board. You only need to provide USB cable between the board and PC.
Note 2: Connection between CTS/RTS is optional, depending on whether you want to use hardware flow control.
If you want to connect your device directly with ESP32-S2-WROOM rather than the ESP board that integrates it,
please refer to ESP32-S2-WROOM & ESP32-S2-WROOM-I Datasheet for more details.
ESP32-C3 AT uses two UART ports: UART0 is used to download firmware and log output; UART1 is used to send
AT commands and receive AT responses.
AT command/response 2
UART1 USB to serial converter
• GPIO6 (RX) • TX
• GPIO7 (TX) • RX
• GPIO5 (CTS) • RTS
• GPIO4 (RTS) • CTS
Note 1: Connection between individual pins of the ESP board and the PC is already established internally on the ESP
board. You only need to provide USB cable between the board and PC.
Note 2: Connection between CTS/RTS is optional, depending on whether you want to use hardware flow control.
If you want to connect your device directly with ESP32-C3-MINI-1 rather than the ESP board that integrates it, please
refer to ESP32-C3-MINI-1 Datasheet for more details.
ESP8266 AT uses two UART ports: UART0 is used to download firmware and send AT commands and receive AT
responses; UART1 is used to log output.
AT command/response 2
UART0 USB to serial converter
• GPIO13 (RX) • TX
• GPIO15 (TX) • RX
• GPIO3 (CTS) • RTS
• GPIO1 (RTS) • CTS
Log output
UART1 USB to serial converter
• GPIO2 (TX) • RX
Note 1: Connection between individual pins of the ESP board and the PC is already established internally on the ESP
board. You only need to provide USB cable between the board and PC.
Note 2: Connection between CTS/RTS is optional, depending on whether you want to use hardware flow control.
Note: The default ESP8266 RTOS AT firmware for ESP-WROOM-02 swaps RX/TX with CTS/RTS. If you want to
use hardware flow control, you need to disconnect UART1, desolder CP2102N chip from the ESP board, and connect
the board with 3.3 V and GND of the converter to supply power.
If you want to connect your device directly with ESP-WROOM-02 or ESP-WROOM-02D/02U rather than the ESP
board that integrates it, please refer to ESP-WROOM-02 Datasheet or ESP-WROOM-02D/02U Datasheet for more
details.
For more details about ESP8266 modules, please refer to ESP8266 documentation.
.
at_customize.bin // secondary partition table
bootloader // bootloader
bootloader.bin
customized_partitions // AT customized binaries
ble_data.bin
client_ca.bin
client_cert.bin
client_key.bin
factory_param.bin
factory_param_WROOM-32.bin
mqtt_ca.bin
(continues on next page)
The file download.config contains the configuration to flash the firmware into multiple addresses:
• --flash_mode dio means the firmware is compiled with flash DIO mode.
• --flash_freq 40m means the firmware’s flash frequency is 40 MHz.
• --flash_size 4MB means the firmware is using flash size 4 MB.
• 0x10000 ota_data_initial.bin means downloading ota_data_initial.bin into the address
0x10000.
Windows
Before starting to flash, you need to download Flash Download Tools for Windows. For more details about the tools,
please see readme.pdf or the doc folder in the zip folder.
• Open the ESP Flash Download Tool.
• Select your target chip. For example, choose “ESP8266 DownloadTool” for ESP8266 chip; choose “ESP32-S2
DownloadTool” for ESP32-S2 chip. (Here, we select ESP32 DownloadTool.)
• Flash AT firmware into your device. You can select either of the two ways below.
– To download one combined factory bin to address 0, select “DoNotChgBin” to use the default configuration
of the factory bin.
– To download multiple bins separately to different addresses, set up the configurations according to the file
download.config and do NOT select “DoNotChgBin”.
In case of flashing issues, please verify what the COM port number of download interface of the ESP board is and
select it from “COM:” dropdown list. If you don’t know the port number, you can refer to Check port on Windows for
details.
When you finish flashing, please Check Whether AT Works.
Linux or macOS
Replace PORTNAME with your port name. If you don’t know it, you can refer to Check port on Linux and
macOS for details.
Replace download.config with the content inside the file.
Below is the example command for ESP32-WROOM-32.
• To download the bins together to one address, enter the following command and replace PORTNAME and
FILEDIRECTORY:
Replace PORTNAME with your port name. If you don’t know it, you can refer to Check port on Linux and
macOS for details.
Replace FILEDIRECTORY with the file directory you would flash to the address 0x0. It is normally fac-
tory/XXX.bin.
Below is the example command for ESP32-WROOM-32.
AT Binary Lists
[]
23
ESP-AT User Guide
• factory_param_XXX.bin indicates the hardware configurations for different ESP modules (see the ta-
ble below). Please make sure the correct bin is used for your specific module. If users design their
own module, they can configure it with reference to the esp-at/docs/en/Compile_and_Develop/
How_to_create_factory_parameter_bin.md, and the binaries will be automatically generated af-
ter compilation. When users flash the firmware into module according to the download.config, the
customized_partitions/factory_param.bin should be replaced with the actual module-specific
customized_partitions/factory_param_XXX.bin. UART CTS and RTS pins are optional.
– ESP32 Series
– ESP32S2 Series
Modules UART Pins (TX, RX, CTS, RTS) Factory Parameter Bin
ESP32S2-WROOM Series GPIO17, GPIO21, GPIO20, GPIO19 factory_param_WROOM.bin
ESP32S2-WROVER Series GPIO17, GPIO21, GPIO20, GPIO19 factory_param_WROVER.bin
ESP32S2-SOLO Series GPIO17, GPIO21, GPIO20, GPIO19 factory_param_SOLO.bin
ESP32S2-MINI Series GPIO17, GPIO21, GPIO20, GPIO19 factory_param_MINI.bin
– ESP32-C3 Series
Modules UART Pins (TX, RX, CTS, RTS) Factory Parameter Bin
ESP32-C3-MINI Series GPIO7, GPIO6, GPIO5, GPIO4 factory_param_MINI-1.bin
– ESP8266 Series
• ble_data.bin is to provide BLE services when the ESP32 works as a BLE server;
• server_cert.bin, server_key.bin and server_ca.bin are examples of SSL server‘s certificate;
• client_cert.bin, client_key.bin and client_ca.bin are examples of SSL client‘s certificate.
If some of the functions are not used, then the corresponding binaries need not to be downloaded into flash.
AT Command Set
[]
Here is a list of AT commands. Some of them can only work on the ESP32 series, so they are marked as [ESP32
Only] at the beginning; those without any mark can work on all ESP series, including ESP32, ESP8266, ESP32-S2,
and ESP32-C3.
27
ESP-AT User Guide
Execute Command
Command:
AT
Response:
OK
Execute Command
Command:
AT+RST
Response:
OK
Execute Command
Command:
AT+GMR
Response:
OK
Parameters
• <AT version info>: information about the esp-at core library version, which is under the directory: esp-at/
components/at/lib/. Code is closed source, no plan to open.
• <SDK version info>: information about the esp-at platform sdk version, which is defined in file: esp-at/
module_config/module_{platform}_default/IDF_VERSION
• <compile time>: the time to compile the firmware.
• <Bin version>: esp-at firmware version. Version information can be modified in menuconfig.
Note
• If you have any issues on esp-at firmware, please provide AT+GMR version information firstly.
Example
AT+GMR
AT version:2.2.0.0-dev(ca41ec4 - ESP32 - Sep 16 2020 11:28:17)
SDK version:v4.0.1-193-ge7ac221b4
compile time(98b95fc):Oct 29 2020 11:23:25
Bin version:2.1.0(MINI-1)
OK
3.1.4 AT+CMD: List all AT commands and types supported in current firmware
Query Command
Command:
AT+CMD?
Response:
OK
Parameters
Set Command
Command:
AT+GSLP=<time>
Response:
<time>
OK
Parameter
• <time>: the duration when the device stays in Deep-sleep. Unit: millisecond. When the time is up, the device
automatically wakes up, calls Deep-sleep wake stub, and then proceeds to load the application.
– For ESP32 devices:
Notes
• For ESP8266 devices, you must connect GPIO16 to RST pin to wake them up automatically when time is up.
• For all devices, affected by external factors, the theoretical and actual time of Deep-sleep will be different.
• ESP8266 devices can be waken up from Deep-sleep by directly triggering the RST pin low-level pulse.
Execute Command
Command:
ATE0
or
ATE1
Response:
OK
Parameters
Execute Command
Command:
AT+RESTORE
Response:
OK
Notes
• The execution of this command will restore all parameters saved in flash to factory default settings of the module.
• The device will be restarted when this command is executed.
Query Command
Command:
AT+UART_CUR?
Response:
+UART_CUR:<baudrate>,<databits>,<stopbits>,<parity>,<flow control>
OK
Set Command
Command:
AT+UART_CUR=<baudrate>,<databits>,<stopbits>,<parity>,<flow control>
Response:
OK
Parameters
Notes
• The Query Command will return actual values of UART configuration parameters, which may have minor
differences from the set value because of the clock division.
• The configuration changes will NOT be saved in flash.
• To use hardware flow control, you need to connect CTS/RTS pins of your ESP device. For more de-
tails, please refer to Hardware Connection or components/customized_partitions/raw_data/
factory_param/factory_param_data.csv.
Example
AT+UART_CUR=115200,8,1,0,3
Query Command
Command:
AT+UART_DEF?
Response:
+UART_DEF:<baudrate>,<databits>,<stopbits>,<parity>,<flow control>
OK
Set Command
Command:
AT+UART_DEF=<baudrate>,<databits>,<stopbits>,<parity>,<flow control>
Response:
OK
Parameters
– 1: Odd
– 2: Even
• <flow control>: flow control
– 0: flow control is not enabled
– 1: enable RTS
– 2: enable CTS
– 3: enable both RTS and CTS
Notes
• The configuration changes will be saved in the NVS area, and will still be valid when the chip is powered on
again.
• To use hardware flow control, you need to connect CTS/RTS pins of your ESP device. For more de-
tails, please refer to Hardware Connection or components/customized_partitions/raw_data/
factory_param/factory_param_data.csv.
Example
AT+UART_DEF=115200,8,1,0,3
Set Command
Command:
AT+SLEEP=<sleep mode>
Response:
OK
Parameter
• <sleep mode>:
– 0: Disable the sleep mode.
– 1: Modem-sleep DTIM mode. RF will be periodically closed according to AP DTIM.
– 2: Light-sleep mode. CPU will automatically sleep and RF will be periodically closed according to
listen interval set by AT+CWJAP.
– 3: Modem-sleep listen interval mode. RF will be periodically closed according to listen interval
set by AT+CWJAP.
Note
• Modem-sleep mode and Light-sleep mode can be set only in station mode.
• Before setting the Light-sleep mode, it is recommended to set the wakeup source in advance through the com-
mand AT+SLEEPWKCFG, otherwise ESP devices can’t wake up and will always be in sleep mode.
• After setting the Light-sleep mode, if the Light-sleep wakeup condition is not met, ESP devices will automati-
cally enter the sleep mode. When the Light-sleep wakeup condition is met, ESP devices will automatically wake
up from sleep mode.
Example
AT+SLEEP=0
3.1.11 AT+SYSRAM: Query Current Remaining Heap Size and Minimum Heap Size
Query Command
Command:
AT+SYSRAM?
Response:
Parameters
Example
AT+SYSRAM?
+SYSRAM:148408,84044
OK
Query Command
Function:
Query the current system prompt information state.
Command:
AT+SYSMSG?
Response:
+SYSMSG:<state>
OK
Set Command
Function:
Configure system prompt information.
Command:
AT+SYSMSG=<state>
Response:
OK
Parameter
• <state>:
– Bit0: Prompt information when quitting Wi-Fi Passthrough Mode.
Notes
Example
Query Command
Function:
Query the current available user’s RAM size.
Command:
AT+USERRAM?
Response:
+USERRAM:<size>
OK
Set Command
Function:
Operate user’s free RAM
Command:
AT+USERRAM=<operation>,<size>[,<offset>]
Response:
:: +USERRAM:<length>,<data> // esp-at returns this response only when the operator is read
OK
Parameters
• <operation>:
– 0: release user’s RAM
– 1: malloc user’s RAM
– 2: write user’s RAM
– 3: read user’s RAM
– 4: clear user’s RAM
• <size>: the size to malloc/read/write
• <offset>: the offset to read/write. Default: 0
Notes
• Please malloc the RAM size before you perform any other operations.
• If the operator is write, wrap return > after the write command, then you can send the data that you want to
write. The length should be parameter <length>.
• If the operator is read and the length is bigger than 1024, ESP-AT will reply multiple times in the same format,
each reply can carry up to 1024 bytes of data, and eventually end up with \r\nOK\r\n.
Example
Query Command
Function:
Query user partitions in flash.
Command:
AT+SYSFLASH?
Response:
+SYSFLASH:<partition>,<type>,<subtype>,<addr>,<size>
OK
Set Command
Function:
Read/write the user partitions in flash.
Command:
AT+SYSFLASH=<operation>,<partition>,<offset>,<length>
Response:
+SYSFLASH:<length>,<data>
OK
Parameters
• <operation>:
– 0: erase sector
– 1: write data into the user partition
– 2: read data from the user partition
• <partition>: name of user partition
• <offset>: offset of user partition
• <length>: data length
• <type>: type of user partition
• <subtype>: subtype of user partition
• <addr>: address of user partition
• <size>: size of user partition
Notes
• Please make sure that you have downloaded at_customize.bin before using this command. For more details,
please refer to The Secondary Partitions Table.
• When erasing the targeted user partition in its entirety, you can omit the parameters <offset> and <length>.
For example, command AT+SYSFLASH=0,"ble_data" can erase the entire “ble_data” user partition. But
if you want to keep the two parameters, they have to be 4KB-aligned.
• The introduction to partitions is in ESP-IDF Partition Tables.
• If the operator is write, wrap return > after the write command, then you can send the data that you want to
write. The length should be parameter <length>.
• If the operator is write, please make sure that you have already erased this partition.
• If the operator is write on a PKI bin, the <length> should be 4 bytes aligned.
Example
Set Command
Command:
AT+FS=<type>,<operation>,<filename>,<offset>,<length>
Response:
OK
Parameters
Notes
• Please make sure that you have downloaded at_customize.bin before using this command. For more details,
refer to ESP-IDF Partition Tables and The Secondary Partitions Table.
• If the length of the read data is greater than the actual file length, only the actual data length of the file will be
returned.
• If the operator is write, wrap return > after the write command, then you can send the data that you want to
write. The length should be parameter <length>.
Example
// delete a file.
AT+FS=0,0,"filename"
Query Command
Function:
Query the RF TX Power.
Command:
AT+RFPOWER?
Response:
+RFPOWER:<wifi_power>,<ble_adv_power>,<ble_scan_power>,<ble_conn_power>
OK
Set Command
Command:
AT+RFPOWER=<wifi_power>[,<ble_adv_power>,<ble_scan_power>,<ble_conn_power>]
Response:
OK
Parameters
• <wifi_power>: the unit is 0.25 dBm. For example, if you set the value to 78, the actual maximum RF Power
value is 78 * 0.25 dBm = 19.5 dBm. After you configure it, please confirm the actual value by entering the
command AT+RFPOWER?.
– For ESP32 and ESP32-S2 devices, the range is [40,84]:
3.1.17 Note
• Since the RF TX Power is actually divided into several levels, and each level has its own value range, the
wifi_power value queried by the esp_wifi_get_max_tx_power may differ from the value set by
Execute Command
Command:
AT+SYSROLLBACK
Response:
OK
Note
• This command will not upgrade via OTA. It only rolls back to the firmware which is in the other OTA partition.
Query Command
Function:
Query the time stamp.
Command:
AT+SYSTIMESTAMP?
Response:
+SYSTIMESTAMP:<Unix_timestamp>
OK
Set Command
Function:
Set local time stamp. It will be the same as SNTP time when the SNTP time is updated.
Command:
AT+SYSTIMESTAMP=<Unix_timestamp>
Response:
OK
Parameter
Example
Query Command
Function:
Query whether the AT error code prompt is enabled or not.
Command:
AT+SYSLOG?
Response:
+SYSLOG:<status>
OK
Set Command
Function:
Enable or disable the AT error code prompt.
Command:
AT+SYSLOG=<status>
Response:
OK
Parameter
Example
OK
AT+FAKE
ERR CODE:0x01090000
ERROR
OK
AT+FAKE
// No `ERR CODE:0x01090000`
ERROR
• extension: error extension information. There are different extensions for different subcategory. For more
information, please see the components/at/include/esp_at.h.
For example, the error code ERR CODE:0x01090000 means the command is not supported.
3.1.21 AT+SLEEPWKCFG: Set the Light-sleep Wakeup Source and Awake GPIO
Set Command
Command:
AT+SLEEPWKCFG=<wakeup source>,<param1>[,<param2>]
Response:
OK
Parameters
• <wakeup source>:
– 0: wakeup by a timer.
– 1: reserved.
– 2: wakeup by GPIO.
• <param1>:
– If the wakeup source is a timer, it means the time before wakeup. Unit: millisecond.
– If the wakeup source is GPIO, it means the GPIO number.
• <param2>:
– If the wakeup source is GPIO, it means the wakeup level:
– 0: low level.
– 1: high level.
Note
• GPIO16 as the RTC IO can not be set as GPIO wakeup source on ESP8266 platform for light sleep.
Example
// Timer wakeup
AT+SLEEPWKCFG=0,1000
Query Command
Function:
Query the AT parameter store mode.
Command:
AT+SYSSTORE?
Response:
+SYSSTORE:<store_mode>
OK
Set Command
Command:
AT+SYSSTORE=<store_mode>
Response:
OK
Parameter
• <store_mode>:
– 0: command configuration is not stored into flash.
– 1: command configuration is stored into flash. (Default)
Note
• This command affects set commands only. Query commands are always fetched from RAM.
• Affected commands:
– AT+SYSMSG
– AT+CWMODE
– AT+CIPV6
– AT+CWJAP
– AT+CWSAP
– AT+CWRECONNCFG
– AT+CIPAP
– AT+CIPSTA
– AT+CIPAPMAC
– AT+CIPSTAMAC
– AT+CIPDNS
– AT+CIPSSLCCONF
– AT+CIPRECONNINTV
– AT+CIPTCPOPT
– AT+CWDHCPS
– AT+CWDHCP
– AT+CWSTAPROTO
– AT+CWAPPROTO
– AT+CWJEAP
– AT+CIPETH
– AT+CIPETHMAC
– AT+BLENAME
– AT+BTNAME
– AT+BLEADVPARAM
– AT+BLEADVDATA
– AT+BLEADVDATAEX
– AT+BLESCANRSPDATA
– AT+BLESCANPARAM
– AT+BTSCANMODE
Examples
AT+SYSSTORE=0
AT+CWMODE=1 // Not stored into flash
AT+CWJAP="test","1234567890" // Not stored into flash
AT+SYSSTORE=1
AT+CWMODE=3 // Stored into flash
AT+CWJAP="test","1234567890" // Stored into flash
Set Command
Command:
AT+SYSREG=<direct>,<address>[,<write value>]
Response:
Parameters
Note
• AT does not check address. Make sure that the registers you are operating on are valid.
Example
// Enable ESP32-S2 IO33 output, 0x3F40402C means base address 0x3F404000 add relative
˓→address 0x2C (GPIO_ENABLE1_REG)
AT+SYSREG=1,0x3F40402C,0x2
Query Command
Command:
AT+SYSTEMP?
Response:
+SYSTEMP:<temperature>
OK
Parameter
Note
Example
AT+SYSTEMP?
+SYSTEMP:21.59
OK
Query Command
Function:
Query the Wi-Fi mode of ESP devices.
Command:
AT+CWMODE?
Response:
+CWMODE:<mode>
OK
Set Command
Function:
Set the Wi-Fi mode of ESP devices.
Command:
AT+CWMODE=<mode>[,<auto_connect>]
Response:
OK
Parameters
• <mode>:
– 0: Null mode. Wi-Fi RF will be disabled.
– 1: Station mode.
– 2: SoftAP mode.
– 3: SoftAP+Station mode.
• <auto_connect>: Enable or disable automatic connection to an AP when you change the mode of the ESP
device from the SoftAP mode or null mode to the station mode or the SoftAP+Station mode. Default: 1. If you
omit the parameter, the default value will be used, i.e. automatically connecting to an AP.
– 0: The ESP device will not automatically connect to an AP.
– 1: The ESP device will automatically connect to an AP if the configuration to connect to the AP has already
been saved in flash before.
Note
Example
AT+CWMODE=3
Query Command
Function:
Query the Wi-Fi state and Wi-Fi information of ESP devices.
Command:
AT+CWSTATE?
Response:
+CWSTATE:<state>,<"ssid">
OK
Parameters
Note
• When ESP station is not connected to an AP, it is recommended to use this command to query Wi-Fi information;
after ESP station is connected to an AP, it is recommended to use AT+CWJAP to query Wi-Fi information.
Query Command
Function:
Query the AP to which the ESP Station is already connected.
Command:
AT+CWJAP?
Response:
+CWJAP:<ssid>,<bssid>,<channel>,<rssi>,<pci_en>,<reconn_interval>,<listen_interval>,
˓→<scan_mode>,<pmf>
OK
Set Command
Function:
Connect an ESP station to a targeted AP.
Command:
AT+CWJAP=[<ssid>],[<pwd>][,<bssid>][,<pci_en>][,<reconn_interval>][,<listen_interval>
˓→][,<scan_mode>][,<jap_timeout>][,<pmf>]
Response:
WIFI CONNECTED
WIFI GOT IP
OK
[WIFI GOT IPv6 LL]
[WIFI GOT IPv6 GL]
or
+CWJAP:<error code>
ERROR
Execute Command
Function:
Connect an ESP station to a targeted AP with last Wi-Fi configuration.
Command:
AT+CWJAP
Response:
WIFI CONNECTED
WIFI GOT IP
OK
[WIFI GOT IPv6 LL]
[WIFI GOT IPv6 GL]
or
+CWJAP:<error code>
ERROR
Parameters
– [1,7200]: The ESP station will reconnect to the AP at the specified interval when disconnected.
• <listen_interval>: the interval of listening to the AP’s beacon. Unit: AP beacon intervals. Default: 3. Range:
[1,100].
• <scan_mode>:
– 0: fast scan. It will end after finding the targeted AP. The ESP station will connect to the first scanned AP.
– 1: all-channel scan. It will end after all the channels are scanned. The device will connect to the scanned
AP with the strongest signal.
• <jap_timeout>: maximum timeout for AT+CWJAP command. Unit: second. Default: 15. Range: [3,600].
• <pmf>: Protected Management Frames. Default: 0.
– 0 means disable PMF.
– bit 0: PMF capable, advertizes support for protected management frame. Device will prefer to connect in
PMF mode if other device also advertizes PMF capability.
– bit 1: PMF required, advertizes that protected management frame is required. Device will not associate to
non-PMF capable devices.
• <error code>: (for reference only)
– 1: connection timeout.
– 2: wrong password.
– 3: cannot find the target AP.
– 4: connection failed.
– others: unknown error occurred.
Notes
Example
// If the target AP's SSID is "abc" and the password is "0123456789", the command
˓→should be:
AT+CWJAP="abc","0123456789"
// If the target AP's SSID is "ab\,c" and the password is "0123456789"\", the command
˓→should be:
AT+CWJAP="ab\\\,c","0123456789\"\\"
// If multiple APs all have the SSID of "abc", the target AP can be found by BSSID:
AT+CWJAP="abc","0123456789","ca:d7:19:d8:a6:44"
AT+CWJAP="abc","0123456789",,,,,,,3
Query Command
Function:
Query the configuration of Wi-Fi reconnect.
Command:
AT+CWRECONNCFG?
Response:
+CWRECONNCFG:<interval_second>,<repeat_count>
OK
Set Command
Function:
Set the configuration of Wi-Fi reconnect.
Command:
AT+CWRECONNCFG=<interval_second>,<repeat_count>
Response:
OK
Parameters
• <interval_second>: the interval between Wi-Fi reconnections. Unit: second. Default: 0. Maximum: 7200.
– 0: The ESP station will not reconnect to the AP when disconnected.
– [1,7200]: The ESP station will reconnect to the AP at the specified interval when disconnected.
• <repeat_count>: the number of attempts the ESP device makes to reconnect to the AP. This parameter only
works when the parameter <interval_second> is not 0. Default: 0. Maximum: 1000.
– 0: The ESP station will always try to reconnect to AP.
– [1,1000]: The ESP station will attempt to reconnect to AP for the specified times.
Example
// The ESP station tries to reconnect to AP at the interval of one second for 100
˓→times.
AT+CWRECONNCFG=1,100
Notes
Set Command
Command:
Response:
OK
or
ERROR
Parameters
Example
// The first parameter is 1, meaning that the result of the command AT+CWLAP will be
˓→ordered according to RSSI;
// The second parameter is 31, namely 0x1F, meaning that the corresponding bits of
˓→<print mask> are set to 1. All parameters will be shown in the result of AT+CWLAP.
AT+CWLAPOPT=1,31
AT+CWLAP
Set Command
Function:
Query the APs with specified parameters, such as the SSID, MAC address, or channel.
Command:
AT+CWLAP=[<ssid>,<mac>,<channel>,<scan_type>,<scan_time_min>,<scan_time_max>]
Execute Command
Function:
List all available APs.
Command:
AT+CWLAP
Response:
+CWLAP:<ecn>,<ssid>,<rssi>,<mac>,<channel>,<freq_offset>,<freqcal_val>,<pairwise_
˓→cipher>,<group_cipher>,<bgn>,<wps>
OK
Parameters
Example
AT+CWLAP="Wi-Fi","ca:d7:19:d8:a6:44",6,0,400,1000
Execute Command
Command:
AT+CWQAP
Response:
OK
Query Command
Function:
AT+CWSAP?
Response:
Set Command
Function:
Set the configuration of an ESP SoftAP.
Command:
Response:
OK
Parameters
Notes
Example
AT+CWSAP="ESP","1234567890",5,3
3.2.9 AT+CWLIF: Obtain IP Address of the Station That Connects to an ESP SoftAP
Execute Command
Command:
AT+CWLIF
Response:
+CWLIF:<ip addr>,<mac>
OK
Parameters
• <ip addr>: IP address of the station that connects to the ESP SoftAP.
• <mac>: MAC address of the station that connects to the ESP SoftAP.
Note
• This command cannot get a static IP. It works only when DHCP of both the ESP SoftAP and the connected
station are enabled.
Execute Command
Function:
Disconnect all stations that are connected to the ESP SoftAP.
Command:
AT+CWQIF
Response:
OK
Set Command
Function:
Disconnect a specific station from the ESP SoftAP.
Command:
AT+CWQIF=<mac>
Response:
OK
Parameter
Query Command
Command:
AT+CWDHCP?
Response:
<state>
Set Command
Function:
Enable/disable DHCP.
Command:
AT+CWDHCP=<operate>,<mode>
Response:
OK
Parameters
• <operate>:
– 0: disable
– 1: enable
• <mode>:
– Bit0: Station DHCP
– Bit1: SoftAP DHCP
• <state>: the status of DHCP
– Bit0:
Notes
Example
// Enable Station DHCP. If the last DHCP mode is 2, the current DHCP mode will be 3.
AT+CWDHCP=1,1
// Disable SoftAP DHCP. If the last DHCP mode is 3, the current DHCP mode will be 1.
AT+CWDHCP=0,2
Query Command
Command:
AT+CWDHCPS?
Response:
Set Command
Function:
Set the IP address range of the ESP SoftAP DHCP server.
Command:
Response:
OK
Parameters
• <enable>:
– 1: Enable DHCP server settings. The parameters below have to be set.
– 0: Disable DHCP server settings and use the default IP address range.
• <lease time>: lease time. Unit: minute. Range [1,2880].
• <start IP>: start IP address of the IP address range that can be obtained from ESP SoftAP DHCP server.
• <end IP>: end IP address of the IP address range that can be obtained from ESP SoftAP DHCP server.
Notes
Example
AT+CWDHCPS=1,3,"192.168.4.10","192.168.4.15"
AT+CWDHCPS=0 // Disable the settings and use the default IP address range.
Set Command
Command:
AT+CWAUTOCONN=<enable>
Response:
OK
Parameters
• <enable>:
– 1: Enable automatic connection to an AP when powered on. (Default)
– 0: Disable automatic connection to an AP when powered on.
Note
Example
AT+CWAUTOCONN=1
Query Command
Command:
AT+CWAPPROTO?
Response:
+CWAPPROTO=<protocol>
OK
Set Command
Command:
AT+CWAPPROTO=<protocol>
Response:
OK
Parameters
• <protocol>:
– bit0: 802.11b protocol standard.
– bit1: 802.11g protocol standard.
– bit2: 802.11n protocol standard.
Note
Query Command
Command:
AT+CWSTAPROTO?
Response:
+CWSTAPROTO=<protocol>
OK
Set Command
Command:
AT+CWSTAPROTO=<protocol>
Response:
OK
Parameters
• <protocol>:
– bit0: 802.11b protocol standard.
– bit1: 802.11g protocol standard.
– bit2: 802.11n protocol standard.
Note
Query Command
Function:
Query the MAC address of the ESP Station.
Command:
AT+CIPSTAMAC?
Response:
+CIPSTAMAC:<mac>
OK
Set Command
Function:
Set the MAC address of an ESP station.
Command:
AT+CIPSTAMAC=<mac>
Response:
OK
Parameters
Notes
Example
AT+CIPSTAMAC="1a:fe:35:98:d3:7b"
Query Command
Function:
Query the MAC address of the ESP SoftAP.
Command:
AT+CIPAPMAC?
Response:
+CIPAPMAC:<mac>
OK
Set Command
Function:
Set the MAC address of the ESP SoftAP.
Command:
AT+CIPAPMAC=<mac>
Response:
OK
Parameters
Notes
Example
AT+CIPAPMAC="18:fe:35:98:d3:7b"
Query Command
Function:
Query the IP address of the ESP Station.
Command:
AT+CIPSTA?
Response:
+CIPSTA:ip:<"ip">
+CIPSTA:gateway:<"gateway">
+CIPSTA:netmask:<"netmask">
+CIPSTA:ip6ll:<"ipv6 addr">
+CIPSTA:ip6gl:<"ipv6 addr">
OK
Set Command
Function:
Set the IPv4 address of the ESP station.
Command:
AT+CIPSTA=<"ip">[,<"gateway">,<"netmask">]
Response:
OK
Parameters
• <”ip”>: string parameter showing the IPv4 address of the ESP station.
• <”gateway”>: gateway.
• <”netmask”>: netmask.
• <”ipv6 addr”>: string parameter showing the IPv6 address of the ESP station.
Notes
• For the query command, only when the ESP station is connected to an AP or the static IP address is configured
can its IP address be queried.
• The configuration changes will be saved in the NVS area if AT+SYSSTORE=1.
• The Set Command correlates with the commands that set DHCP, such as AT+CWDHCP.
– If static IP address is enabled, DHCP will be disabled;
– If DHCP is enabled, static IP address will be disabled;
– The last configuration overwrites the previous configuration.
Example
AT+CIPSTA="192.168.6.100","192.168.6.1","255.255.255.0"
Query Command
Function:
Query the IP address of the ESP SoftAP.
Command:
AT+CIPAP?
Response:
+CIPAP:ip:<"ip">
+CIPAP:gateway:<"gateway">
+CIPAP:netmask:<"netmask">
+CIPAP:ip6ll:<"ipv6 addr">
+CIPAP:ip6gl:<"ipv6 addr">
OK
Set Command
Function:
Set the IPv4 address of the ESP SoftAP.
Command:
AT+CIPAP=<"ip">[,<"gateway">,<"netmask">]
Response:
OK
Parameters
• <”ip”>: string parameter showing the IPv4 address of the ESP SoftAP.
• <”gateway”>: gateway.
• <”netmask”>: netmask.
• <”ipv6 addr”>: string parameter showing the IPv6 address of the ESP SoftAP.
Notes
Example
AT+CIPAP="192.168.5.1","192.168.5.1","255.255.255.0"
Execute Command
Function:
AT+CWSTARTSMART
Set Command
Function:
Start SmartConfig of a designated type.
Command:
AT+CWSTARTSMART=<type>[,<auth floor>]
Response:
OK
Parameters
• <type>:
– 1: ESP-TOUCH
– 2: AirKiss
– 3: ESP-TOUCH+AirKiss
• <auth floor>: Wi-Fi authentication mode floor. ESP-AT will not connect to the AP whose authmode is lower
than this floor.
– 0: OPEN (Default)
– 1: WEP
– 2: WPA_PSK
– 3: WPA2_PSK
– 4: WPA_WPA2_PSK
– 5: WPA2_ENTERPRISE
– 6: WPA3_PSK
– 7: WPA2_WPA3_PSK
Notes
• When AT returns Smartconfig connected Wi-Fi, it is recommended to delay more than 6 seconds
before executing AT+CWSTOPSMART because the ESP device needs to synchronize the SmartConfig results
to the mobile phone.
• Use command AT+CWSTOPSMART to stop SmartConfig before running other commands. Please make sure
that you do not execute other commands during SmartConfig.
Example
AT+CWMODE=1
AT+CWSTARTSMART
Execute Command
Command:
AT+CWSTOPSMART
Response:
OK
Note
• Irrespective of whether SmartConfig succeeds or not, please always call AT+CWSTOPSMART before executing
any other AT commands to release the internal memory taken up by SmartConfig.
Example
AT+CWMODE=1
AT+CWSTARTSMART
AT+CWSTOPSMART
Set Command
Command:
AT+WPS=<enable>[,<auth floor>]
Response:
OK
Parameters
• <enable>:
– 1: Enable WPS (Wi-Fi Protected Setup) that uses PBC (Push Button Configuration) mode.
– 0: Disable WPS that uses PBC mode.
• <auth floor>: Wi-Fi authentication mode floor. ESP-AT will not connect to the AP whose authmode is lower
than this floor.
– 0: OPEN (Default)
– 1: WEP
– 2: WPA_PSK
– 3: WPA2_PSK
– 4: WPA_WPA2_PSK
– 5: WPA2_ENTERPRISE
– 6: WPA3_PSK
– 7: WPA2_WPA3_PSK
Notes
Example
AT+CWMODE=1
AT+WPS=1
Set Command
Command:
AT+MDNS=<enable>[,<hostname>,<service_name>,<port>]
Response:
OK
Parameters
• <enable>:
– 1: Enable the mDNS function. The following three parameters need to be set.
– 0: Disable the mDNS function. The following three parameters does not need to be set.
Example
AT+MDNS=1,"espressif","_iot",8080
AT+MDNS=0
Query Command
Function:
Query the configuration information of the Enterprise AP to which the ESP station is already connected.
Command:
AT+CWJEAP?
Response:
+CWJEAP:<ssid>,<method>,<identity>,<username>,<password>,<security>
OK
Set Command
Function:
Connect to the targeted Enterprise AP.
Command:
AT+CWJEAP=<ssid>,<method>,<identity>,<username>,<password>,<security>[,<jeap_timeout>]
Response:
OK
or
+CWJEAP:Timeout
ERROR
Parameters
– 0: EAP-TLS.
– 1: EAP-PEAP.
– 2: EAP-TTLS.
• <identity>: identity for phase 1. String limited to 1 ~ 32.
• <username>: username for phase 2. Range: 1 ~ 32 bytes. For the EAP-PEAP and EAP-TTLS method, you
must set this parameter. For the EAP-TLS method, you don’t need to.
• <password>: password for phase 2. Range: 1 ~ 32 bytes. For the EAP-PEAP and EAP-TTLS method, you
must set this parameter. For the EAP-TLS method, you don’t need to.
• <security>:
– Bit0: Client certificate.
– Bit1: Server certificate.
• [<jeap_timeout>]: maximum timeout for AT+CWJEAP command. Unit: second. Default: 15. Range: [3,600].
Example
// Connect to EAP-TLS mode Enterprise AP, set identity, verify server certificate and
˓→load client certificate
AT+CWJEAP="dlink11111",0,"example@espressif.com",,,3
// Connect to EAP-PEAP mode Enterprise AP, set identity, username and password, not
˓→verify server certificate and not load client certificate
AT+CWJEAP="dlink11111",1,"example@espressif.com","espressif","test11",0
Error Code:
The WPA2 Enterprise error code will be prompt as ERR CODE:0x<%08x>.
AT_EAP_MALLOC_FAILED 0x8001
AT_EAP_GET_NVS_CONFIG_FAILED 0x8002
AT_EAP_CONN_FAILED 0x8003
AT_EAP_SET_WIFI_CONFIG_FAILED 0x8004
AT_EAP_SET_IDENTITY_FAILED 0x8005
AT_EAP_SET_USERNAME_FAILED 0x8006
AT_EAP_SET_PASSWORD_FAILED 0x8007
AT_EAP_GET_CA_LEN_FAILED 0x8008
AT_EAP_READ_CA_FAILED 0x8009
AT_EAP_SET_CA_FAILED 0x800A
AT_EAP_GET_CERT_LEN_FAILED 0x800B
AT_EAP_READ_CERT_FAILED 0x800C
AT_EAP_GET_KEY_LEN_FAILED 0x800D
AT_EAP_READ_KEY_FAILED 0x800E
AT_EAP_SET_CERT_KEY_FAILED 0x800F
AT_EAP_ENABLE_FAILED 0x8010
AT_EAP_ALREADY_CONNECTED 0x8011
AT_EAP_GET_SSID_FAILED 0x8012
AT_EAP_SSID_NULL 0x8013
AT_EAP_SSID_LEN_ERROR 0x8014
AT_EAP_GET_METHOD_FAILED 0x8015
Continued on next page
Note
Query Command
Function:
Query the host name of ESP Station.
Command:
AT+CWHOSTNAME?
Response:
+CWHOSTNAME:<hostname>
OK
Set Command
Function:
Set the host name of ESP Station.
Command:
AT+CWHOSTNAME=<hostname>
Response:
OK
ERROR
Parameters
• <hostname>: the host name of the ESP Station. Maximum length: 32 bytes.
Note
Example
AT+CWMODE=3
AT+CWHOSTNAME="my_test"
Query Command
Function:
Query Wi-Fi country code information.
Command:
AT+CWCOUNTRY?
Response:
+CWCOUNTRY:<country_policy>,<country_code>,<start_channel>,<total_channel_count>
OK
Set Command
Function:
Set the Wi-Fi country code information.
Command:
AT+ CWCOUNTRY=<country_policy>,<country_code>,<start_channel>,<total_channel_count>
Response:
OK
Parameters
• <country_policy>:
– 0: will change the county code to be the same as the AP that the ESP device is connected to.
– 1: the country code will not change, always be the one set by command.
• <country_code>: country code. Maximum length: 3 characters.
• <start_channel>: the channel number to start. Range: [1,14].
• <total_channel_count>: total number of channels.
Note
Example
AT+CWMODE=3
AT+CWCOUNTRY=1,"CN",1,13
Query Command
Function:
Query whether IPv6 is enabled.
Command:
AT+CIPV6?
Response:
+CIPV6:<enable>
OK
Set Command
Function:
Enable/Disable IPv6 network.
Command:
AT+CIPV6=<enable>
Response:
OK
Parameters
Notes
• 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).
Execute Command
Command:
AT+CIPSTATUS
Response:
STATUS:<stat>
+CIPSTATUS:<link ID>,<"type">,<"remote IP">,<remote port>,<local port>,<tetype>
OK
Parameters
• <tetype>:
– 0: ESP device runs as a client.
– 1: ESP device runs as a server.
Set Command
Command:
Response:
+CIPDOMAIN:<"IP address">
OK
Parameter
Example
Set Command
Command:
// Single connection (AT+CIPMUX=0):
AT+CIPSTART=<"type">,<"remote host">,<remote port>[,<keep alive>][,<"local IP">]
Response:
CONNECT
OK
Parameters
Notes
• If you want to establish TCP connection based on IPv6 network, set AT+CIPV6=1 first, and ensure the con-
nected AP by AT+CWJAP supports IPv6 and esp-at got the IPv6 address which you can check it by AT+CIPSTA.
• <keep alive> parameter will eventually be configured to the socket option TCP_KEEPIDLE. As for other
socket options of keepalive, TCP_KEEPINTVL will use 1 by default, and TCP_KEEPCNT will use 3 by default.
Example
AT+CIPSTART="TCP","iot.espressif.cn",8000
AT+CIPSTART="TCP","192.168.101.110",1000
AT+CIPSTART="TCP","192.168.101.110",1000,,"192.168.101.100"
AT+CIPSTART="TCPv6","test-ipv6.com",80
AT+CIPSTART="TCPv6","fe80::860d:8eff:fe9d:cd90",1000,,"fe80::411c:1fdb:22a6:4d24"
Set Command
Command:
Response:
CONNECT
OK
Parameters
Notes
• If the remote host over the UDP is an IPv4 multicast address (224.0.0.0 ~ 239.255.255.255), the ESP device will
send and receive the UDPv4 multicast.
• If the remote host over the UDP is an IPv4 broadcast address (255.255.255.255), the ESP device 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 ESP device will send and receive the UDP multi-
cast based on IPv6 network.
• To use the parameter <mode>, parameter <local port> must be set first.
• If you want to establish UDP connection based on IPv6 network, set AT+CIPV6=1 first, and ensure the con-
nected AP by AT+CWJAP supports IPv6 and esp-at got the IPv6 address which you can check it by AT+CIPSTA.
Example
// UDP unicast
AT+CIPSTART="UDP","192.168.101.110",1000,1002,2
AT+CIPSTART="UDP","192.168.101.110",1000,,,"192.168.101.100"
Set Command
Command:
Response:
OK
Parameters
Notes
• The number of SSL connections depends on available memory and the maximum number of connections. For
ESP8266 devices, only one SSL connection can be established due to limited memory.
• 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.
• If you want to establish SSL connection based on IPv6 network, set AT+CIPV6=1 first, and ensure the connected
AP by AT+CWJAP supports IPv6 and esp-at got the IPv6 address which you can check it by AT+CIPSTA.
• <keep alive> parameter will eventually be configured to the socket option TCP_KEEPIDLE. As for other
socket options of keepalive, TCP_KEEPINTVL will use 1 by default, and TCP_KEEPCNT will use 3 by default.
Example
AT+CIPSTART="SSL","iot.espressif.cn",8443
AT+CIPSTART="SSL","192.168.101.110",1000,,"192.168.101.100"
This command is similar to AT+CIPSTART except that you don’t need to assign an ID by yourself in multiple connec-
tions mode (AT+CIPMUX=1). The system will assign an ID to the new connection automatically.
Function:
Exit from Passthrough Mode and enter the Passthrough Receiving Mode.
Command:
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 passthrough data.
Set Command
Function:
Set the data length to be send in the Normal Transmission Mode.
Command:
Response:
OK
>
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:
ERROR
SEND OK
Execute Command
Function:
Enter the Wi-Fi Passthrough Mode.
Command:
AT+CIPSEND
Response:
OK
>
or
ERROR
Enter the Wi-Fi Passthrough Mode. The ESP8266 devices can receive 2048 bytes and send 1460 bytes at most each
time; the other ESP devices can receive 8192 bytes and send 2920 bytes at most each time. If the length of the
currently received data is greater than the maximum number of bytes that can be sent, AT will send the received data
immediately; Otherwise, the received data will be sent out within 20 ms. When a single packet containing +++ is
received, the ESP device 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.
Parameters
Set Command
Function:
Set the data length to be send in Normal Transmission Mode, or use \0 (0x5c, 0x30 ASCII) to trigger data transmis-
sion.
Command:
Response:
OK
>
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:
ERROR
SEND OK
Parameters
Notes
• When the requirement of data length is met, or when the string \0 (0x5c, 0x30 in ASCII) appears, the transmis-
sion 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.
Set Command
Function:
Close TCP/UDP/SSL connection in the multiple connections mode.
Command:
AT+CIPCLOSE=<link ID>
Execute Command
Function:
Close TCP/UDP/SSL connection in the single connection mode.
AT+CIPCLOSE
Response:
OK
Parameter
• <link ID>: ID of the connection that you want to close. If you set it to 5, all connections will be closed.
Execute Command
Command:
AT+CIFSR
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">
OK
Parameters
Note
• Only when the ESP device has the valid interface information can you query its IP address and MAC address.
Query Command
Function:
Query the connection type.
Command:
AT+CIPMUX?
Response:
+CIPMUX:<mode>
OK
Set Command
Function:
Set the connection type.
Command:
AT+CIPMUX=<mode>
Response:
OK
Parameter
Notes
• This mode can only be changed after all connections are disconnected.
• If you want to set the multiple connections mode, ESP devices 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).
Example
AT+CIPMUX=1
Query Command
Function:
Query the TCP/SSL server status.
Command:
AT+CIPSERVER?
Response:
+CIPSERVER:<mode>[,<port>,<"type">][,<CA enable>]
OK
Set Command
Command:
AT+CIPSERVER=<mode>[,<param2>][,<"type">][,<CA enable>]
Response:
OK
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”. This parameter is NOT
applicable to ESP8266 platform due to memory limitation.
• <CA enable>: not applicable to ESP8266 devices.
– 0: disable CA.
– 1: enable CA.
Notes
• 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.
Example
Query Command
Function:
Obtain the maximum number of clients allowed to connect to the TCP/SSL server.
Command:
AT+CIPSERVERMAXCONN?
Response:
+CIPSERVERMAXCONN:<num>
OK
Set Command
Function:
Set the maximum number of clients allowed to connect to the TCP/SSL server.
Command:
AT+CIPSERVERMAXCONN=<num>
Response:
OK
Parameter
• <num>: the maximum number of clients allowed to connect to the TCP/SSL server.
Note
Example
AT+CIPMUX=1
AT+CIPSERVERMAXCONN=2
AT+CIPSERVER=1,80
Query Command
Function:
Query the transmission mode.
Command:
AT+CIPMODE?
Response:
+CIPMODE:<mode>
OK
Set Command
Function:
Set the transmission mode.
Command:
AT+CIPMODE=<mode>
Response:
OK
Parameter
• <mode>:
– 0: Normal Transmission 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.
Notes
Example
AT+CIPMODE=1
Set Command
Command:
Response:
OK
Parameters
• <mode>:
– 0: ESP will NOT enter Wi-Fi Passthrough Mode on power-up.
– 1: ESP will enter Wi-Fi Passthrough Mode on power-up.
• <”remote host”>: string parameter showing the IPv4 address or IPv6 address or domain name of remote host.
• <remote port>: the remote port number.
• <”type”>: string parameter showing the type of transmission: “TCP”, “TCPv6”, “SSL”, or “SSLv6”. Default:
“TCP”.
• <keep alive>: TCP keep-alive interval. Default: 0.
– 0: disable the keep-alive function.
– 1 ~ 7200: detection interval. Unit: second.
Notes
• This command will save the Wi-Fi Passthrough Mode configuration in the NVS area. If <mode> is set to 1,
ESP device will enter the Wi-Fi Passthrough Mode in any subsequent power cycles. The configuration will take
effect after ESP reboots.
• As long as the remote host and port are valid, the configuration will be saved in flash.
• If you want to establish TCP/SSL connection based on IPv6 network, set AT+CIPV6=1 first, and ensure the con-
nected AP by AT+CWJAP supports IPv6 and esp-at got the IPv6 address which you can check it by AT+CIPSTA.
Example
AT+SAVETRANSLINK=1,"192.168.6.110",1002,"TCP"
AT+SAVETRANSLINK=1,"www.baidu.com",443,"SSL"
AT+SAVETRANSLINK=1,"240e:3a1:2070:11c0:55ce:4e19:9649:b75",8080,"TCPv6"
AT+SAVETRANSLINK=1,"240e:3a1:2070:11c0:55ce:4e19:9649:b75",8080,"SSLv6"
Set Command
Command:
Response:
OK
Parameters
• <mode>:
– 0: ESP will NOT enter Wi-Fi Passthrough Mode on power-up.
– 1: ESP will enter Wi-Fi Passthrough Mode on power-up.
• <”remote host”>: string parameter showing the IPv4 address or IPv6 address or domain name of remote host.
• <remote port>: the remote port number.
• <”type”>: string parameter showing the type of transmission: “UDP” or “UDPv6”. Default: “TCP”.
• <local port>: local port when UDP Wi-Fi passthrough is enabled on power-up.
Notes
• This command will save the Wi-Fi Passthrough Mode configuration in the NVS area. If <mode> is set to 1,
ESP device will enter the Wi-Fi Passthrough Mode in any subsequent power cycles. The configuration will take
effect after ESP reboots.
• As long as the remote host and port are valid, the configuration will be saved in flash.
• If you want to establish UDP transmission based on IPv6 network, set AT+CIPV6=1 first, and ensure the con-
nected AP by AT+CWJAP supports IPv6 and esp-at got the IPv6 address which you can check it by AT+CIPSTA.
Example
AT+SAVETRANSLINK=1,"192.168.6.110",1002,"UDP",1005
AT+SAVETRANSLINK=1,"240e:3a1:2070:11c0:55ce:4e19:9649:b75",8081,"UDPv6",1005
Query Command
Function:
Query the local TCP/SSL server timeout.
Command:
AT+CIPSTO?
Response:
+CIPSTO:<time>
OK
Set Command
Function:
Set the local TCP/SSL server timeout.
Command:
AT+CIPSTO=<time>
Response:
OK
Parameter
Notes
• When a TCP/SSL client does not communicate with the ESP 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 within the set time, the timer will restart. After the
timeout expires, the client is closed. During the set time, if the server initiate a communication with the client,
the timer will not restart. After the timeout expires, the client is closed.
Example
AT+CIPMUX=1
AT+CIPSERVER=1,1001
AT+CIPSTO=10
3.3.17 AT+CIPSNTPCFG: Query/Set the Time Zone and the SNTP Server
Query Command
Command:
AT+CIPSNTPCFG?
Response:
Set Command
Command:
Response:
OK
Parameters
Note
• 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.
Example
// Enable SNTP server, set timezone to New York of the United States (UTC05: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"
Query Command
Command:
AT+CIPSNTPTIME?
Response:
+CIPSNTPTIME:<asctime style time>
OK
Note
Example
AT+CIPSNTPCFG=1,8,"cn.ntp.org.cn","ntp.sjtu.edu.cn"
OK
AT+CIPSNTPTIME?
+CIPSNTPTIME:Mon Dec 12 02:33:32 2016
OK
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 ESP device upgrade status.
Command:
AT+CIUPDATE?
Response:
+CIPUPDATE:<state>
OK
Execute Command
Function:
Upgrade OTA the latest version of firmware via TCP/SSL from the server.
Command:
AT+CIUPDATE
Response:
+CIPUPDATE:<state>
OK
or
ERROR
Set Command
Function:
Upgrade the specified version of firmware from the server.
Command:
Response:
+CIPUPDATE:<state>
OK
or
ERROR
Parameters
• <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 Build Your Own ESP-AT Project.
• <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, user can not send AT command until OTA completes successfully
or fails.)
– 1: OTA by non-blocking mode (Users need to manually restart after upgrade done (+CIPUPDATE:4).)
• <state>:
– 0: Idle.
– 1: Server found.
– 2: Connected to the server.
– 3: Got the upgrade version.
– 4: Upgrade done.
– -1: Upgrade failed.
Notes
Example
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",,1
Set Command
Command:
AT+CIPDINFO=<mode>
Response:
OK
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.
Example
AT+CIPDINFO=1
Query Command
Function:
Query the configuration of each connection where the ESP device runs as an SSL client.
Command:
AT+CIPSSLCCONF?
Response:
+CIPSSLCCONF:<link ID>,<auth_mode>,<pki_number>,<ca_number>
OK
Set Command
Command:
Response:
OK
Parameters
• <link ID>: ID of the connection (0 ~ max). For multiple connections, if the value is max, it means all connec-
tions. 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.
Notes
• If you want this configuration to take effect immediately, run this command before establishing an SSL connec-
tion.
• The configuration changes will be saved in the NVS area. If you set the command AT+SAVETRANSLINK to
enter SSL Wi-Fi Passthrough Mode on power-up, the ESP device will establish an SSL connection based on this
configuration when powered up next time.
Query Command
Function:
Query the common name of the SSL client of each connection.
Command:
AT+CIPSSLCCN?
Response:
Set Command
Command:
Response:
OK
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.
Note
• If you want this configuration to take effect immediately, run this command before establishing the SSL con-
nection.
Query Command
Function:
Query the SNI configuration of each connection.
Command:
AT+CIPSSLCSNI?
Response:
+CIPSSLCSNI:<link ID>,<"sni">
OK
Set Command
Command:
Response:
OK
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.
Notes
• If you want this configuration to take effect immediately, run this command before establishing the SSL con-
nection.
Query Command
Function:
Query the ALPN configuration of each connection where the ESP device runs as an SSL client.
Command:
AT+CIPSSLCALPN?
Response:
+CIPSSLCALPN:<link ID>[,<"alpn">][,<"alpn">][,<"alpn">]
OK
Set Command
Command:
Response:
OK
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.
Note
• If you want this configuration to take effect immediately, run this command before establishing the SSL con-
nection.
Query Command
Function:
Query the PSK configuration of each connection where the ESP device runs as an SSL client.
Command:
AT+CIPSSLCPSK?
Response:
+CIPSSLCPSK:<link ID>,<"psk">,<"hint">
OK
Set Command
Command:
Response:
OK
Parameters
• <link ID>: ID of the connection (0 ~ max). For single connection, <link ID> is 0. For multiple connections, if
the value is max, it means all connections, max is 5 by default.
• <”psk”>: PSK identity. Maximum length: 32.
• <”hint”>: PSK hint. Maximum length: 32.
Notes
• If you want this configuration to take effect immediately, run this command before establishing the SSL con-
nection.
Query Command
Function:
Query the automatic connect interval for the Wi-Fi Passthrough Mode.
Command:
AT+CIPRECONNINTV?
Response:
+CIPRECONNINTV:<interval>
OK
Set Command
Function:
Set the automatic reconnecting interval when TCP/UDP/SSL transmission breaks in the Wi-Fi Passthrough Mode.
Command:
AT+CIPRECONNINTV=<interval>
Response:
OK
Parameter
• <interval>: the duration between automatic reconnections. Unit: 100 milliseconds. Default: 1. Range:
[1,36000].
Note
Example
AT+CIPRECONNINTV=10
Query Command
Function:
Query the socket receiving mode.
Command:
AT+CIPRECVMODE?
Response:
+CIPRECVMODE:<mode>
OK
Set Command
Command:
AT+CIPRECVMODE=<mode>
Response:
OK
Parameter
Notes
• 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. In other words, if +IPD has been reported, the message CLOSED of this connection will never
come until you send AT+CIPCLOSE or read all data by command AT+CIPRECVDATA.
Example
AT+CIPRECVMODE=1
Set Command
Command:
Response:
+CIPRECVDATA:<actual_len>,<data>
OK
or
Parameters
• <”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.
Example
AT+CIPRECVMODE=1
// For example, if host MCU gets a message of receiving 100-byte data in connection
˓→with No.0,
Query Command
Function:
Query the length of the entire data buffered for the connection.
Command:
AT+CIPRECVLEN?
Response:
OK
Parameters
• <data length of link>: length of the entire data buffered for the connection.
Note
• For SSL connections, ESP-AT will return the length of the encrypted data, so the returned length will be larger
than the real data length.
Example
AT+CIPRECVLEN?
+CIPRECVLEN:100,,,,,
OK
Set Command
Function:
Ping the remote host.
Command:
AT+PING=<"host">
Response:
+PING:<time>
OK
or
+PING:TIMEOUT // esp-at returns this response only when the domain name resolution
˓→failure or ping timeout
ERROR
Parameters
• <”host”>: string parameter showing the host IPv4 address or IPv6 address or domain name.
• <time>: the response time of ping. Unit: millisecond.
Notes
• If you want to ping a remote host based on IPv6 network, set AT+CIPV6=1 first, and ensure the connected AP
by AT+CWJAP supports IPv6 and esp-at got the IPv6 address which you can check it by AT+CIPSTA.
• 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.
Example
AT+PING="192.168.1.1"
AT+PING="www.baidu.com"
Query Command
Function:
Query the current DNS server information.
Command:
AT+CIPDNS?
Response:
Set Command
Function:
Set DNS server information.
Command:
Response:
OK
or
ERROR
Parameters
Notes
Example
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"
Query Command
Function:
Query current socket options.
Command:
AT+CIPTCPOPT?
Response:
+CIPTCPOPT:<link_id>,<so_linger>,<tcp_nodelay>,<so_sndtimeo>
OK
Set Command
Command:
Response:
OK
or
ERROR
Parameters
• <link_id>: ID of the connection (0 ~ max). For multiple connections, if the value is max, it means all connec-
tions. By default, max is 5.
• <so_linger>: configure the SO_LINGER options for the socket. Unit: second. Default: -1.
– = -1: off
Query Command
Function:
Check the initialization status of Bluetooth LE.
Command:
AT+BLEINIT?
Response:
If Bluetooth LE is initialized, AT will return:
+BLEINIT:<role>
OK
+BLEINIT:0
OK
Set Command
Function:
Initialize the role of Bluetooth LE.
Command:
AT+BLEINIT=<init>
Response:
OK
Parameter
• <init>:
– 0: deinit Bluetooth LE
– 1: client role
– 2: server role
Notes
• The file “at_customize.bin” has to be downloaded, so that the relevant commands can be used. Please refer to
How To Customize ble services for more details.
• Before using other Bluetooth LE AT commands, you should run this command first to trigger the initialization
process.
• After the initialization, the Bluetooth LE role cannot be changed unless you run AT+RST to restart the system
first and then re-initialize the Bluetooth LE role.
• If you use an ESP device as a Bluetooth LE server, a service bin should be downloaded into flash.
– To learn how to generate a service bin, please refer to esp-at/tools/readme.md.
– The download address of the service bin is the “ble_data” address in esp-
at/module_config/module_${platform}_default/at_customize.csv.
Example
AT+BLEINIT=1
Query Command
Function:
Query the Bluetooth LE Public Address.
Command:
AT+BLEADDR?
Response:
+BLEADDR:<BLE_public_addr>
OK
Set Command
Function:
Set the Bluetooth LE address type.
Command:
AT+BLEADDR=<addr_type>[,<random_addr>]
Response:
OK
Parameter
• <addr_type>:
– 0: Public Address
– 1: Random Address
Note
Example
Query Command
Function:
Query the Bluetooth LE device name.
Command:
AT+BLENAME?
Response:
+BLENAME:<device_name>
OK
Set Command
Function:
Set the Bluetooth LE device name.
Command:
AT+BLENAME=<device_name>
Response:
OK
Parameter
• <device_name>: the Bluetooth LE device name. The maximum length is 32. Default: “BLE_AT”.
Note
Example
AT+BLENAME="esp_demo"
Query Command
Function:
Query the parameters of Bluetooth LE scanning.
Command:
AT+BLESCANPARAM?
Response:
+BLESCANPARAM:<scan_type>,<own_addr_type>,<filter_policy>,<scan_interval>,<scan_
˓→window>
OK
Set Command
Function:
Set the parameters of Bluetooth LE scanning.
Command:
AT+BLESCANPARAM=<scan_type>,<own_addr_type>,<filter_policy>,<scan_interval>,<scan_
˓→window>
Response:
OK
Parameters
• <scan_type>:
– 0: passive scan
– 1: active scan
• <own_addr_type>:
– 0: Public Address
– 1: Random Address
– 2: RPA Public Address
– 3: RPA Random Address
• <filter_policy>:
– 0: BLE_SCAN_FILTER_ALLOW_ALL
– 1: BLE_SCAN_FILTER_ALLOW_ONLY_WLST
– 2: BLE_SCAN_FILTER_ALLOW_UND_RPA_DIR
– 3: BLE_SCAN_FILTER_ALLOW_WLIST_PRA_DIR
• <scan_interval>: scan interval
• <scan_window>: scan window
Note
Example
Set Command
Function:
Enable/disable scanning.
Command:
AT+BLESCAN=<enable>[,<interval>][,<filter_type>,<filter_param>]
Response:
+BLESCAN:<addr>,<rssi>,<adv_data>,<scan_rsp_data>,<addr_type>
OK
Parameters
• <enable>:
– 1: enable continuous scanning.
– 0: disable continuous scanning.
• [<interval>]: optional parameter. Unit: second.
– If you want to disable the scanning, this parameter should be omitted.
– If you want to enable the scanning, set a value for this parameter:
– When you set it to 0, it means that scanning is continuous.
– When set it to a value other than 0, for example, AT+BLESCAN=1,3, it means that scanning will last for
3 seconds and then stop automatically. The scanning results will be returned.
• [<filter_type>]: filtering option.
– 1: “MAC”.
– 2: “NAME”.
• <filter_param>: filtering parameter showing the remote device MAC address or remote device name.
• <addr>: Bluetooth LE address.
• <rssi>: signal strength.
• <adv_data>: advertising data.
• <scan_rsp_data>: scan response data.
• <addr_type>: the address type of broadcasters.
Notes
• The response OK does not necessarily come before the response +BLESCAN:<addr>,<rssi>,
<adv_data>,<scan_rsp_data>,<addr_type>. It may be output before +BLESCAN:<addr>,
<rssi>,<adv_data>,<scan_rsp_data>,<addr_type> or after it.
Example
Set Command
Function:
Set scan response.
Command:
AT+BLESCANRSPDATA=<scan_rsp_data>
Response:
OK
Parameter
• <scan_rsp_data>: scan response data is a HEX string. For example, if you want to set the response data to
“0x11 0x22 0x33 0x44 0x55”, the command should be AT+BLESCANRSPDATA="1122334455".
Example
Query Command
Function:
Query the parameters of advertising.
Command:
AT+BLEADVPARAM?
Response:
+BLEADVPARAM:<adv_int_min>,<adv_int_max>,<adv_type>,<own_addr_type>,<channel_map>,
˓→<adv_filter_policy>,<peer_addr_type>,<peer_addr>
OK
Set Command
Function:
Set the parameters of advertising.
Command:
AT+BLEADVPARAM=<adv_int_min>,<adv_int_max>, <adv_type>,<own_addr_type>,<channel_map>[,
˓→<adv_filter_policy>][,<peer_addr_type>] [,<peer_addr>]
Response:
OK
Parameters
• <adv_int_min>: minimum advertising interval. It should be less than the value of <adv_int_max>. Range:
0x0020 ~ 0x4000.
• <adv_int_max>: maximum advertising interval. It should be more than the value of <adv_int_min>.
Range: 0x0020 ~ 0x4000.
• <adv_type>:
– 0: ADV_TYPE_IND
– 1: ADV_TYPE_DIRECT_IND_HIGH
– 2: ADV_TYPE_SCAN_IND
– 3: ADV_TYPE_NONCONN_IND
• <own_addr_type>: own Bluetooth LE address type.
– 0: BLE_ADDR_TYPE_PUBLIC
– 1: BLE_ADDR_TYPE_RANDOM
• <channel_map>: channel of advertising.
– 1: ADV_CHNL_37
– 2: ADV_CHNL_38
– 4: ADV_CHNL_39
– 7: ADV_CHNL_ALL
• [<adv_filter_policy>]: filter policy of advertising.
– 0: ADV_FILTER_ALLOW_SCAN_ANY_CON_ANY
– 1: ADV_FILTER_ALLOW_SCAN_WLST_CON_ANY
– 2: ADV_FILTER_ALLOW_SCAN_ANY_CON_WLST
– 3: ADV_FILTER_ALLOW_SCAN_WLST_CON_WLST
• [<peer_addr_type>]: remote Bluetooth LE address type.
– 0: PUBLIC
– 1: RANDOM
• [<peer_addr>]: remote Bluetooth LE address.
Example
Set Command
Function:
Set advertising data.
Command:
AT+BLEADVDATA=<adv_data>
Response:
OK
Parameter
• <adv_data>: advertising data in HEX string. For example, to set the advertising data to “0x11 0x22 0x33 0x44
0x55”, the command should be AT+BLEADVDATA="1122334455".
Note
Example
Query Command
Function:
Query the parameters of advertising data.
Command:
AT+BLEADVDATAEX?
Response:
+BLEADVDATAEX:<dev_name>,<uuid>,<manufacturer_data>,<include_power>
OK
Set Command
Function:
Set the advertising data and start advertising.
Command:
AT+BLEADVDATAEX=<dev_name>,<uuid>,<manufacturer_data>,<include_power>
Response:
OK
Parameters
• <dev_name>: string parameter showing a device name. For example, if you want to set the de-
vice name to “just-test”, the command should be AT+BLEADVSTARTEX="just-test",<uuid>,
<manufacturer_data>,<include_power>.
• <uuid>: string parameter. For example, if you want to set the UUID to “0xA002”, the command should be
AT+BLEADVSTARTEX=<dev_name>,"A002",<manufacturer_data>,<include_power>.
• <manufacturer_data>: manufacturer data in HEX string. For example, if you set the manufacturer data to
“0x11 0x22 0x33 0x44 0x55”, the command should be AT+BLEADVSTARTEX=<dev_name>,<uuid>,
"1122334455",<include_power>.
• <include_power>: If you need to include the TX power in the advertising data, you should set the parameter to
1. Otherwise, set it to 0.
Note
Example
Execute Command
Function:
Start advertising.
Command:
AT+BLEADVSTART
Response:
OK
Notes
• If advertising parameters are NOT set by command AT+BLEADVPARAM=<adv_parameter>, the default pa-
rameters will be used.
• If advertising data is NOT set by command AT+BLEADVDATA=<adv_data>, the advertising playload will be
empty.
• If advertising data is preset by command AT+BLEADVDATA=<adv_data>, it will be overwritten by
AT+BLEADVDATAEX=<dev_name>,<uuid>,<manufacturer_data>,<include_power> and vice versa.
Example
Execute Command
Function:
Stop advertising.
Command:
AT+BLEADVSTOP
Response:
OK
Note
• After the start of advertising, if the Bluetooth LE connection is established successfully, it will stop advertising
automatically. In such a case, this command does NOT need to be called.
Example
Query Command
Function:
Query the Bluetooth LE connection.
Command:
AT+BLECONN?
Response:
+BLECONN:<conn_index>,<remote_address>
OK
If the connection has not been established, there will be no <conn_index> and <remote_address> in the response.
Set Command
Function:
Establish the Bluetooth LE connection.
Command:
AT+BLECONN=<conn_index>,<remote_address>[,<addr_type>,<timeout>]
Response:
OK
+BLECONN:<conn_index>,<remote_address>
+BLECONN:<conn_index>,-1
Parameters
Notes
• It is recommended to scan devices by running AT+BLESCAN before initiating a new connection to ensure that
the target device is in the broadcast state.
• The maximum timeout for connection is 30 seconds.
• If the Bluetooth LE server is initialized and the connection is established successfully, you can use this command
to discover the services in the peer device (GATTC). The following GATTC commands can also be used:
– AT+BLEGATTCPRIMSRV
– AT+BLEGATTCINCLSRV
– AT+BLEGATTCCHAR
– AT+BLEGATTCRD
– AT+BLEGATTCWR
– AT+BLEGATTSIND
Example
Query Command
Function:
Query the parameters of Bluetooth LE connection.
Command:
AT+BLECONNPARAM?
Response:
+BLECONNPARAM:<conn_index>,<min_interval>,<max_interval>,<cur_interval>,<latency>,
˓→<timeout>
OK
Set Command
Function:
Update the parameters of Bluetooth LE connection.
Command:
AT+BLECONNPARAM=<conn_index>,<min_interval>,<max_interval>,<latency>,<timeout>
Response:
OK
+BLECONNPARAM: <conn_index>,-1
Parameters
Note
• This command only supports the client role when updating its connection parameters. Of course, the connection
has to be established first.
Example
Execute Command
Function:
End the Bluetooth LE connection.
Command:
AT+BLEDISCONN=<conn_index>
Response:
Parameters
Note
Example
Set Command
Function:
Set the length of Bluetooth LE data packet.
Command:
AT+BLEDATALEN=<conn_index>,<pkt_data_len>
Response:
OK
Parameters
Note
Example
Query Command
Function:
Query the length of the maximum transmission unit (MTU).
Command:
AT+BLECFGMTU?
Response:
+BLECFGMTU:<conn_index>,<mtu_size>
OK
Set Command
Function:
Set the length of the maximum transmission unit (MTU).
Command:
AT+BLECFGMTU=<conn_index>,<mtu_size>
Response:
Parameters
Notes
Example
Execute Command
Function:
The Generic Attributes Server (GATTS) creates Bluetooth LE services.
Command:
AT+BLEGATTSSRVCRE
Response:
OK
Notes
• If you are using an ESP device as a Bluetooth LE server, a service bin should be downloaded into flash in order
to provide services.
– To learn how to generate a service bin, please refer to esp-at/tools/readme.md.
– The download address of the service bin is the “ble_data” address in esp-
at/module_config/module_${platform}_default/at_customize.csv.
• This command should be called immediately to create services, right after the Bluetooth LE server is initialized;
If a Bluetooth LE connection is established first, the service creation will fail.
• If the Bluetooth LE client is initialized, you can use this command to create local services. Some GATTS
commands can also be used, such as those to start and stop services, set attribute values, and send notifica-
tions/indications. See the list below for the specific commands.
– AT+BLEGATTSSRVCRE (It is recommended to execute this command before the connection is estab-
lished)
– AT+BLEGATTSSRVSTART (It is recommended to execute this command before the connection is estab-
lished)
– AT+BLEGATTSSRV
– AT+BLEGATTSCHAR
– AT+BLEGATTSNTFY
– AT+BLEGATTSIND
– AT+BLEGATTSSETATTR
Example
Execute Command
Function:
GATTS starts all services.
Command:
AT+BLEGATTSSRVSTART
Set Command
Function:
GATTS starts a specific service.
Command:
AT+BLEGATTSSRVSTART=<srv_index>
Response:
OK
Parameter
Example
Execute Command
Function:
GATTS stops all services.
Command:
AT+BLEGATTSSRVSTOP
Set Command
Function:
GATTS stops a specific service.
Command:
AT+BLEGATTSSRVSTOP=<srv_index>
Response:
OK
Parameter
Example
Query Command
Function:
GATTS discovers services.
Command:
AT+BLEGATTSSRV?
Response:
+BLEGATTSSRV:<srv_index>,<start>,<srv_uuid>,<srv_type>
OK
Parameters
Example
Query Command
Function:
GATTS discovers characteristics.
Command:
AT+BLEGATTSCHAR?
Response:
The response for a characteristic:
+BLEGATTSCHAR:"char",<srv_index>,<char_index>,<char_uuid>,<char_prop>
Parameters
Example
Set Command
Function:
Notify a client of the value of a characteristic value from the server.
Command:
AT+BLEGATTSNTFY=<conn_index>,<srv_index>,<char_index>,<length>
Response:
>
The symbol > indicates that AT is ready for receiving serial data, and you can enter data now. When the requirement
of data length determined by the parameter <length> is met, the notification starts.
If the data transmission is successful, AT returns:
OK
Parameters
Example
AT+BLEGATTSCHAR? // Query the characteristics which the client will be notified of.
// For example, to notify of 4-byte data using the 6th characteristic in the 3rd
˓→service, use the following command:
AT+BLEGATTSNTFY=0,3,6,4
// After the symbol ">" shows, enter the 4-byte data, such as "1234". Then the data
˓→will be transmitted automatically.
3.4.23 [ESP32 Only] AT+BLEGATTSIND: Indicate the Characteristic Value from the
Server to a Client
Set Command
Function:
Indicate the characteristic value from the server to a client.
Command:
AT+BLEGATTSIND=<conn_index>,<srv_index>,<char_index>,<length>
Response:
>
The symbol > indicates that AT is ready for receiving serial data and you can enter data now. When the requirement
of data length determined by the parameter <length> is met, the indication starts.
If the data transmission is successful, AT returns:
OK
Parameters
Example
// For example, to indicate 4 bytes of data using the 7th characteristic in the 3rd
˓→service, use the following command:
AT+BLEGATTSIND=0,3,7,4
// After the symbol ">" shows, input 4 bytes of data, such as "1234". Then the data
˓→will be transmitted automatically.
Set Command
Function:
GATTS sets its characteristic (descriptor).
Command:
AT+BLEGATTSSETATTR=<srv_index>,<char_index>,[<desc_index>],<length>
Response:
>
The symbol > indicates that AT is ready for receiving serial data and you can enter data now. When the requirement
of data length determined by the parameter <length> is met, the setting starts.
If the setting is successful, AT returns:
OK
Parameters
Note
• If the value of <length> is larger than the maximum length allowed, the setting will fail. The service table is
defined in components/customized_partitions/raw_data/ble_data.
Example
AT+BLEGATTSSETATTR=1,1,,1
// After the symbol ">" shows, input 1 byte of data, such as "8". Then the setting
˓→starts.
Query Command
Function:
Generic Attributes Client (GATTC) discovers primary services.
Command:
AT+BLEGATTCPRIMSRV=<conn_index>
Response:
+BLEGATTCPRIMSRV:<conn_index>,<srv_index>,<srv_uuid>,<srv_type>
OK
Parameters
Note
Example
Set Command
Function:
GATTC discovers included services.
Command:
AT+BLEGATTCINCLSRV=<conn_index>,<srv_index>
Response:
+BLEGATTCINCLSRV:<conn_index>,<srv_index>,<srv_uuid>,<srv_type>,<included_srv_uuid>,
˓→<included_srv_type>
OK
Parameters
Note
Example
Set Command
Function:
GATTC discovers characteristics.
Command:
AT+BLEGATTCCHAR=<conn_index>,<srv_index>
Response:
The response for a characteristic:
+BLEGATTCCHAR:"char",<conn_index>,<srv_index>,<char_index>,<char_uuid>,<char_prop>
Parameters
Note
Example
Set Command
Function:
GATTC reads a characteristic or descriptor.
Command:
AT+BLEGATTCRD=<conn_index>,<srv_index>,<char_index>[,<desc_index>]
Response:
+BLEGATTCRD:<conn_index>,<len>,<value>
OK
Parameters
Notes
Example
// For example, to read 1st descriptor of the 2nd characteristic in the 3rd service,
˓→use the following command:
AT+BLEGATTCRD=0,3,2,1
Set Command
Function:
GATTC writes characteristics or descriptors.
Command:
AT+BLEGATTCWR=<conn_index>,<srv_index>,<char_index>[,<desc_index>],<length>
Response:
>
The symbol > indicates that AT is ready for receiving serial data and you can enter data now. When the requirement
of data length determined by the parameter <length> is met, the writing starts.
If the setting is successful, AT returns:
OK
Parameters
Notes
Example
// For example, to write 6 bytes of data to the 4th characteristic in the 3rd service,
˓→ use the following command:
AT+BLEGATTCWR=0,3,4,,6
// After the symbol ">" shows, input 6 bytes of data, such as "123456". Then the
˓→writing starts.
Query Command
Function:
Query the parameters of Bluetooth LE Serial Port Profile (SPP).
Command:
AT+BLESPPCFG?
Response:
+BLESPPCFG:<tx_service_index>,<tx_char_index>,<rx_service_index>,<rx_char_index>
OK
Set Command
Function:
Set or reset the parameters of Bluetooth LE SPP.
Command:
AT+BLESPPCFG=<cfg_enable>[,<tx_service_index>,<tx_char_index>,<rx_service_index>,<rx_
˓→char_index>]
Response:
OK
Parameters
• <cfg_enable>:
– 0: all the SPP parameters will be reset, and the following four parameters don’t need input.
– 1: you should input the following four parameters.
• <tx_service_index>: tx service’s index. It can be fetched with command
AT+BLEGATTCPRIMSRV=<conn_index> and AT+BLEGATTSSRV?.
Notes
• In Bluetooth LE client, the property of tx characteristic must be write with response or write
without response, and the property of rx characteristic must be indicate or notify.
• In Bluetooth LE server, the property of tx characteristic must be indicate or notify, and the property of rx
characteristic must be write with response or write without response.
Example
Execute Command
Function:
Enter Bluetooth LE SPP mode.
Command:
AT+BLESPP
Response:
>
Notes
• If the Bluetooth LE SPP parameters are illegal, this command will return ERROR.
• During the SPP transmission, AT will not prompt any connection status changes unless bit2 of AT+SYSMSG is
1.
Example
Query Command
Function:
Query the parameters of Bluetooth LE SMP.
Command:
AT+BLESECPARAM?
Response:
+BLESECPARAM:<auth_req>,<iocap>,<key_size>,<init_key>,<rsp_key>,<auth_option>
OK
Set Command
Function:
Set the parameters of Bluetooth LE SMP.
Command:
AT+BLESECPARAM=<auth_req>,<iocap>,<key_size>,<init_key>,<rsp_key>[,<auth_option>]
Response:
OK
Parameters
Note
Example
AT+BLESECPARAM=1,4,16,3,3,0
Set Command
Function:
Start a pairing request
Command:
AT+BLEENC=<conn_index>,<sec_act>
Response:
OK
Parameters
Note
• Before running this command, please set the security parameters and connection with remote devices.
Example
AT+BLESECPARAM=1,4,16,3,3
AT+BLEENC=0,3
3.4.34 [ESP32 Only] AT+BLEENCRSP: Respond to the Pairing Request from the
Peer Device
Set Command
Function:
Respond to the pairing request from the peer device.
Command:
AT+BLEENCRSP=<conn_index>,<accept>
Response:
OK
Parameters
Note
• After running this command, AT will output the pairing result at the end of the pairing process.
+BLEAUTHCMPL:<conn_index>,<enc_result>
Example
AT+BLEENCRSP=0,1
3.4.35 [ESP32 Only] AT+BLEKEYREPLY: Reply the Key Value to the Peer Device in
the Legacy Connection Stage
Set Command
Function:
Reply a pairing key.
Command:
AT+BLEKEYREPLY=<conn_index>,<key>
Response:
OK
Parameters
Example
AT+BLEKEYREPLY=0,649784
3.4.36 [ESP32 Only] AT+BLECONFREPLY: Reply the Confirm Value to the Peer De-
vice in the Legacy Connection Stage
Set Command
Function:
Reply a pairing result.
Command:
AT+BLECONFREPLY=<conn_index>,<confirm>
Response:
OK
Parameters
Example
AT+BLECONFREPLY=0,1
Query Command
Function:
Query bonded Bluetooth LE encryption device list.
Command:
AT+BLEENCDEV?
Response:
+BLEENCDEV:<enc_dev_index>,<mac_address>
OK
Parameters
Example
AT+BLEENCDEV?
Set Command
Function:
Remove a device from the security database list with a specific index.
Command:
AT+BLEENCCLEAR=<enc_dev_index>
Response:
OK
Execute Command
Function:
Remove all devices from the security database.
Command:
AT+BLEENCCLEAR
Response:
OK
Parameter
Example
AT+BLEENCCLEAR
Query Command
Function:
Query the Bluetooth LE static pair key. If it is not set, AT will return -1.
Command:
AT+BLESETKEY?
Response:
+BLESETKEY:<static_key>
OK
Set Command
Function:
Set a Bluetooth LE static pair key for all Bluetooth LE connections.
Command:
AT+BLESETKEY=<static_key>
Response:
OK
Parameter
Example
AT+BLESETKEY=123456
Query Command
Function:
Query the initialization status of Bluetooth LE HID profile.
Command:
AT+BLEHIDINIT?
Response:
If Bluetooth LE HID device profile is not initialized, AT will return:
+BLEHIDINIT:0
OK
+BLEHIDINIT:1
OK
Set Command
Function:
Initialize the Bluetooth LE HID profile.
Command:
AT+BLEHIDINIT=<init>
Response:
OK
Parameter
• <init>:
– 0: deinit Bluetooth LE HID profile
– 1: init Bluetooth LE HID profile
Note
• The Bluetooth LE HID command cannot be used at the same time with general GATT/GAP commands.
Example
AT+BLEHIDINIT=1
Set Command
Function:
Send keyboard information.
Command:
AT+BLEHIDKB=<Modifier_keys>,<key_1>,<key_2>,<key_3>,<key_4>,<key_5>,<key_6>
Response:
OK
Parameters
Note
• For more information about key codes, please refer to the chapter Keyboard/Keypad Page of Universal Serial
Bus HID Usage Tables.
Example
Set Command
Function:
Send mouse information.
Command:
AT+BLEHIDMUS=<buttons>,<X_displacement>,<Y_displacement>,<wheel>
Response:
OK
Parameters
Example
AT+BLEHIDMUS=0,10,10,0
Set Command
Function:
Send consumer information.
Command:
AT+BLEHIDCONSUMER=<consumer_usage_id>
Response:
OK
Parameter
• <consumer_usage_id>: consumer ID, such as power, reset, help, volume and so on. See chapter Consumer
Page (0x0C) of HID Usage Tables for Universal Serial Bus (USB) for more information.
Example
AT+BLEHIDCONSUMER=233 // volume up
Query Command
Function:
Query the status of BluFi.
Command:
AT+BLUFI?
Response:
If BluFi is not started, it will return:
+BLUFI:0
OK
+BLUFI:1
OK
Set Command
Function:
Start or stop BluFi.
Command:
AT+BLUFI=<option>[,<auth floor>]
Response:
OK
Parameter
• <option>:
– 0: stop BluFi
– 1: start BluFi
• <auth floor>: Wi-Fi authentication mode floor. ESP-AT will not connect to the AP whose authmode is lower
than this floor.
– 0: OPEN (Default)
– 1: WEP
– 2: WPA_PSK
– 3: WPA2_PSK
– 4: WPA_WPA2_PSK
– 5: WPA2_ENTERPRISE
– 6: WPA3_PSK
– 7: WPA2_WPA3_PSK
Example
AT+BLUFI=1
Query Command
Function:
Query the BluFi name.
Command:
AT+BLUFINAME?
Response:
+BLUFINAME:<device_name>
OK
Set Command
Function:
Set the BluFi device name.
Command:
AT+BLUFINAME=<device_name>
Response:
OK
Parameter
Notes
• If you need to set BluFi name, please set it before command AT+BLUFI=1. Otherwise, it will use the default
name BLUFI_DEVICE.
• The maximum length of BluFi name is 29 bytes.
Example
AT+BLUFINAME="BLUFI_DEV"
AT+BLUFINAME?
Query Command
Function:
Query the initialization status of Classic Bluetooth.
Command:
AT+BTINIT?
Response:
If Classic Bluetooth is initialized, AT will return:
+BTINIT:1
OK
+BTINIT:0
OK
Set Command
Function:
Initialize or deinitialize Classic Bluetooth.
Command:
AT+BTINIT=<init>
Response:
OK
Parameter
• <init>:
– 0: deinitialize Classic Bluetooth.
– 1: initialize Classic Bluetooth.
Example
AT+BTINIT=1
Query Command
Function:
Query the Classic Bluetooth device name.
Command:
AT+BTNAME?
Response:
+BTNAME:<device_name>
OK
Set Command
Function:
Set the Classic Bluetooth device name.
Command:
AT+BTNAME=<device_name>
Response:
OK
Parameter
• <device_name>: the Classic Bluetooth device name. The maximum length is 32.
Notes
Example
AT+BTNAME="esp_demo"
Set Command
Function:
Set the scan mode of Classic Bluetooth.
Command:
AT+BTSCANMODE=<scan_mode>
Response:
OK
Parameter
• <scan_mode>:
– 0: Neither discoverable nor connectable.
– 1: Connectable but not discoverable.
– 2: Both discoverable and connectable.
– 3: Discoverable but not connectable.
Example
Set Command
Function:
Start Classic Bluetooth discovery.
Command:
AT+BTSTARTDISC=<inq_mode>,<inq_len>,<inq_num_rsps>
Response:
+BTSTARTDISC:<bt_addr>,<dev_name>,<major_dev_class>,<minor_dev_class>,<major_srv_
˓→class>,<rssi>
OK
Parameters
• <inq_mode>:
– 0: general inquiry mode.
– 1: limited inquiry mode.
• <inq_len>: inquiry duration. Range: 0x01 ~ 0x30.
• <inq_num_rsps>: number of inquiry responses that can be received. If you set it to 0, AT will receive an
unlimited number of responses.
Example
AT+BTINIT=1
AT+BTSCANMODE=2
AT+BTSTARTDISC=0,10,10
Query Command
Function:
Query the initialization status of Classic Bluetooth SPP profile.
Command:
AT+BTSPPINIT?
Response:
If Classic Bluetooth SPP profile is initialized, it will return:
+BTSPPINIT:1
OK
+BTSPPINIT:0
OK
Set Command
Function:
Initialize or deinitialize Classic Bluetooth SPP profile.
Command:
AT+BTSPPINIT=<init>
Response:
OK
Parameter
• <init>:
– 0: deinitialize Classic Bluetooth SPP profile.
– 1: initialize Classic Bluetooth SPP profile, the role is master.
– 2: initialize Classic Bluetooth SPP profile, the role is slave.
Example
AT+BTSPPINIT=1 // master
AT+BTSPPINIT=2 // slave
Query Command
Function:
Query Classic Bluetooth SPP connection.
Command:
AT+BTSPPCONN?
Response:
+BTSPPCONN:<conn_index>,<remote_address>
OK
+BTSPPCONN:-1
Set Command
Function:
Establish the Classic Bluetooth SPP connection.
Command:
AT+BTSPPCONN=<conn_index>,<sec_mode>,<remote_address>
Response:
OK
+BTSPPCONN:<conn_index>,<remote_address>
+BTSPPCONN:<conn_index>,-1
Parameters
• <conn_index>: index of Classic Bluetooth SPP connection. Only 0 is supported for the single connection right
now.
• <sec_mode>:
– 0x0000: no security.
– 0x0001: authorization required (only needed for out going connection).
– 0x0036: encryption required.
– 0x3000: Man-In-The-Middle protection.
Example
AT+BTSPPCONN=0,0,"24:0a:c4:09:34:23"
Execute Command
Function:
End the Classic Bluetooth SPP connection.
Command:
AT+BTSPPDISCONN=<conn_index>
Response:
OK
+BTSPPDISCONN:<conn_index>,<remote_address>
+BTSPPDISCONN:-1
Parameters
• <conn_index>: index of Classic Bluetooth SPP connection. Only 0 is supported for the single connection right
now.
• <remote_address>: remote Classic Bluetooth A2DP device address.
Example
AT+BTSPPDISCONN=0
3.5.8 [ESP32 Only] AT+BTSPPSEND: Send Data to Remote Classic Bluetooth SPP
Device
Execute Command
Function:
Enter Classic Bluetooth SPP mode.
Command:
AT+BTSPPSEND
Response:
>
Set Command
Function:
Send data to the remote Classic Bluetooth SPP device.
Command:
AT+BTSPPSEND=<conn_index>,<data_len>
Response:
OK
Parameters
• <conn_index>: index of Classic Bluetooth SPP connection. Only 0 is supported for the single connection right
now.
• <data_len>: the length of the data which is ready to be sent.
Notes
• The wrap return is > after this command is executed. Then, the ESP device enters UART Bluetooth passthrough
mode. When the packet which only contains +++ is received, the device returns to normal command mode.
Please wait for at least one second before sending the next AT command.
Example
AT+BTSPPSEND=0,100
AT+BTSPPSEND
Execute Command
Function:
Start Classic Bluetooth SPP profile.
Command:
AT+BTSPPSTART
Response:
OK
Note
• During the SPP transmission, AT will not prompt any connection status changes unless bit2 of AT+SYSMSG is
1.
Example
AT+BTSPPSTART
Query Command
Function:
Query the initialization status of Classic Bluetooth A2DP profile.
Command:
AT+BTA2DPINIT?
Response:
If Classic Bluetooth A2DP profile is initialized, AT will return:
+BTA2DPINIT:1
OK
+BTA2DPINIT:0
OK
Set Command
Function:
Initialize or deinitialize Classic Bluetooth A2DP profile.
Command:
AT+BTA2DPINIT=<role>,<init_val>
Response:
OK
Parameters
• <role>:
– 0: source.
– 1: sink.
• <init_val>:
– 0: deinitialize Classic Bluetooth A2DP profile.
– 1: initialize Classic Bluetooth A2DP profile.
Example
AT+BTA2DPINIT=0,1
Query Command
Function:
Query Classic Bluetooth A2DP connection.
Command:
AT+BTA2DPCONN?
Response:
+BTA2DPCONN:<conn_index>,<remote_address>
OK
If the connection has not been established, AT will NOT return the parameter <conn_index> and <remote_address>.
Set Command
Function:
Establish the Classic Bluetooth A2DP connection.
Command:
AT+BTA2DPCONN=<conn_index>,<remote_address>
Response:
OK
+BTA2DPCONN:<conn_index>,<remote_address>
+BTA2DPCONN:<conn_index>,-1
Parameters
• <conn_index>: index of Classic Bluetooth A2DP connection. Only 0 is supported for the single connection
right now.
• <remote_address>: remote Classic Bluetooth A2DP device address.
Example
AT+BTA2DPCONN=0,0,0,"24:0a:c4:09:34:23"
Execute Command
Function:
End the Classic Bluetooth A2DP connection.
Command:
AT+BTA2DPDISCONN=<conn_index>
Response:
+BTA2DPDISCONN:<conn_index>,<remote_address>
OK
Parameters
• <conn_index>: index of Classic Bluetooth A2DP connection. Only 0 is supported for the single connection
right now.
• <remote_address>: remote Classic Bluetooth A2DP device address.
Example
AT+BTA2DPDISCONN=0
Query Command
Function:
Query the audio file URL.
Command:
AT+BTA2DPSRC?
Response:
+BTA2DPSRC:<url>,<type>
OK
Execute Command
Function:
Set the audio file URL.
Command:
AT+BTA2DPSRC=<conn_index>,<url>
Response:
OK
Parameters
• <conn_index>: index of Classic Bluetooth A2DP connection. Only 0 is supported for the single connection
right now.
• <url>: the path of the source file. HTTP, HTTPS and FLASH are currently supported.
• <type>: the type of audio file, such as “mp3”.
Note
Example
AT+BTA2DPSRC=0,"https://dl.espressif.com/dl/audio/ff-16b-2c-44100hz.mp3"
AT+BTA2DPSRC=0,"flash://spiffs/zhifubao.mp3"
Execute Command
Function:
Control the audio play.
Command:
AT+BTA2DPCTRL=<conn_index>,<ctrl>
Response:
OK
Parameters
• <conn_index>: index of Classic Bluetooth A2DP connection. Only 0 is supported for the single connection
right now.
• <ctrl>: types of control.
– 0: A2DP Sink, stop play.
– 1: A2DP Sink, start play.
– 2: A2DP Sink, forward.
– 3: A2DP Sink, backward.
– 4: A2DP Sink, fastward start.
– 5: A2DP Sink, fastward stop.
– 0: A2DP Source, stop play.
– 1: A2DP Source, start play.
– 2: A2DP Source, suspend.
Example
Query Command
Function:
Query Classic Bluetooth security parameters.
Command:
AT+BTSECPARAM?
Response:
+BTSECPARAM:<io_cap>,<pin_type>,<pin_code>
OK
Set Command
Function:
Set the Classic Bluetooth security parameters.
Command:
AT+BTSECPARAM=<io_cap>,<pin_type>,<pin_code>
Response:
OK
Parameters
Note
Example
AT+BTSECPARAM=3,1,"9527"
Execute Command
Function:
Input the Simple Pair Key.
Command:
AT+BTKEYREPLY=<conn_index>,<Key>
Response:
OK
Parameters
• <conn_index>: index of Classic Bluetooth connection. Currently, only 0 is supported for the single connection.
• <Key>: the Simple Pair Key.
Example
AT+BTKEYREPLY=0,123456
3.5.17 [ESP32 Only] AT+BTPINREPLY: Input the Legacy Pair PIN Code
Execute Command
Function:
Input the Legacy Pair PIN Code.
Command:
AT+BTPINREPLY=<conn_index>,<Pin>
Response:
OK
Parameters
• <conn_index>: index of Classic Bluetooth connection. Currently, only 0 is supported for the single connection.
• <Pin>: the Legacy Pair PIN Code.
Example
AT+BTPINREPLY=0,"6688"
3.5.18 [ESP32 Only] AT+BTSECCFM: Reply the Confirm Value to the Peer Device in
the Legacy Connection Stage
Execute Command
Function:
Reply the confirm value to the peer device in the legacy connection stage.
Command:
AT+BTSECCFM=<conn_index>,<accept>
Response:
OK
Parameters
• <conn_index>: index of Classic Bluetooth connection. Currently, only 0 is supported for the single connection.
• <accept>: reject or accept.
– 0: reject.
– 1: accept.
Example
AT+BTSECCFM=0,1
Query Command
Function:
Query the bound devices.
Command:
AT+BTENCDEV?
Response:
+BTENCDEV:<enc_dev_index>,<mac_address>
OK
Parameters
Example
AT+BTENCDEV?
Set Command
Function:
Remove a device from the security database list with a specific index.
Command:
AT+BTENCCLEAR=<enc_dev_index>
Response:
OK
Execute Command
Function:
Remove all devices from the security database.
Command:
AT+BLEENCCLEAR
Response:
OK
Parameter
Example
AT+BTENCCLEAR
Set Command
Function:
Set the Classic Bluetooth class of devices.
Command:
AT+BTCOD=<major>,<minor>,<service>
Response:
OK
Parameters
Example
Query Command
Function:
Query Classic Bluetooth tx power level.
Command:
AT+BTPOWER?
Response:
+BTPOWER:<min_tx_power>,<max_tx_power>
OK
Set Command
Function:
Set the Classic Bluetooth tx power.
Command:
AT+BTPOWER=<min_tx_power>,<max_tx_power>
Response:
OK
Parameters
Example
Set Command
Function:
Set MQTT User Configuration.
Command:
AT+MQTTUSERCFG=<LinkID>,<scheme>,<"client_id">,<"username">,<"password">,<cert_key_ID>
˓→,<CA_ID>,<"path">
Response:
OK
Parameters
– 10: MQTT over WebSocket Secure (based on TLS, verify server certificate and provide client certificate).
• <client_id>: MQTT client ID. Maximum length: 256 bytes.
• <username>: the username to login to the MQTT broker. Maximum length: 64 bytes.
• <password>: the password to login to the MQTT broker. Maximum length: 64 bytes.
• <cert_key_ID>: certificate ID. Currently, ESP-AT only supports one certificate for ID 0.
• <CA_ID>: CA ID. Currently, ESP-AT only supports one CA for ID 0.
• <path>: the path of the resource. Maximum length: 32 bytes.
Note
• The length of the entire AT command should be less than 256 bytes.
Set Command
Function:
Set MQTT Client ID.
Command:
AT+MQTTCLIENTID=<LinkID>,<"client_id">
Response:
OK
Parameters
Notes
• The length of the entire AT command should be less than 256 bytes.
• The command AT+MQTTUSERCFG can also set MQTT client ID. The differences between the two commands
include:
– You can use AT+MQTTCLIENTID to set a relatively long client ID since there is a limitation on the length
of the AT+MQTTUSERCFG command.
– You should set AT+MQTTCLIENTID after setting the AT+MQTTUSERCFG command.
Set Command
Function:
Set MQTT username.
Command:
AT+MQTTUSERNAME=<LinkID>,<"username">
Response:
OK
Parameters
Notes
• The length of the entire AT command should be less than 256 bytes.
• The command AT+MQTTUSERCFG can also set MQTT username. The differences between the two commands
include:
– You can use AT+MQTTUSERNAME to set a relatively long username since there is a limitation on the length
of the AT+MQTTUSERCFG command.
– You should set AT+MQTTUSERNAME after setting the command AT+MQTTUSERCFG.
Set Command
Function:
Set MQTT password.
Command:
AT+MQTTPASSWORD=<LinkID>,<"password">
Response:
OK
Parameters
Notes
• The length of the entire AT command should be less than 256 bytes.
• The command AT+MQTTUSERCFG can also set MQTT password. The differences between the two commands
include:
– You can use AT+MQTTPASSWORD to set a relatively long password since there is a limitation on the length
of the AT+MQTTUSERCFG command.
– You should set AT+MQTTPASSWORD after setting the command AT+MQTTUSERCFG.
Set Command
Function:
Set configuration of MQTT Connection.
Command:
AT+MQTTCONNCFG=<LinkID>,<keepalive>,<disable_clean_session>,<"lwt_topic">,<"lwt_msg">,
˓→<lwt_qos>,<lwt_retain>
Response:
OK
Parameters
Query Command
Function:
Query the MQTT broker that ESP devices are connected to.
Command:
AT+MQTTCONN?
Response:
+MQTTCONN:<LinkID>,<state>,<scheme><"host">,<port>,<"path">,<reconnect>
OK
Set Command
Function:
Connect to an MQTT broker.
Command:
AT+MQTTCONN=<LinkID>,<"host">,<port>,<reconnect>
Response:
OK
Parameters
Set Command
Function:
Publish MQTT messages in string to a defined topic. If you need to publish messages in binary, please use the
AT+MQTTPUBRAW command.
Command:
AT+MQTTPUB=<LinkID>,<"topic">,<"data">,<qos>,<retain>
Response:
OK
Parameters
Notes
• The length of the entire AT command should be less than 256 bytes.
• This command cannot send data \0. If you need to send \0, please use the command AT+MQTTPUBRAW
instead.
Set Command
Function:
Publish MQTT messages in binary to a defined topic.
Command:
AT+MQTTPUBRAW=<LinkID>,<"topic">,<length>,<qos>,<retain>
Response:
OK
>
The symbol > indicates that AT is ready for receiving serial data, and you can enter the data now. When the requirement
of message length determined by the parameter <length> is met, the transmission starts.
If the transmission is successful, AT returns:
+MQTTPUB:OK
Otherwise, it returns:
+MQTTPUB:FAIL
Parameters
Query Command
Function:
List all MQTT topics that have been already subscribed.
Command:
AT+MQTTSUB?
Response:
+MQTTSUB:<LinkID>,<state>,<"topic1">,<qos>
+MQTTSUB:<LinkID>,<state>,<"topic2">,<qos>
+MQTTSUB:<LinkID>,<state>,<"topic3">,<qos>
...
OK
Set Command
Function:
Subscribe to defined MQTT topics with defined QoS. It supports subscribing to multiple topics.
Command:
AT+MQTTSUB=<LinkID>,<"topic">,<qos>
Response:
OK
+MQTTSUBRECV:<LinkID>,<"topic">,<data_length>,data
ALREADY SUBSCRIBE
Parameters
Set Command
Function:
Unsubscribe the client from defined topics. This command can be called multiple times to unsubscribe from different
topics.
Command:
AT+MQTTUNSUB=<LinkID>,<"topic">
Response:
OK
NO UNSUBSCRIBE
OK
Parameters
Set Command
Function:
Close the MQTT connection and release the resource.
Command:
AT+MQTTCLEAN=<LinkID>
Response:
OK
Parameter
• In general, AT MQTT commands responds within 10 s, except the command AT+MQTTCONN. For example, if
the router fails to access the Internet, the command AT+MQTTPUB will respond within 10 s. But the command
AT+MQTTCONN may need more time due to packet retransmission in a bad network environment.
• If the AT+MQTTCONN is based on a TLS connection, the timeout of each packet is 10 s, and the total timeout
will be much longer depending on the handshake packets count.
• When the MQTT connection ends, it will prompt the message +MQTTDISCONNECTED:<LinkID>.
• When the MQTT connection established, it will prompt the message +MQTTCONNECTED:<LinkID>,
<scheme>,<"host">,port,<"path">,<reconnect>.
Set Command
Command:
AT+HTTPCLIENT=<opt>,<content-type>,<"url">,[<"host">],[<"path">],<transport_type>[,<
˓→"data">][,<"http_req_header">][,<"http_req_header">][...]
Response:
+HTTPCLIENT:<size>,<data>
OK
Parameters
Notes
• If the url parameter is not null, HTTP client will use it and ignore the host parameter and path parameter;
If the url parameter is omited or null string, HTTP client will use host parameter and path parameter.
• In some released firmware, HTTP client commands are not supported (see How to understand the differences of
each type of module), but you can enable it by ./build.py menuconfig > Component config > AT
> AT http command support and build the project (see Build Your Own ESP-AT Project).
Example
// HEAD Request
AT+HTTPCLIENT=1,0,"http://httpbin.org/get","httpbin.org","/get",1
// GET Request
AT+HTTPCLIENT=2,0,"http://httpbin.org/get","httpbin.org","/get",1
// POST Request
AT+HTTPCLIENT=3,0,"http://httpbin.org/post","httpbin.org","/post",1,"field1=value1&
˓→field2=value2"
Set Command
Command:
AT+HTTPGETSIZE=<url>
Response:
+HTTPGETSIZE:<size>
OK
Parameters
Note
• In some released firmware, HTTP client commands are not supported (see How to understand the differences of
each type of module), but you can enable it by ./build.py menuconfig > Component config > AT
> AT http command support and build the project (see Build Your Own ESP-AT Project).
Example
AT+HTTPGETSIZE="http://www.baidu.com/img/bdlogo.gif"
Set Command
Command:
AT+HTTPCPOST=<url>,<length>[,<http_req_header_cnt>][,<http_req_header>..<http_req_
˓→header>]
Response:
OK
>
The symbol > indicates that AT is ready for receiving serial data, and you can enter the data now. When the requirement
of message length determined by the parameter <length> is met, the transmission starts.
If the transmission is successful, AT returns:
SEND OK
Otherwise, it returns:
SEND FAIL
Parameters
• HTTP Client:
• HTTP Server:
• HTTP AT:
– The error code of command AT+HTTPCLIENT will be 0x7000+Standard HTTP Error Code
(For more details about Standard HTTP/1.1 Error Code, see RFC 2616).
– For example, if AT gets the HTTP error 404 when calling command AT+HTTPCLIENT, it will respond
with error code of 0x7194 (hex(0x7000+404)=0x7194).
3.8.1 Prerequisite
Before you run any Ethernet AT Commands, please make the following preparations:
Note: This prerequisite takes ESP32-Ethernet-Kit as an example. If you use other modules or development boards,
please refer to corresponding datasheets for RX/TX pins.
• Change AT UART pins (because default AT UART pins are in conflict with the Ethernet function pins):
– Open factory_param_data.csv file.
– In the row of module WROVER-32, change uart_tx_pin from GPIO22 to GPIO2, uart_rx_pin
from GPIO19 to GPIO4, uart_cts_pin from GPIO15 to GPIO1, and uart_rts_pin from GPIO14
to GPIO1 (flow control is optional and is not used here). See How to Set AT Port Pins for more information.
• Enable AT ethernet support. See How to enable ESP-AT Ethernet for more information.
• Compile and flash the project onto ESP32-Ethernet-Kit.
• Connect your hardware:
– Connect Host MCU (PC with USB to serial converter) to GPIO2 (TX) and GPIO4 (RX) of ESP32-
Ethernet-Kit when the flow control function is not enabled.
– Connect ESP32-Ethernet-Kit with Ethernet network.
3.8.2 [ESP32 Only] AT+CIPETHMAC: Query/Set the MAC Address of the ESP Ether-
net
Query Command
Function:
Query the MAC address of the ESP Ethernet.
Command:
AT+CIPETHMAC?
Response:
+CIPETHMAC:<"mac">
OK
Set Command
Function:
Set the MAC address of the ESP Ethernet.
Command:
AT+CIPETHMAC=<"mac">
Response:
OK
Parameter
• <”mac”>: string parameter showing the MAC address of the Ethernet interface.
Notes
• The default firmware does not support Ethernet AT commands (see How to understand the differences of each
type of module), but you can enable it by ./build.py menuconfig > Component config > AT > AT
ethernet support and compile the project (see Build Your Own ESP-AT Project).
• The configuration changes will be saved in the NVS area if AT+SYSSTORE=1.
• Please make sure the MAC address of Ethernet interface you set is different from those of other interfaces.
• Bit0 of the ESP 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 addresses and cannot be set.
Example
AT+CIPETHMAC="1a:fe:35:98:d4:7b"
3.8.3 [ESP32 Only] AT+CIPETH: Query/Set the IP Address of the the ESP Ethernet
Query Command
Function:
Query the IP address of the ESP Ethernet.
Command:
AT+CIPETH?
Response:
+CIPETH:ip:<ip>
+CIPETH:gateway:<gateway>
+CIPETH:netmask:<netmask>
OK
Set Command
Function:
Set the IP address of the ESP Ethernet.
Command:
AT+CIPETH=<ip>[,<gateway>,<netmask>]
Response:
OK
Parameters
Notes
• The default firmware does not support Ethernet AT commands (see How to understand the differences of each
type of module), but you can enable it by ./build.py menuconfig > Component config > AT > AT
ethernet support and compile the project (see Build Your Own ESP-AT Project).
• The configuration changes will be saved in the NVS area if AT+SYSSTORE=1.
• This Set Command correlates with DHCP commands, such as AT+CWDHCP:
– If static IP is enabled, DHCP will be disabled.
– If DHCP is enabled, static IP will be disabled.
– The last configuration overwrites the previous configuration.
Example
AT+CIPETH="192.168.6.100","192.168.6.1","255.255.255.0"
Set Command
Command:
AT+FACTPLCP=<enable>,<tx_with_long>
Response:
OK
Parameters
Set Command
Command:
AT+WEBSERVER=<enable>,<server_port>,<connection_timeout>
Response:
OK
Parameters
Notes
• There are two ways to provide the HTML files needed by the web server. One is to use fatfs file system (non
ESP8266 chips), and you need to enable AT FS command at this time. The other one is to use embedded files
to storge HTML files (default setting).
• Please make sure that the max number of open sockets is not less than 12, you may change the number by .
/build.py menuconfig > Component config > LWIP > Max bumber of open sockets and
compile the project (see Build Your Own ESP-AT Project).
• The default firmware does not support web server AT commands (see How to understand the differences of each
type of module), but you can enable it by ./build.py menuconfig > Component config > AT > AT
WEB Server command support and compile the project (see Build Your Own ESP-AT Project).
• For ESP8266 devices, you may need to turn off some unnecessary options to store the necessary html files.
• For more examples, please refer to Web Server AT Example.
Example
// Enable the web server with port 80, and the timeout for the every connection is 50
˓→seconds:
AT+WEBSERVER=1,80,50
Set Command
Command:
AT+DRVADC=<channel>,<atten>
Response:
+DRVADC:<raw data>
OK
Parameters
Notes
Example
Set Command
Command:
AT+DRVPWMINIT=<freq>,<duty_res>,<ch0_gpio>[,...,<ch3_gpio>]
Response:
OK
Parameters
Notes
Example
Set Command
Command:
AT+DRVPWMDUTY=<ch0_duty>[,...,<ch3_duty>]
Response:
OK
Parameter
Notes
Example
Set Command
Command:
AT+DRVPWMFADE=<ch0_target_duty>,<ch0_fade_time>[,...,<ch3_target_duty>,<ch3_fade_time>
˓→]
Response:
OK
Parameters
Notes
Example
Set Command
Command:
AT+DRVI2CINIT=<num>,<scl_io>,<sda_io>,<clock>
Response:
OK
Parameters
• <num>: I2C port number. Range: 0 ~ 1. If the following parameters are not set, AT will deinitialize the I2C
port.
• <scl_io>: GPIO number for I2C SCL signal.
• <sda_io>: GPIO number for I2C SDA signal.
• <clock>: I2C clock frequency for master mode. Unit: Hz. Maximum: 1 MHz.
Note
Example
Set Command
Command:
AT+DRVI2CRD=<num>,<address>,<length>
Response:
+DRVI2CRD:<read data>
OK
Parameters
Note
Example
Set Command
Command:
AT+DRVI2CWRDATA=<num>,<address>,<length>
Response:
OK
>
This response indicates that you should enter the data you want to write. When the requirement of data length is met,
the data transmission starts.
If the data is transmitted successfully, AT returns:
OK
ERROR
Parameters
Note
Example
Set Command
Command:
AT+DRVI2CWRBYTES=<num>,<address>,<length>,<data>
Response:
OK
Parameters
Note
Example
Set Command
Command:
AT+DRVSPICONFGPIO=<mosi>,<miso>,<sclk>,<cs>
Response:
OK
Parameters
Set Command
Command:
AT+DRVSPIINIT=<clock>,<mode>,<cmd_bit>,<addr_bit>,<dma_chan>[,bits_msb]
Response:
OK
Parameters
Note
Example
OK
AT+DRVSPIINIT=0 // delete SPI Driver
OK
Set Command
Command:
AT+DRVSPIRD=<data_len>[,<cmd>,<cmd_len>][,<addr>,<addr_len>]
Response:
+DRVSPIRD:<read data>
OK
Parameters
• <data_len>: length of SPI data you want to read. Range: 1 ~ 4092 bytes.
• <cmd>: command data. The length of the data is set in <cmd_len>.
• <cmd_len>: command length in this transaction. Range: 0 ~ 2 bytes.
• <addr>: command address. The length of the address is set in <addr_len>.
• <addr_len>: The address length in this transaction. Range: 0 ~ 4 bytes.
Note
• If you don’t use DMA, the maximum <data_len> you can set is 64 bytes each time.
Example
+DRVI2CREAD:ffff
OK
Set Command
Command:
AT+DRVSPIWR=<data_len>[,<cmd>,<cmd_len>][,<addr>,<addr_len>]
Response:
When <data_len> is larger than 0, AT returns:
OK
>
This response indicates that you should enter the data you want to write. When the requirement of data length is met,
the data transmission starts.
If the data is transmitted successfully, AT returns:
OK
When <data_len> is equal to 0, which means AT transmits commands and addresses only, and no SPI data, AT
returns:
OK
Parameters
Note
• If you don’t use DMA, the maximum <data_len> you can set is 64 bytes each time.
Example
OK
Note: The table below covers all the commands supported by the NONOS-AT, but not all by ESP-AT. See Section
AT Command Set for a full list of commands supported by ESP-AT.
The links in the first column of the table point to ESP-AT commands.
2
AT+RFPOWER Set RF TX Power
Range: [0,82]
Unit: 0.25
dBm
Tip: Click the footnote number to jump (back) to where it is marked in the table above.
It is strongly recommended to read the following sections for some common information on AT commands before you
dive into the details of each command.
• AT Command Types
• AT Commands with Configuration Saved in the Flash
• AT Messages
• Not all AT commands support all of the four types mentioned above.
• Currently, only strings and integer numbers are supported as input parameters in AT commands.
1 AT+SLEEP in ESP-AT:
• ESP8266 and ESP32
– 1: modem sleep by DTIM
– 2: light sleep
– 3: modem sleep by listen interval
• ESP32-S2
• Angle brackets < > designate parameters that can not be omitted.
• Square brackets [ ] designate optional parameters that can be omitted. The default value of the parameter will be
used instead when you omit it. Below are examples of entering the command AT+CWJAP with some parameters
omitted.
AT+CWJAP="ssid","password"
AT+CWJAP="ssid","password","11:22:33:44:55:66"
• If the parameter you want to omit is followed by a parameter(s), you must give a , to indicate it.
AT+CWJAP="ssid","password",,1
AT+CWSAP="ESP756290","21030826",1,4
• Escape character syntax is needed if a string contains special characters, such as ,, ", or \:
– \\: escape the backslash itself
– \,: escape comma which is not used to separate each parameter
– \": escape double quotation mark which is not used to mark string input
– \<any>: escape <any> character means that drop backslash symbol and only use <any> character
• Escape is needed in AT commands only, not elsewhere. For example, when AT command port prints > and wait
for your input, the input does not need to be escaped.
AT+CWJAP="comma\,backslash\\ssid","1234567890"
AT+MQTTPUB=0,"topic","\"{\"sensor\":012}\"",1,0
Configuration settings entered by the following AT Commands will always be saved in the flash NVS Area, so they
can be automatically restored on reset:
• AT+UART_DEF: AT+UART_DEF=115200,8,1,0,3
• AT+SAVETRANSLINK: AT+SAVETRANSLINK=1,"192.168.6.10",1001
• AT+CWAUTOCONN: AT+CWAUTOCONN=1
Saving of configuration settings by several other commands can be switched on or off with AT+SYSSTORE command,
which is mentioned in the Note section of these commands.
3.15 AT Messages
There are two types of ESP-AT messages returned from the ESP-AT command port:
• ESP-AT Response Messages (passive)
Each ESP-AT command input returns response messages to tell the sender the result of the ESP-AT command.
AT Command Examples
[]
Command:
AT+CWMODE=3 // SoftAP+Station mode
Response:
OK
Response:
OK
211
ESP-AT User Guide
AT+CIFSR
Response:
192.168.3.106 // device got an IP from router
4. Connect the PC to the same router which ESP is connected to. Use a network tool on the PC to create a TCP
server. For example, the TCP server on PC is 192.168.3.116, port 8080.
5. ESP is connected to the TCP server as a client:
6. Send data:
Response:
SEND OK
Note If the number of bytes inputted are more than the length (n) set by AT+CIPSEND, the system will reply
busy, and send the first n bytes. And after sending the first n bytes, the system will reply SEND OK.
7. Receive data:
When ESP works as a TCP server, multiple connections should be enabled; that is to say, there should be more than
one client connecting to ESP.Below is an example showing how a TCP server is established when ESP works in the
SoftAP mode. If ESP works as a Station, set up a server in the same way after connecting ESP to the router.
1. Set the Wi-Fi mode:
Command:
AT+CWMODE=3 // SoftAP+Station mode
Response:
OK
AT+CIPMUX=1
Response:
OK
Response:
OK
Response:
SEND OK
Note If the number of bytes inputted are more than the length (n) set by AT+CIPSEND, the system will reply
busy, and send the first n bytes. And after sending the first n bytes, the system will reply SEND OK.
7. Receive data:
AT+CIPCLOSE=0
Response:
0,CLOSED
OK
Command:
AT+CWMODE=3 // SoftAP+Station mode
(continues on next page)
Response:
OK
Response:
OK
AT+CIFSR
Response:
+CIFSR:STAIP,"192.168.101.104" // device got an IP from router
4. Connect the PC to the same router which ESP is connected to. Use a network tool on the PC to create UDP
transmission. For example, the PC’s IP address is 192.168.101.116, port 8080.
5. Below are two examples of UDP transmission.
In UDP transmission, whether the remote IP and port are fixed or not is determined by the last parameter of
AT+CIPSTART. 0 means that the remote IP and port are fixed and cannot be changed. 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:
OK
AT+CIPSTART=4,"UDP","192.168.101.110",8080,1112,0
Response:
4,CONNECT
OK
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 ESP. Users can define this port number. A random port will be used if
this parameter is not set.
• 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 ESP port 1112, ESP 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:
Response:
SEND OK
Note If the number of bytes inputted are more than the length (n) set by AT+CIPSEND, the system will reply
busy, and send the first n bytes. And after sending the first n bytes, the system will reply SEND OK.
4. Receive data:
AT+CIPCLOSE=4
Response:
4,CLOSED
OK
AT+CIPSTART="UDP","192.168.101.110",8080,1112,2
Response:
CONNECT
OK
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 above Example 2.
• 1112 is the local port of ESP. Users can define this port. A random port will be opened if this parameter
is not set.
• 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 ESP.
2. Send data:
Response:
SEND OK
Note If the number of bytes inputted are more than the length (n) set by AT+CIPSEND, the system will reply
busy, and send the first n bytes. And after sending the first n bytes, the system will reply SEND OK.
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.
Response:
SEND OK
4. Receive data:
AT+CIPCLOSE
Response:
CLOSED
OK
ESP-AT supports UART-Wi-Fi passthrough transmission only when ESP works as a TCP client in single connection
or UDP transmission.
Example 4.1. ESP as a TCP Client in UART-Wi-Fi Passthrough (Single Connection Mode)
Command:
AT+CWMODE=3 // SoftAP+Station mode
Response:
OK
Response:
OK
AT+CIFSR
Response:
+CIFSR:STAIP,"192.168.101.105" // device got an IP from router
4. Connect the PC to the same router which ESP is connected to. Use a network tool on the PC to create a TCP
server. For example, the PC’s IP address is 192.168.101.110, port 8080.
5. Connect the ESP device to the TCP server as a TCP client.
AT+CIPSTART="TCP","192.168.101.110",8080
AT+CIPMODE=1
Response:
OK
7. Send data.
AT+CIPSEND
Response:
> // From now on, data received from UART will be transparent
˓→transmitted to server
8. Stop sending data.When receiving a packet that contains only +++, the UART-WiFi passthrough transmission
process will be stopped. Then please wait at least 1 second before sending next AT command.Please be noted
that if you input +++ directly by typing, the +++, may not be recognised as three consecutive + because of
the Prolonged time when typing.Notice:The aim of ending the packet with +++ is to exit transparent transmis-
sion 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.
9. Exit the UART-WiFi passthrough mode.
AT+CIPMODE=0
Response:
OK
AT+CIPCLOSE
Response:
CLOSED
OK
Command:
AT+CWMODE=3 // SoftAP+Station mode
Response:
OK
Response:
CONNECT
OK
Response:
OK
6. Send data.
AT+CIPSEND
Response:
> // From now on, data received from UART will be transparent
˓→transmitted to server
7. Stop sending data.When receiving a packet that contains only +++, the UART-WiFi passthrough transmission
process will be stopped. Then please wait at least 1 second before sending next AT command.Please be noted
that if you input +++ directly by typing, the +++, may not be recognised as three consecutive + because of
the Prolonged time when typing.Notice:The aim of ending the packet with +++ is to exit transparent transmis-
sion 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.
8. Exit the UART-WiFi passthrough mode.
AT+CIPMODE=0
AT+CIPCLOSE
Response:
CLOSED
OK
Below is an example of using two ESP32 modules, one as a BLE server (hereafter named “ESP32 Server”), the other
one as a BLE client (hereafter named “ESP32 Client”). The example shows how to use BLE functions with AT
commands.Notice:
• The ESP32 Server needs to download a “service bin” into Flash to provide BLE services.
– To learn how to generate a “service bin”, please refer to esp-at/tools/readme.md.
– The download address of the “service bin” is the address of “ble_data” in esp-at/partitions_at.csv.
1. BLE initialization:
ESP32 Server:
Command:
AT+BLEINIT=2 // server role
Response:
OK
ESP32 Client:
Command:
AT+BLEINIT=1 // client role
Response:
OK
Command:
AT+BLEADDR? // get server's BLE address
Response:
+BLEADDR:24:0a:c4:03:f4:d6
OK
Command:
AT+BLEADVSTART
Response:
OK
Command:
AT+BLESCAN=1,3
Response:
+BLESCAN:<BLE address>,<rssi>,<adv_data>,<scan_rsp_data>
OK
(2) Establish the BLE connection, when the server is scanned successfully.
AT+BLECONN=0,"24:0a:c4:03:f4:d6"
Response:
OK
+BLECONN:0,"24:0a:c4:03:f4:d6"
Notes:
• If the BLE connection is established successfully, it will prompt +BLECONN:<conn_index>,
<remote_BLE_address>
• If the BLE connection is broken, it will prompt +BLEDISCONN:<conn_index>,
<remote_BLE_address>
3. Read/Write a characteristic:
ESP32 Server:(1) Create services.
AT+BLEGATTSSRVCRE
Response:
OK
AT+BLEGATTSSRVSTART
Response:
OK
AT+BLEGATTSCHAR?
Response:
+BLEGATTSCHAR:"char",1,1,0xC300
+BLEGATTSCHAR:"desc",1,1,1
+BLEGATTSCHAR:"char",1,2,0xC301
+BLEGATTSCHAR:"desc",1,2,1
+BLEGATTSCHAR:"char",1,3,0xC302
+BLEGATTSCHAR:"desc",1,3,1
OK
AT+BLEGATTCPRIMSRV=0
Response:
+BLEGATTCPRIMSRV:0,1,0x1801,1
+BLEGATTCPRIMSRV:0,2,0x1800,1
+BLEGATTCPRIMSRV:0,3,0xA002,1
OK
Notice:
• When discovering services, the ESP32 Client will get two more default services (UUID:0x1800 and
0x1801) than what the ESP32 Server will get.
• So, for the same service, the <srv_index> received by the ESP32 Client equals the <srv_index> received
by ESP32 Server + 2.
• For example, the <srv_index> of the above-mentioned service, 0xA002, is 3 when the ESP32 Client
is in the process of discovering services. But if the ESP32 Server tries to discover it with command
AT+BLEGATTSSRV?, the <srv_index> will be 1.
(2) Discover characteristics.
AT+BLEGATTCCHAR=0,3
Response:
+BLEGATTCCHAR:"char",0,3,1,0xC300,2
+BLEGATTCCHAR:"desc",0,3,1,1,0x2901
+BLEGATTCCHAR:"char",0,3,2,0xC301,2
+BLEGATTCCHAR:"desc",0,3,2,1,0x2901
+BLEGATTCCHAR:"char",0,3,3,0xC302,8
+BLEGATTCCHAR:"desc",0,3,3,1,0x2901
+BLEGATTCCHAR:"char",0,3,4,0xC303,4
+BLEGATTCCHAR:"desc",0,3,4,1,0x2901
+BLEGATTCCHAR:"char",0,3,5,0xC304,8
+BLEGATTCCHAR:"char",0,3,6,0xC305,16
+BLEGATTCCHAR:"desc",0,3,6,1,0x2902
+BLEGATTCCHAR:"char",0,3,7,0xC306,32
+BLEGATTCCHAR:"desc",0,3,7,1,0x2902
OK
(3) Read a characteristic. Please note that the target characteristic’s property has to support the read operation.
AT+BLEGATTCRD=0,3,1
Response:
(continues on next page)
Note:
• If the ESP32 Client reads the characteristic successfully, message +READ:<conn_index>,<remote
BLE address> will be prompted on the ESP32 Server side.
(4) Write a characteristic. Please note that the target characteristic’s property has to support the write operation.
AT+BLEGATTCWR=0,3,3,,2
Response:
> // waiting for data
OK
Note:
• If the ESP32 Client writes the characteristic successfully, message +WRITE:<conn_index>,
<srv_index>,<char_index>,[<desc_index>],<len>,<value> will be prompted on the
ESP32 Server side.
4. Notify of a characteristic:
ESP32 Client:(1) Configure the characteristic’s descriptor. Please note that the target characteristic’s property
has to support notifications.
AT+BLEGATTCWR=0,3,6,1,2
Response:
> // waiting for data
OK
Note:
• If the ESP32 Client writes the descriptor successfully, message +WRITE:<conn_index>,
<srv_index>,<char_index>,<desc_index>,<len>,<value> will be prompted on the
ESP32 Server side.
ESP32 Server:(1) Notify of a characteristic. Please note that the target characteristic’s property has to support
notifications.
AT+BLEGATTSNTFY=0,1,6,3
Response:
> // waiting for data
OK
Note:
• If the ESP32 Client receives the notification, it will prompt message +NOTIFY:<conn_index>,
<srv_index>,<char_index>,<len>,<value>.
• For the same service, the <srv_index> on the ESP32 Client side equals the <srv_index> on the ESP32
Server side + 2.
5. Indicate a characteristic:
ESP32 Client:(1) Configure the characteristic’s descriptor. Please note that the target characteristic’s property
has to support the indicate operation.
AT+BLEGATTCWR=0,3,7,1,2
Response:
> // waiting for data
OK
Note:
• If the ESP32 Client writes the descriptor successfully, message +WRITE:<conn_index>,
<srv_index>,<char_index>,<desc_index>,<len>,<value> will be prompted on the
ESP32 Server side.
ESP32 Server:(1) Indicate characteristic. Please note that the target characteristic’s property has to support the
indicate operation.
AT+BLEGATTSIND=0,1,7,3
Response:
> // waiting for data
OK
Note:
• If the ESP32 Client receives the indication, it will prompt message +INDICATE:<conn_index>,
<srv_index>,<char_index>,<len>,<value>
• For the same service, the <srv_index> on the ESP32 Client side equals the <srv_index> on the ESP32
Server side + 2.
Response
OK
2. Start advertising. Configure the parameters of the iBeacon advertisement as the following table shows:
The AT command should be as below:
```
AT+BLEADVDATA="0201061aff4c000215fda50693a4e24fb1afcfc6eb0764782527b7f206c5"
OK
OK
```
Open WeChat on your mobile phone and then select “Shake Nearby” to discover the ESP32 device that is advertising.
avatar
Not only can the ESP32 device transmits iBeacons, but it can also work as a BLE client that scans for iBeacons and
gets the advertisement data which can then be parsed by the host MCU.Notice:If the ESP32 device has already been
initialized as a BLE server, you need to call AT+BLEINIT=0 to de-init it first, and then re-init it as a BLE client.
Response
OK
AT+BLESCAN=1,3
Response
OK
```
+BLESCAN:24:0a:c4:02:10:0e,-33,
˓→0201061aff4c000215fda50693a4e24fb1afcfc6eb0764782527b7f206c5,
+BLESCAN:24:0a:c4:01:4d:fe,-74,02010207097a4f68664b43020aeb051220004000,
+BLESCAN:24:0a:c4:02:10:0e,-33,
˓→0201061aff4c000215fda50693a4e24fb1afcfc6eb0764782527b7f206c5,
```
Below is an example of using two ESP32 modules, one as a BLE server (hereafter named “ESP32 Server”), the other
one as a BLE client (hereafter named “ESP32 Client”). The example shows how to build BLE SPP (Serial Port Profile,
UART-BLE passthrough mode) with AT commands. Notice:
• The ESP32 Server needs to download a “service bin” into Flash to provide BLE services.
– To learn how to generate a “service bin”, please refer to esp-at/tools/readme.md.
– The download address of the “service bin” is the address of “ble_data” in esp-at/partitions_at.csv.
1. BLE initialization:
ESP32 Server:
OK
OK
OK
ESP32 Client:
OK
Response:
+BLEADDR:24:0a:c4:03:f4:d6
OK
(2) Optional Configuration, configure advertisement data. Without the configuration, the payload of the broad-
casting packet will be empty.
Command:
AT+BLEADVDATA="0201060A09457370726573736966030302A0"
Response:
OK
Response:
OK
Response:
+BLESCAN:<BLE address>,<rssi>,<adv_data>,<scan_rsp_data>
OK
(2) Establish the BLE connection, when the server is scanned successfully.
AT+BLECONN=0,"24:0a:c4:03:f4:d6"
Response:
OK
+BLECONN:0,"24:0a:c4:03:f4:d6"
Notes:
• If the BLE connection is established successfully, it will prompt +BLECONN:<conn_index>,
<remote_BLE_address>
• If the BLE connection is broken, it will prompt +BLEDISCONN:<conn_index>,
<remote_BLE_address>
3. Discover services.
ESP32 Server:(1) Discover local services.
AT+BLEGATTSSRV?
Response:
+BLEGATTSSRV:1,1,0xA002,1
OK
AT+BLEGATTSCHAR?
Response:
+BLEGATTSCHAR:"char",1,1,0xC300
+BLEGATTSCHAR:"desc",1,1,1
+BLEGATTSCHAR:"char",1,2,0xC301
+BLEGATTSCHAR:"desc",1,2,1
+BLEGATTSCHAR:"char",1,3,0xC302
+BLEGATTSCHAR:"desc",1,3,1
OK
AT+BLEGATTCPRIMSRV=0
Response:
+BLEGATTCPRIMSRV:0,1,0x1801,1
+BLEGATTCPRIMSRV:0,2,0x1800,1
+BLEGATTCPRIMSRV:0,3,0xA002,1
OK
Notice:
• When discovering services, the ESP32 Client will get two more default services (UUID:0x1800 and
0x1801) than what the ESP32 Server will get.
• So, for the same service, the <srv_index> received by the ESP32 Client equals the <srv_index> received
by ESP32 Server + 2.
• For example, the <srv_index> of the above-mentioned service, 0xA002, is 3 when the ESP32 Client
is in the process of discovering services. But if the ESP32 Server tries to discover it with command
AT+BLEGATTSSRV?, the <srv_index> will be 1.
(2) Discover characteristics.
AT+BLEGATTCCHAR=0,3
Response:
+BLEGATTCCHAR:"char",0,3,1,0xC300,2
+BLEGATTCCHAR:"desc",0,3,1,1,0x2901
+BLEGATTCCHAR:"char",0,3,2,0xC301,2
+BLEGATTCCHAR:"desc",0,3,2,1,0x2901
+BLEGATTCCHAR:"char",0,3,3,0xC302,8
+BLEGATTCCHAR:"desc",0,3,3,1,0x2901
(continues on next page)
OK
AT+BLESPPCFG=1,3,5,3,7
Response:
OK
AT+BLESPP
Response:
OK
> // waiting for serial data
Note: After ESP32 Client enabling BLE SPP, data received from serial port will be transmitted to the BLE server
directly.
ESP32 Server:
(1) Set a characteristic that supports notification or indication to TX channel for
˓→sending data. Set another characteristic that enables writing permission to RX
AT+BLESPPCFG=1,1,7,1,5
Response:
OK
(2) Enable BLE SPP:
AT+BLESPP
Response:
OK
> // waiting for serial data
Notes:
• After ESP32 Server enables BLE SPP, the data received from serial port will be transmitted to the BLE client
directly.
• If the ESP32 Client does not enable BLE SPP first, or uses other device as BLE client, then the BLE client needs
to listen to the notification or indication first. For example, if the ESP32 Client does not enable BLE SPP first,
then it should enable listening with command AT+BLEGATTCWR=0,3,7,1,1 first for the ESP32 Server to
transmit successfully.
• For the same service, the <srv_index> on the ESP32 Client side equals the <srv_index> on the ESP32
Server side plus 2.
Create a local MQTT broker. For example, the MQTT broker’s IP address is “192.168.31.113”, port 1883. Then the
example of communicating with the MQTT broker will be as the following steps.
AT+MQTTUSERCFG=0,1,"ESP32","espressif","1234567890",0,0,""
AT+MQTTCONN=0,"192.168.31.113",1883,0
AT+MQTTSUB=0,"topic",1
AT+MQTTPUB=0,"topic","test",1,0
AT+MQTTCLEAN=0
Create a local MQTT broker. For example, the MQTT broker’s IP address is “192.168.31.113”, port 1883. Then the
example of communicating with the MQTT broker will be as the following steps.
AT+CIPSNTPCFG=1,8,"ntp1.aliyun.com"
AT+CIPSNTPTIME?
AT+MQTTUSERCFG=0,3,"ESP32","espressif","1234567890",0,0,""
AT+MQTTCONNCFG=0,0,0,"lwtt","lwtm",0,0
AT+MQTTCONN=0,"192.168.31.113",1883,0
AT+MQTTSUB=0,"topic",1
AT+MQTTPUB=0,"topic","test",1,0
AT+MQTTCLEAN=0
This is an example of communicating with MQTT broker: iot.eclipse.org, of which port is 443.
AT+CIPSNTPCFG=1,8,"ntp1.aliyun.com"
AT+CIPSNTPTIME?
AT+MQTTUSERCFG=0,7,"ESP32","espressif","1234567890",0,0,"wss"
AT+MQTTCONN=0,"iot.eclipse.org",443,0
AT+MQTTSUB=0,"topic",1
AT+MQTTPUB=0,"topic","test",1,0
AT+MQTTCLEAN=0
Note: Before you run any Ethernet AT commands, please make sure you have followed the Prerequisite.
AT+CIPMUX=1
• Response
OK
AT+CIPSERVER=1,8081
• Response
OK
AT+CIPETH?
• Response
+CIPETH:ip:192.168.105.24
+CIPETH:gateway:192.168.105.1
+CIPETH:netmask:255.255.255.0
OK
4. Use a network tool on PC to create a TCP client and connect to the TCP server that ESP created. (IP:
192.168.105.24, Port: 8081).
5. Send data in Normal Transmission Mode.
• Command
• Response
OK
>
• Response
SEND OK
Note: If the length of the data you entered is more than the value of <length> (n) set by AT+CIPSEND, the
system will prompt busy, and send the first n bytes. After sending the first n bytes, the system will reply SEND
OK.
6. Receive data in Normal Transmission Mode.
When the ESP server receives data, AT will prompt:
AT+CIPCLOSE=0
• Response
OK
AT+CIPSERVER=0
• Response
OK
Note: The default firmware does not support web server AT commands, please refer to Web server AT Commands to
enable the web server.
Introduction
With the web server, mobile phone or PC is able to control ESP device‘s Wi-Fi provisioning service. You can use
a mobile phone or computer to connect to the SoftAP of the ESP device, open the web pages via browser, start
provisioning service, and then the ESP device can connect to the target router as you set.
The whole process can be divided into the following three steps:
Firstly, ESP device needs to be configured to softAP + STA mode, and creates a web server to wait for Wi-Fi provi-
sioning messages. In this case, a mobile phone or a PC can connect to the ESP softAP as a station. The corresponding
AT commands are as follows:
1. Clear the previous Wi-Fi provisioning information.
• Command
AT+RESTORE
AT+CWMODE=3
3. Set the configuration of an ESP SoftAP.For example, set the default connection ssid to “pos_softap”, Wi-Fi
without password.
• Command
AT+CWSAP="pos_softap","",11,0,3
AT+CIPMUX=1
5. Create a web server, port: 80, connection timeout: 25 s (default maximum is 60 s).
• Command
AT+WEBSERVER=1,80,25
After starting the web sever according to the above commands, you can turn on the Wi-Fi connection function on your
STA device, and connect it to the softAP of the ESP device:
After your STA device connected to the ESP softAP, it can send Wi-Fi connection information to ESP in an HTTP
request. Please note that if your target AP is the hotspot of the device which opens the web pages, you may not receive
the Wi-Fi connection result. You can enter the default IP address of the web server in the browser (the default IP is
192.168.4.1, or you can query the current SoftAP IP address by command AT+CIPAP?), open the Wi-Fi provisioning
interface, and enter the ssid and password of the router to be connected, click “Connect” to let ESP device start
connecting to the router:
Or you can click the drop-down box of SSID to list all APs nearby, select the target AP and enter the password, and
then click “Connect” to let the ESP device start connecting to the router:
After the Wi-Fi connection is established successfully, the web page will be displayed as follows:
Note 1: After the Wi-Fi connection is established successfully, the webpage will be closed automatically. If you want
to continue to access the webpage, please re-enter the IP address of the ESP device and reopen the webpage.
At the same time, the following messages will be returned from the ESP-AT command port:
+WEBSERVERRSP:2 // meaning that STA device has received Wi-Fi connection result,
˓→and web resources can be released
If the ESP device fails to connect to the router, the web page will display:
At the same time, the following messages will be returned from the ESP-AT command port:
Troubleshooting
Note 1: The network configuration page received a prompt “Connection failed”. Please check whether the Wi-Fi AP
of the ESP module is correctly turned on, and the relevant configuration of the AP, and confirm that the correct AT
command has been entered to successfully enable the web server.
Introduction
After the browser opens the web page of the web server, you can choose to enter the OTA upgrade page to upgrade
the firmware of the ESP device through the web page.
As shown in the figure, click on the “OTA” option in the lower right corner of the web page, and after opening the
OTA configuration page, you can view the current firmware version and AT Core version:
Note 1: The configuration interface can only be opened when the STA device is connected to the AP of the ESP device,
or the STA device accessing the OTA configuration page is connected to the ESP device in the same subnet.
Note 2: The “current app version” displayed on the webpage is the version number of the application. You can change
the version number through ./build.py menuconfig –> Component config –> AT –> AT firmware
version (see Build Your Own ESP-AT Project). In this case, you can manage your application firmware version.
As shown in the figure, click the “Browse” button on the page and select the new firmware to be sent:
Note 1: Before sending the new firmware, the system will check the selected firmware. The suffix of the firmware
name must be .bin, and its size should not exceed 2M.
As shown in the figure, if the ESP device OTA successfully, it will prompt “OTA Succeeded”:
At the same time, the following messages will be returned from the ESP-AT command port:
If the received firmware data verification fails, the following message will be received on the serial port:
Introduction
The WeChat applet can automatically connect to the WiFi AP of the ESP device, and then send the ssid and password
required by the ESP device to connect to the network.
The whole process can be divided into the following four steps:
Firstly, ESP device needs to be configured to softAP + STA mode, and creates a web server to wait for Wi-Fi provi-
sioning messages. In this case, a mobile phone or a PC can connect to the ESP softAP as a station. The corresponding
AT commands are as follows:
1. Clear the previous Wi-Fi provisioning information.
• Command
AT+RESTORE
AT+CWMODE=3
3. Set the configuration of an ESP SoftAP.For example, set the default connection ssid to “pos_softap” , and
password to “espressif”.
• Command
AT+CWSAP="pos_softap","espressif",11,3,3
Note: By default, the WeChat applet initiates a connection to the SoftAP whose ssid is pos_softap and
password is espressif. Please make sure to set the parameters of the ESP device according to the above
configuration.
AT+CIPMUX=1
2. Create a web server, port: 80, connection timeout: 40 s (default maximum is 60 s).
• Command
AT+WEBSERVER=1,80,40
Open the WeChat applet and enter the Wi-Fi provisioning interface:
Target AP Selection
After loading the WeChat applet, there are two situations according to different target AP:
Situation 1. If your target AP is the hotspot of the mobile phone which running the WeChat applet, please select the
“Local phone hotspot” option box on the WeChat applet page.
Situation 2. If your target AP is just another AP, not as the special situation one as above, then please do not select the
“Local phone hotspot” option box.
The target AP to be accessed is not the hotspot provided by the mobile phone which loading the
WeChat applet.
Here, take connecting to a router as an example, the process of Wi-Fi Connection configuration is introduced:
1.Turn on the mobile Wi-Fi and connect to the router:
2.Open the WeChat applet, you can see that the applet page has automatically displayed the ssid of the current router
as “FAST_FWR310_02”.
Note: If the ssid of the connected router is not displayed on the current page, please click “Re-enter applet” in the
following figure to refresh the current page:
3.After entering the password of the router, click “Connect”.
4.After the Wi-Fi connection is established successfully, the web page will be displayed as follows:
At the same time, the following messages will be returned from the ESP-AT command port:
+WEBSERVERRSP:2 // meaning that STA device has received Wi-Fi connection result,
˓→and web resources can be released
5.If the ESP device fails to connect to the router, the page will display:
At the same time, the following messages will be returned from the ESP-AT command port:
The target AP to be accessed is the hotspot provided by the mobile phone which loading the WeChat
applet.
If the target AP to be accessed is the hotspot provided by the mobile phone which loading the WeChat applet, it is
not necessary to enter the ssid, but only needs to enter the password of the AP, and turn on the mobile AP in time
according to the prompts.
1.Select the “Local phone hotspot” option box on the WeChat applet page, enter the password of the local hotspot, and
click “Connect”.
Fig. 12: The applet obtains the information of the router to be connected
Fig. 14: The applet starts the ESP device to connect to the router
2.After receiving the prompt “Connecting to the mobile phone hotspot”, please check that the local mobile phone
hotspot is turned on. At this time, the ESP device will automatically scan the surrounding hotspots and initiate a
connection.
3.The display of the WiFi connection results on the applet page and the data output from the serial port are the same
as the above-mentioned “The target AP to be accessed is not the hotspot provided by the mobile phone which loading
the WeChat applet.”, please refer to the above.
Troubleshooting
Note 1: The Wi-Fi provisioning page received a prompt “Data transmission failed”. Please check whether the Wi-Fi
AP of the ESP device is correctly turned on, and the relevant configuration of the AP, and confirm that the correct AT
command has been entered to successfully enable the web server.
Note 2: The Wi-Fi provisioning page receives a prompt “Failed to connect to the AP”. Please check whether the Wi-
Fi connection function of the mobile phone is turned on, check whether the Wi-Fi AP of the ESP device is correctly
turned on, and whether the ssid and password of the AP are configured according to the above steps.
Note 3: The Wi-Fi provisioning page receives a prompt “The Wi-Fi provisioning saved by the system expired”. Please
manually connect the ESP device AP with a mobile phone, and confirm that the ssid and password of the ESP module
have been configured according to the above steps.
The WeChat applet support online firmware upgrade , please refer to the above-described Configure ESP Device
Parameters specific steps performed ESP device configuration (if the configuration has been completed, do not repeat
configuration). Once configured, the device performs OTA firmware upgrade processes is similar as OTA Firmware
Upgrade Using a Browser .
Introduction
Captive Portal is commonly used to present a specified page to newly connected devices of a Wi-Fi or wired network.
For more information about Captive Portal, please refer to Captive Portal Wiki .
Note: The default firmware does not support web server Captive Portal, you may enable it by ./build.py
menuconfig > Component config > AT > AT WEB Server command support > AT WEB captive
portal support and build the project (see Build Your Own ESP-AT Project). In addition, enabling this feature
may cause page skipping when using wechat applet for Wi-Fi provisioning or OTA firmware upgrade. It is recom-
mended that this feature be enabled only when accessing at web using browser.
After Enable Captive Portal support, please refer to Use STA Device to Connect to ESP Device to complete the
configuration of the ESP device, and then connect to the AP of the ESP device:
As shown in the figure above, after the Station device is connected to the AP of the ESP device with the Captive Portal
function enabled, it will prompt “requires login/authentication”, and then the browser will automatically open and
jump to the main interface of AT Web. If it cannot be redirected automatically, please follow the instructions of the
Station device, click “Authentication” or click the name of the “pos_softap” hotspot in the figure above to manually
trigger the Captive Portal to automatically open the browser and enter the main interface of AT Web.
Troubleshooting
Note 1: Both Station device and AP device support the Captive Portal function to ensure the normal use of this func-
tion. Therefore, if the device is connected to the AP of the ESP device, but it does not prompt “Login/Authentication”,
it may be that the Station device does not support this function. In this case, please refer to the specific steps of Use
the Browser to Send Wi-Fi Connection Information above to open the main interface of AT Web.
[]
This document details how to build your own ESP-AT project and flash the generated binary files into your ESP
devices, including ESP32, ESP32-S2, ESP32-C3, and ESP8266. It comes in handy when the default AT Binary Lists
cannot meet your needs, for example, to customize the AT port pins, Bluetooth service, partitions, and so on.
The structure of this document is as follows:
• Overview: Overview of the steps to build an ESP-AT project.
• ESP32, ESP32-S2 and ESP32-C3 Series: Details steps to build a project for ESP32, ESP32-S2, and ESP32-C3
series.
• ESP8266 Series: Details steps to build a project for ESP8266.
5.1.1 Overview
Before compiling an ESP-AT project, you need first get started with ESP-IDF and set up the environment for ESP-IDF,
because ESP-AT is based on ESP-IDF.
After the environment is ready, install the tools and ESP-AT SDK. Then, connect your ESP device to PC. Use ./
build.py menuconfig to set up some configuration for the project. Build the project and flash the generated bin
files onto your ESP device.
Note: Please pay attention to possible conflicts of pins. If choosing AT through HSPI, you can get the informa-
tion of the HSPI pin by ./build.py menuconfig –> Component config –> AT –> AT hspi settings.
255
ESP-AT User Guide
This section describes how to compile an ESP-AT project for ESP32, ESP32-S2 and ESP32-C3 series.
Get started with ESP-IDF before compiling an ESP-AT project, because ESP-AT is developed based on ESP-IDF, and
the supported version varies from series to series:
First, set up the development environment for ESP-IDF according to Step 1 to 4 of ESP-IDF Get Started Guide (click
the corresponding link in the table above to navigate to the documentation).
Then, start a simple project of hello_world according to Step 5 to 10 of ESP-IDF Get Started Guide to make sure
your environment works and familiarize yourself with the process of starting a new project based on ESP-IDF. It is
not a must, but you are strongly recommended to do so.
After finishing all the ten steps (if not, at least the first four steps), you can move onto the following steps that are
ESP-AT specific.
Note: Please do not set IDF_PATH during the process, otherwise, you would encounter some unexpected issues
when compiling ESP-AT projects later.
Get ESP-AT
To compile an ESP-AT project, you need the software libraries provided by Espressif in the ESP-AT repository.
To get ESP-AT, navigate to your installation directory and clone the repository with git clone, following instructions
below specific to your operating system.
• Linux or macOS
cd ~/esp
git clone --recursive https://github.com/espressif/esp-at.git
• Windows
cd %userprofile%\esp
git clone --recursive https://github.com/espressif/esp-at.git
If you are located in China or have difficulties to access GitHub, you can also use git clone https://gitee.
com/EspressifSystems/esp-at.git to get ESP-AT, which may be faster.
ESP-AT will be downloaded into ~/esp/esp-at on Linux or macOS, or %userprofile%\esp\esp-at on
Windows.
Note: This guide uses the directory ~/esp on Linux or macOS, or %userprofile%\esp on Windows as an
installation folder for ESP-AT. You can use any directory, but you will need to adjust paths for the commands respec-
tively. Keep in mind that ESP-AT does not support spaces in paths.
Connect your device to the PC with a USB cable to download firmware and log output. See Hardware Connection for
more information. Note that you do not need to set up the “AT command/response” connection if you do not send AT
commands and receive AT responses during the compiling process. You can change default port pins referring to How
to Set AT Port Pins.
Configure
In this step, you will clone the esp-idf folder into the esp-at folder, set up the development environment in the
newly cloned folder, and configure your project.
1. Navigate to ~/esp/esp-at directory.
2. Run the project configuration utility menuconfig to configure.
./build.py menuconfig
3. Select the following configuration options for your ESP device if it is your first time.
• Select the Platform name for your ESP device. For example, select PLATFORM_ESP32 for ESP32 se-
ries of products, PLATFORM_ESP32S2 for ESP32-S2 series of products. Platform name is defined in
factory_param_data.csv .
• Select the Module name for your ESP device. For example, select WROOM-32 for the ESP32-WROOM-32D
module. Module name is defined in factory_param_data.csv .
• Enable or disable silence mode. If enabled, it will remove some logs and reduce the firmware size. Gener-
ally, it should be disabled.
• The above three option items will not appear if the file build/module_info.json exists. So please delete
it if you want to reconfigure the module information.
4. Now, the esp-idf folder is created in esp-at folder. This esp-idf is different from that in Step Get
Started with ESP-IDF.
• If the terminal prompt an error message like the following, please proceed with the next step to set up the develop
environment in the esp-at/esp-idf.
• If you have compiled an ESP-AT project for an ESP series before and want to switch to another series, you must
run rm -rf esp-idf to remove the old esp/idf and then proceed with the next step.
• If your esp-idf is upgraded, you are recommended to proceed with the next step.
5. Set up the development environment in the esp-at/esp-idf.
• Set up the tools in the folder if it is the first time you compile the ESP-AT project. See Step 3 of ESP-IDF Get
Started Guide.
• Set up environment variables in the folder every time you compile an ESP-AT project. See Step 4 of ESP-IDF
Get Started Guide.
• Install pyyaml and xlrd packages with pip in the folder if you have not done it.
If the previous steps have been done correctly, the following menu appears after you run ./build.py
menuconfig:
You are using this menu to set up project-specific configuration, e.g. changing AT port pins, enabling Classic Bluetooth
function, etc. If you made no changes, it will run with the default configuration.
./build.py build
• If Bluetooth feature is enabled, the firmware size will be much larger. Please make sure it does not exceed the
ota partition size.
• After compiled, the combined factory bin will be created in build/factory. See How to understand the
differences of each type of module for more information.
Flash the binaries that you just built onto your ESP32 board by running:
• Note that you may need to replace PORT with your ESP device’s serial port name.
• Or you can follow the printed instructions to flash the bin files into flash. Note that you may also need to replace
the PORT.
• If the ESP-AT bin fails to boot and prints “ota data partition invalid”, you should run ./build.py
erase_flash to erase the entire flash, and then re-flash the AT firmware.
This section describes how to compile an ESP-AT project for ESP8266 series.
Get started with ESP-IDF before compiling an ESP-AT project, because ESP-AT is developed based on ESP-IDF:
First, set up the development environment according to ESP8266 RTOS SDK Get Started Guide v3.4.
Then, start a simple project of hello_world according to the Guide to make sure your environment works and
familiarize yourself with the process of starting a new project based on ESP-IDF. It is not a must, but you are strongly
recommended to do so.
After setting up the development environment and starting a simple project, you can move onto the following steps
that are ESP-AT specific.
Note: Please do not set IDF_PATH during the process, otherwise, you would encounter some unexpected issues
when compiling ESP-AT projects later.
Get ESP-AT
To compile an ESP-AT project, you need the software libraries provided by Espressif in the ESP-AT repository.
To get ESP-AT, navigate to your installation directory and clone the repository with git clone, following instructions
below specific to your operating system.
• Linux or macOS
cd ~/esp
git clone --recursive https://github.com/espressif/esp-at.git
• Windows
cd %userprofile%\esp
git clone --recursive https://github.com/espressif/esp-at.git
If you are located in China or have difficulties to access GitHub, you can also use git clone https://gitee.
com/EspressifSystems/esp-at.git to get ESP-AT, which may be faster.
ESP-AT will be downloaded into ~/esp/esp-at on Linux or macOS, or %userprofile%\esp\esp-at on
Windows.
Note: This guide uses the directory ~/esp on Linux and macOS or %userprofile%\esp on Windows as
an installation folder for ESP-AT. You can use any directory, but you will need to adjust paths for the commands
respectively. Keep in mind that ESP-AT does not support spaces in paths.
Connect your device to the PC with a USB cable to download firmware and log output. See Hardware Connection for
more information. Note that you do not need to set up the “AT command/response” connection if you do not send AT
commands and receive AT responses during the compiling process. You can change default port pins referring to How
to Set AT Port Pins.
Configure
In this step, you will clone the esp-idf folder into the esp-at folder, set up the development environment in the
newly cloned folder, and configure your project.
1. Navigate back to your ~/esp/esp-at directory.
2. Run the project configuration utility menuconfig to configure.
./build.py menuconfig
3. Select the following configuration options for your ESP device if it is the first time you build the ESP-AT project.
• Select the Platform name for your ESP device, i.e., select PLATFORM_ESP8266 for your ESP8266 device.
Platform name is defined in factory_param_data.csv .
• Select the Module name for your ESP device. For example, select WROOM-02 for the ESP-WROOM-02D
module. Module name is defined in factory_param_data.csv .
• Enable or disable silence mode. If enabled, it will remove some logs and reduce the firmware size. Gener-
ally, it should be disabled.
• The above three option items will not appear if the file build/module_info.json exists. So please delete
it if you want to reconfigure the module information.
4. Now, the esp-idf folder is created in esp-at folder. This esp-idf is different from that in Step Get
Started with ESP-IDF.
• If the terminal prompt an error message like the following, please proceed with the next step to set up the develop
environment in the esp-at/esp-idf.
• If you have compiled an ESP-AT project for an ESP series before and want to switch to another series, you must
run rm -rf esp-idf to remove the old esp/idf and then proceed with the next step.
• If your esp-idf is upgraded, you are recommended to proceed with the next step.
5. Set up the development environment in the esp-at/esp-idf.
• Set up the tools in the folder if it is the first time you compile an ESP-AT project. See ESP8266 RTOS SDK Get
Started Guide v3.4 for more information.
• Set up environment variables in the folder every time you compile an ESP-AT project. See ESP8266 RTOS
SDK Get Started Guide v3.4 for more information.
• Install pyyaml and xlrd packages with pip in the folder if you have not done it.
If the previous steps have been done correctly, the following menu appears after you run ./build.py
menuconfig:
You are using this menu to set up project-specific configuration, e.g. changing AT port pins, enabling Classic Bluetooth
function, etc. If you made no changes, it will run with the default configuration.
./build.py build
• After compiled, the combined factory bin will be created in build/factory. By default, the factory bin is 2
MB flash size, DIO flash mode and 80 MHz flash speed. See How to understand the differences of each type of
module for more information.
Flash the binaries that you just built onto your ESP8266 board by running:
• Note that you may need to replace PORT with your ESP device’s serial port name.
• Or you can follow the printed instructions to flash the bin files into flash. Note that you may also need to replace
the PORT.
• If the ESP-AT bin fails to boot and prints “ota data partition invalid”, you should run ./build.py
erase_flash to erase the entire flash, and then re-flash the AT firmware.
This document introduces how to modify AT port pins in the firmware for ESP32, ESP32-S2, ESP32-C3, and ESP8266
series of products. By default, ESP-AT uses two UART interfaces as AT ports: one is to output logs (named as log
port below) and the other to send AT commands and receive responses (named as command port below).
To modify the AT port pins of your ESP device, you should:
• clone the esp-at project;
• modify the pins either in the menuconfig utility or the factory_param_data.csv table;
Note: To use other interfaces as the AT command port, please refer to AT through SDIO , AT through SPI , or AT
through socket for more details.
The log port and command port pins of ESP32 AT firmware can be user-defined to other pins. Refer to ESP32
Technical Reference Manual for the pins you can use.
By default, the ESP32 AT firmware provided by Espressif uses the following UART0 pins to output log:
• TX: GPIO1
• RX: GPIO3
When compiling your esp-at project, you can modify them to other pins with the menuconfig utitlity:
• ./build.py menuconfig –> Component config –> Common ESP-related –> UART for
console output
• ./build.py menuconfig –> Component config –> Common ESP-related –> UART TX on
GPIO#
• ./build.py menuconfig –> Component config –> Common ESP-related –> UART RX on
GPIO#
By default, UART1 is used to send AT commands and receive AT responses, and its pins are defined in
Column uart_port, uart_tx_pin, uart_rx_pin, uart_cts_pin, and uart_rts_pin of the fac-
tory_param_data.csv .
You can change them directly in your factory_param_data.csv table:
• Open your local factory_param_data.csv file.
• Locate the row of your module.
• Set uart_port as needed.
• Set uart_tx_pin and uart_rx_pin as needed.
• Set uart_cts_pin and uart_rts_pin to be -1 if you do not use the hardware flow control function.
• Save the table.
The log port and command port pins of ESP32-S2 AT firmware can be user-defined to other pins. Refer to ESP32-S2
Technical Reference Manual for the pins you can use.
By default, the ESP32-S2 AT firmware provided by Espressif uses the following UART0 pins to output log:
• TX: GPIO43
• RX: GPIO44
When compiling your esp-at project, you can modify them to other pins with the menuconfig utitlity:
• ./build.py menuconfig –> Component config –> Common ESP-related –> UART for
console output
• ./build.py menuconfig –> Component config –> Common ESP-related –> UART TX on
GPIO#
• ./build.py menuconfig –> Component config –> Common ESP-related –> UART RX on
GPIO#
By default, UART1 is used to send AT commands and receive AT responses, and its pins are defined in
Column uart_port, uart_tx_pin, uart_rx_pin, uart_cts_pin, and uart_rts_pin of the fac-
tory_param_data.csv .
You can change them directly in your factory_param_data.csv table:
• Open your local factory_param_data.csv file.
• Locate the row of your module.
• Set uart_port as needed.
• Set uart_tx_pin and uart_rx_pin as needed.
• Set uart_cts_pin and uart_rts_pin to be -1 if you do not use the hardware flow control function.
• Save the table.
The log port and command port pins of ESP32-C3 AT firmware can be user-defined to other pins. ESP32-C3 Technical
Reference Manual for the pins you can use.
By default, the ESP32-C3 AT firmware provided by Espressif uses the following UART0 pins to output log:
• TX: GPIO21
• RX: GPIO20
When compiling your esp-at project, you can modify them to other pins with the menuconfig utitlity:
• ./build.py menuconfig –> Component config –> Common ESP-related –> UART for
console output
• ./build.py menuconfig –> Component config –> Common ESP-related –> UART TX on
GPIO#
• ./build.py menuconfig –> Component config –> Common ESP-related –> UART RX on
GPIO#
By default, UART1 is used to send AT commands and receive AT responses, and its pins are defined in
Column uart_port, uart_tx_pin, uart_rx_pin, uart_cts_pin, and uart_rts_pin of the fac-
tory_param_data.csv .
You can change them directly in your factory_param_data.csv table:
• Open your local factory_param_data.csv file.
• Locate the row of your module.
• Set uart_port as needed.
• Set uart_tx_pin and uart_rx_pin as needed.
• Set uart_cts_pin and uart_rts_pin to be -1 if you do not use the hardware flow control function.
• Save the table.
The log port and command port pins of the ESP8266 AT firmware can be user-defined to other pins, but with limited
options. Please refer to ESP8266 Technical Reference Manual for more details.
By default, the ESP8266 AT firmware provided by Espressif uses UART1 to log output. UART1 only supports GPIO2
as the TX pin, and the pin should not be modified.
However, you could modify the log port from UART1 to UART0 by:
• ./build.py menuconfig –> Component config –> Common ESP-related –> UART for
console output
By default, ESP8266 AT firmware uses UART0 to send AT commands and receive AT responses. The UART0 pins
are defined in Column uart_port, uart_tx_pin, uart_rx_pin, uart_cts_pin, and uart_rts_pin of
the factory_param_data.csv .
The UART pins can be changed, but there are only two choices: GPIO15 as TX pin, GPIO13 as RX or
GPIO1 as TX, GPIO3 as RX. Below are the detailed steps:
• Open your local factory_param_data.csv file.
• Locate the row of your module.
• Set uart_port as needed.
• Set uart_tx_pin and uart_rx_pin to GPIO15 and GPIO13, or GPIO1 and GPIO3.
• Set uart_cts_pin and uart_rts_pin to be -1 if you do not use the hardware flow control function.
• Save the table.
For example, if you need to set GPIO1 (TX) and GPIO3 (RX) to be both the log port and command port of ESP-
WROOM-02, do as follows:
1. Set log port to UART0: ./build.py menuconfig –> Component config –> ESP8266-specific
–> UART for console output –> Default: UART0
2. Open your local factory_param_data.csv.
3. Find the row of WROOM-02, set uart_tx_pin to 1, uart_rx_pin to 3, uart_cts_pin to -1,
uart_rts_pin to -1, and then save the table.
This document details how to add a user-defined AT command based on the esp-at project. It uses the AT+TEST
command as an example to show the sample code for each step.
Customizing a basic and well-functioned command requires at least the two steps below:
• Define AT Commands
• Register AT Commands
This step checks how the newly defined command works out.
• Give it a try
The remaining steps are for relatively complex AT commands and are optional depending on your needs.
• Define Return Values
• Access Command Parameters
• Omit Command Parameters
• Block Command Execution
• Access Input Data from AT Command Port
The source code of AT command set is not open-source, and is provided in the form of library file . It is also the basis
to parse user-defined AT commands.
Before defining any AT command, you should first decide on the name and type of the AT command you want to
define.
Naming rules:
• AT command should start with the + character.
• Alphabetic characters (A~Z, a~z), numeric characters (0~9), and some other characters (!, %, -, ., /, :, _)
are supported. See AT Command Types for more information.
Command types:
Each AT command can have up to four types: Test Command, Query Command, Set Command, and Execute Com-
mand. See AT Command Types for more information.
Then, define each type of command. Assuming that AT+TEST supports all the four types. Below is the sample code
to define each type.
Test Command:
uint8_t at_test_cmd_test(uint8_t *cmd_name)
{
uint8_t buffer[64] = {0};
return ESP_AT_RESULT_CODE_OK;
}
Query Command:
uint8_t at_query_cmd_test(uint8_t *cmd_name)
{
uint8_t buffer[64] = {0};
return ESP_AT_RESULT_CODE_OK;
}
Set Command:
uint8_t at_setup_cmd_test(uint8_t para_num)
{
int32_t para_int_1 = 0;
uint8_t *para_str_2 = NULL;
uint8_t num_index = 0;
uint8_t buffer[64] = {0};
return ESP_AT_RESULT_CODE_ERROR;
}
snprintf((char *)buffer, 64, "this cmd is setup cmd and cmd num is: %u\r\n", para_
˓→ num);
esp_at_port_write_data(buffer, strlen((char *)buffer));
memset(buffer, 0, 64);
snprintf((char *)buffer, 64, "first parameter is: %d\r\n", para_int_1);
esp_at_port_write_data(buffer, strlen((char *)buffer));
memset(buffer, 0, 64);
snprintf((char *)buffer, 64, "second parameter is: %s\r\n", para_str_2);
esp_at_port_write_data(buffer, strlen((char *)buffer));
return ESP_AT_RESULT_CODE_OK;
}
Execute Command:
return ESP_AT_RESULT_CODE_OK;
}
Finally, call esp_at_cmd_struct to define the name and type(s) that your AT command supports. The sample
code below defined the name +TEST (omitting AT) and all the four types.
};
Call API esp_at_custom_cmd_array_regist() to register your AT command. Below is the sample code to
register AT+TEST:
If you have finished the above two steps, the command should work after you build the esp-at project and flash the
firmware to your device. Give it a try!
Below is how AT+TEST works out.
Test Command:
AT+TEST=?
Response:
AT+TEST=?
this cmd is test cmd: +TEST
OK
Query Command:
AT+TEST?
Response:
AT+TEST?
this cmd is query cmd: +TEST
OK
Set Command:
AT+TEST=1,"espressif"
Response:
AT+TEST=1,"espressif"
this cmd is setup cmd and cmd num is: 2
first parameter is: 1
second parameter is: espressif
OK
Execute Command:
AT+TEST
Response:
AT+TEST
this cmd is execute cmd: +TEST
OK
ESP-AT has defined return values in esp_at_result_code_string_index. See AT Messages for more return
values.
In addition to output return values through the return mode, you can also use API esp_at_response_result()
to output the execution result of the command. ESP_AT_RESULT_CODE_SEND_OK and
ESP_AT_RESULT_CODE_SEND_FAIL can be used with the API in code.
For example, when you send data to the server or MCU with the Execute Command of AT+TEST, you can use
esp_at_response_result to output the sending result, and the return mode to output the command execution
result. Below is the sample code:
// output SEND OK
esp_at_response_result(ESP_AT_RESULT_CODE_SEND_OK);
return ESP_AT_RESULT_CODE_OK;
}
AT+TEST
this cmd is execute cmd: +TEST
SEND OK
OK
Let’s say you want to make <param_2> and <param_3> of AT+TEST optional. <param_2> is a digital parameter,
and <param_3> a string parameter.
AT+TEST=<param_1>[,<param_2>][,<param_3>],<param_4>
snprintf((char *)buffer, 64, "this cmd is setup cmd and cmd num is: %u\r\n", para_
˓→ num);
esp_at_port_write_data(buffer, strlen((char *)buffer));
return ESP_AT_RESULT_CODE_OK;
}
Let’s say you want to make the string parameter <param_3> optional, which is also the last parameter.
AT+TEST=<param_1>,<param_2>[,<param_3>]
snprintf((char *)buffer, 64, "this cmd is setup cmd and cmd num is: %u\r\n", para_
˓→ num);
esp_at_port_write_data(buffer, strlen((char *)buffer));
if (num_index == para_num) {
memset(buffer, 0, 64);
snprintf((char *)buffer, 64, "third parameter is omitted\r\n");
esp_at_port_write_data(buffer, strlen((char *)buffer));
} else {
parse_result = esp_at_get_para_as_str(num_index++, ¶_str_3);
if (parse_result != ESP_AT_PARA_PARSE_RESULT_OMITTED) {
if (parse_result != ESP_AT_PARA_PARSE_RESULT_OK) {
return ESP_AT_RESULT_CODE_ERROR;
} else {
// sample code
// user needs to customize the operation
memset(buffer, 0, 64);
snprintf((char *)buffer, 64, "third parameter is: %s\r\n", para_str_
˓→3);
return ESP_AT_RESULT_CODE_OK;
}
Sometimes you want to block the execution of one command to wait for another execution result, and the system may
return different values according to the result.
Generally, this kind of command needs to synchronize the results of other tasks.
// sample code
// users don't have to create semaphores here
at_operation_sema = xSemaphoreCreateBinary();
assert(at_operation_sema != NULL);
return ESP_AT_RESULT_CODE_OK;
}
ESP-AT supports accessing input data from AT Command port. It provides two APIs for this purpose.
• esp_at_port_enter_specific() sets the callback function which will be called by AT port after re-
ceiving the input data.
• esp_at_port_exit_specific() deletes the callback function set by
esp_at_port_enter_specific.
Approaches to access the data vary depending on whether the data length has been specified or not.
Assuming that you have specified the data length in <param_1> as follows:
AT+TEST=<param_1>
Below is the sample to access the input data of <param_1> length from AT Command Port:
void wait_data_callback(void)
{
xSemaphoreGive(at_sync_sema);
}
// sample code
// users don't have to create semaphores here
if (!at_sync_sema) {
at_sync_sema = xSemaphoreCreateBinary();
assert(at_sync_sema != NULL);
}
// set the callback function which will be called by AT port after receiving the
˓→ input data
esp_at_port_enter_specific(wait_data_callback);
if (specified_len == received_len) {
esp_at_port_exit_specific();
// sample code
// output received data
memset(buffer, 0, 64);
snprintf((char *)buffer, 64, "\r\nreceived data is: ");
esp_at_port_write_data(buffer, strlen((char *)buffer));
esp_at_port_write_data(buf, specified_len);
(continues on next page)
break;
}
}
free(buf);
return ESP_AT_RESULT_CODE_OK;
}
So, if you set AT+TEST=5 and the input data is 1234567890, the ESP-AT output is as follows.
AT+TEST=5
>67890
received data is: 12345
OK
This scenario is similar to the Wi-Fi Passthrough Mode. You do not specify the data length.
AT+TEST
Assuming that ESP-AT ends the execution of the command and returns the execution result, the sample code is as
follows:
#define BUFFER_LEN (2048)
static xSemaphoreHandle at_sync_sema = NULL;
void wait_data_callback(void)
{
xSemaphoreGive(at_sync_sema);
}
// sample code
// users don't have to create semaphores here
if (!at_sync_sema) {
at_sync_sema = xSemaphoreCreateBinary();
assert(at_sync_sema != NULL);
}
(continues on next page)
// set the callback function which will be called by AT port after receiving the
˓→ input data
esp_at_port_enter_specific(wait_data_callback);
// sample code
// if the remaining data length > 0, it means that there is still data
˓→left in the buffer to be processed
break;
} else if (received_len > 0) {
// sample code
// users can customize the operation to process the received data
// here is just a simple print received data
memset(buffer, 0, 64);
snprintf((char *)buffer, 64, "\r\nreceived data is: ");
esp_at_port_write_data(buffer, strlen((char *)buffer));
free(buf);
return ESP_AT_RESULT_CODE_OK;
}
So, if the first input data is 1234567890, and the second input data is +++, the ESP-AT output is as follows:
AT+TEST
>
received data is: 1234567890
OK
5.4.1 Overview
In order to adapt the AT firmware to different requirements, for example, different development board, different
country code, different RF restriction, we make a table to configure those parameters.
* For ESP32 Series chip, range[8, 78], more details please refer to ESP32 tx power setting range
* For ESP8266 Series chip, range[-128, 127], more details please refer to ESP8266 tx power setting
range
* For ESP32S2 Series chip, range[8, 78], more details please refer to ESP32S2 tx power setting range
* For ESP32-C3 Series chip, range[8, 78], more details please refer to ESP32-C3 tx power setting range
• start_chanel
– Wi-Fi start channel
• channel_num
– the total channel number of Wi-Fi
• country_code
– Country code
• uart_baudrate
– uart baudrate
• uart_tx_pin
– uart tx pin
• uart_rx_pin
– uart rx pin
• uart_cts_pin
– uart cts pin, it can be configured -1, if the pin is not used
• uart_rts_pin
– uart rts pin, it can be configured -1, if the pin is not used
• tx_control_pin
– for some board, tx pin need to be separated from mcu when power on. It can be configured -1, if the pin is
not used
• rx_control_pin
– for some board, rx pin need to be separated from mcu when power on. It can be configured -1, if the pin is
not used
• reserved2
– reserved
• platform
– Which platform the current firmware runs on
• module_name
– Which module the current firmware runs on
if you want to add a module named as “MY_MODULE”, of which country code is JP, and Wi-Fi channel is from 1 to
14, the table should be as the following one:
Then add module information in esp_at_module_info in at_default_config.c, like
#if defined(CONFIG_IDF_TARGET_ESP8266)
{"WROOM-02", CONFIG_ESP_AT_OTA_TOKEN_WROOM_02, CONFIG_ESP_AT_OTA_SSL_
˓→TOKEN_WROOM_02 },
#endif
(continues on next page)
#if defined(CONFIG_IDF_TARGET_ESP32S2)
{"WROOM", CONFIG_ESP_AT_OTA_TOKEN_ESP32S2_WROOM, CONFIG_ESP_AT_OTA_
˓→SSL_TOKEN_ESP32S2_WROOM },
#endif
#if defined(CONFIG_IDF_TARGET_ESP32C3)
{"MINI-1", CONFIG_ESP_AT_OTA_TOKEN_ESP32C3_MINI, CONFIG_ESP_AT_OTA_
˓→SSL_TOKEN_ESP32C3_MINI },
#endif
};
If you want to add more parameter, for example, add a string “20181225” as the date, you need to add the type of date
in the factory_param_type.csv, as the following table.
Edit factory_param_data.csv with reference to Add customized module, and add the date into the last column,
as the following table,
It is important to know that the total size of the AT factory parameter is controlled by the
ESP_AT_FACTORY_PARAMETER_SIZE in at_default_config.h, and can be adjusted as needed
Notes: It’s recommended that do not change the first 2048 bytes, which may be used by Espressif.
Then, you can add code to parse date in esp_at_factory_parameter_init or other api.
If you simply need to modify factory_param on an existing module, the following three methods are recommended:
• method one
– Premise: you need to have the entire esp-at project.
1. Find the factory_param_data.csv file through the following path: components/
customized_partitions/raw_data/factory_param/factory_param_data.csv, and
modify the parameters.
2. Recompile the esp-at project, download the new factory_param.bin into flash.
• method two
– Premise: you need to have the entire esp-at project.
1. Find the factory_param_data.csv file through the following path: components/
customized_partitions/raw_data/factory_param/factory_param_data.csv, and
modify the parameters.
2. Open the terminal in the following path: esp-at, execute the following command.
The BLE Services are defined as a multivariate array of GATT structures, each element of the array always consist of
a service, declarations, characteristics and optional descriptors.
User can define more than one services. For example, if you want to define three services(Server_A, Server_B
and Server_C), then these three services need to be arranged in order. Since the definition of each service is similar,
here we define one service as example, and then you can define others one by one accordingly.
Each service always consist of a service definition and several characteristics. Each characteristic may be followed by
some descriptions.
the service definition must be in the first line, it always be a primary service (UUID 0x2800) which determines with
its value which service is described(for example, a predefined one such as 0x180A or a self generated one).
• For example, the following line defines a primary service with UUID 0xA002.
Definition of characteristics starts from the second line. It contains at least two lines, one is the characteristic declara-
tion, another is to define the characteristic. UUID 0x2803 means the characteristic declaration, value of this line sets
its permission, for example, 02 means both readable and writable, user can keep this configuration. Then the next line
defines this characteristic, UUID of this line will be the characteristic’s UUID, you can define it as you need, value
will be the characteristic’s value.
• For example, the following lines define a readable and writable characteristic with UUID 0xC300, whose value
is 0x30.
The attribute can be described further by descriptors. A special one is the descriptor “Client Characteristic Configu-
ration” (UUID 0x2902) which should be present if the Notify bit has been activated in the Characteristic Declaration
(UUID 0x2803). This descriptor should always be writable and readable.
• For example, the following lines define a readable and writable characteristic with UUID 0xC306, and able to
notify.
5.6.1 Overview
The primary partition table is for system usage, it will generate a “partitions_at.bin” according to the “parti-
tions_at.csv” in compilation. And if the primary partition table goes wrong, the system will fail to startup. So generally,
we should not change the “partitions_at.csv”.
In this case, we provide a secondary partition table for custom usage, “at_customize.csv”. We have already de-
fined some user partitions in it. Custom can add new partitions in the “at_customize.csv”, and generate a new
“at_customize.bin” according to it. The partition table can be updated by flashing the new “at_customize.bin” into
flash, or be revised by command “AT+SYSFLASH”.
• Users should not change the “name” and “type” of the user partitions which we defined in the
“at_customize.csv”. But “offset” and “size” can be changed, if necessary.
• If you need to add a new user partition, please check if it has already been defined in the ESP-IDF
(esp_partition.h) first.
– If it is defined in the ESP-IDF, you should keep the “type” value to be the same when adding it into the
at_customize.csv.
– If it is not defined in the ESP-IDF, please set the “type” to be “0x40” when adding it into the
at_customize.csv.
• A user partition’s name should NOT be longer than 16 bytes.
• The default size of the entire “at_customize” partition is 0xE0000, which is defined in the first partition. Please
do NOT over the range when adding new user partitions.
5.7.1 Overview
Classic bluetooth is Disabled by default. If you want to use classic bluetooth commands, you need to enable BT
commands in menuconfig.
initialization
There are two initialization-related commands. Firstly, initializing the bluetooth protocol stack, and then initializing
the profile, such as:
After initialization, there are some basic parameter setting commands that may be need to be invoked.
1. device name
The default device name is esp32, If use command to set the device name, it will be stored in NVS.
AT+BTNAME="EXAMPLE"
2. scan mode
3. security parameters
If the PIN type is variable, the PIN code will be ignored. If use the Simple pair encryption, the PIn code will be
ignored.
BT SPP EXAMPLE
1. PC CONNECTS TO ESP32
In this case, generally PC is master and ESP32 is slave. ESP32 needs to do this before the connection is established:
• initialization
• parameters setting
At this point, the PC should be able to find the bluetooth device with name “EXAMPLE”. If the PC initiates a
connection and the connection succeed, ESP32 will print this log:
+BTSPPCONN:<conn index>,<remote_addr>
ESP32 can also initiate connections, before initiating a connection, please scan the surrounding devices at first:
+BTSTARTDISC:<bt_addr>,<dev_name>,<major_dev_class>,<minor_dev_class>,<major_srv_
˓→class>
After the connection is established, the data can be sent and received
>
OK
If you use two ESP32 boards connected to each otherThe process is basically the same as described above, The only
difference is the initialization. the client initialization is as follow:
AT+BTINIT=1 // init BT stack
AT+BTSPPINIT=1 // init spp profile as master
Encryption-related operation
If the IO capability is not NoInputNoOutput, the encryption process will involve the exchange of key and PIN code.
If need to input the PIN code for Legacy Pair:
// conn_index, PIN code
AT+BTPINREPLY=0,"0000"
If ESP32 has the ability to output, You need to enter this password on the remote device
+BTKEYNTF:0,123456
The ESP32 can also choose to accept or reject the encryption request from the remote device:
// conn_index, accept or reject
AT+BTSECCFM=0,1
5.8.1 Overview
Initialises the Ethernet interface and enables it, then sends DHCP requests and tries to obtain a DHCP lease. If
successful then you will be able to ping the device.
Use ./build.py menuconfig to set the PHY model. These configuration items will vary depending on the
hardware configuration you are using.
The default configuration is correct for Espressif’s Ethernet board with TP101 PHY. ESP32 AT supports up to four
Ethernet PHY: LAN8720, IP101, DP83848 and RTL8201. TLK110 PHY is no longer supported because TI stoped
production. If you want to use other phy, follow the document to design.
Compiling
1. ./build.py menuconfig -> Component config -> AT -> AT ethernet support to enable eth-
ernet.
2. ./build.py menuconfig -> Component config -> AT -> Ethernet PHY to choose ethernet.
3. Recompile the esp-at project, download AT bin into flash.
Since the esp-at project supports different platform, for example, ESP32 UART AT, ESP32 SDIO AT, even supports
ESP8266 AT, when compiling the esp-at project, users can set different configurations to generate AT firmware for
different ESP modules. The detailed information are in the esp-at/module_config directory. Default config-
uration is the “PLATFORM_ESP32” for ESP-WROOM-32.Please note that if you use a different bus (for example,
SDIO, SPI or other buses) instead of UART, then you cannot use the default module_espxxxx_default directly,
you need to re-configure it in the menuconfig.Herein, we provide an example of the ESP32 SDIO AT to show how
to set a new platform for the esp-at project.
For example, to name the platform as “PLATFORM_ESP32”, the module as “WROOM32-SDIO”, we need to open
the components/customized_partitions/raw_data/factory_param/factory_param_data.
csv and add a new row of the new platform at the end.
Open the Makefile and set to the new platform. Please use capital letters.
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="module_config/module_esp32-sdio/
˓→partitions_at.csv"
CONFIG_PARTITION_TABLE_FILENAME="module_config/module_esp32-sdio/partitions_at.csv
˓→"
CONFIG_AT_CUSTOMIZED_PARTITION_TABLE_FILE="module_config/module_esp32-sdio/at_
˓→customize.csv"
– Since the esp-at project already supports the SDIO configuration, we only need to add it into the
sdkconfig.defaults.
Since the ESP32 SDIO AT and the ESP32 UART AT are based on the same platform, ESP32, they will share the same
at_core.lib. In this case, we need not to add any new at_core lib.If you need to use a new at_core lib, put the lib into
the components/at/lib, rename the lib as libxxxx_at_core.a, xxxx is the platform name. For example,
if you set the ESP_AT_PROJECT_PLATFORM ?= PLATFORM_ESP8848 in the Makefile in Step 2, then the
lib should be named as libesp8848_at_core.a.
5.10.1 Overview
SDIO AT is based on ESP32 AT, using SDIO, instead of UART, to communicate with host MCU. The ESP32 SDIO
AT runs as an SDIO slave.SDIO communication needs at least 4 pins: CMD, CLK, DAT0, DAT1;
• for one line mode, DAT1 runs as the interrupt pin;
• for four lines mode, two more pins (DAT2 and DAT3) are needed.
SDIO SLAVE pins is as below:
• CLK is GPIO14
• CMD is GPIO15
• DAT0 is GPIO2
• DAT1 is GPIO4
• DAT2 is GPIO12 (for four lines mode only)
• DAT3 is GPIO13 (for four lines mode only)
ESP-SDIO-TESTBOARD-V1
SDIO HOST
SDIO SLAVE
When SDIO slave receives data from SDIO host, the slave will inform the AT core and give the data to the AT core to
handle. After the AT core finished the work, the slave will send data to the host as feedback.
1. Initialize SDIO Slave
• Call sdio_slave_initialize to initialize SDIO slave driver
• Call sdio_slave_recv_register_buf to register receiving buffer. To make it receive data faster,
you can register multiple buffers.
This document mainly introduces the implementation and use of SPI AT, mainly involving the following aspects:
• Overview
• How to Use SPI AT?
• SPI AT Throughput
Note: This document mainly introduces the implementation and use of SPI AT for ESP32-C and ESP32-S series. For
ESP32 series, please refer to ESP32 SPI AT.
5.11.1 Overview
SPI AT is based on ESP-AT project and uses SPI protocol for data communication. When SPI AT is used, MCU
works as SPI master and ESP AT device works as SPI slave. Both sides of communication exchange data based on AT
command through SPI protocol.
ESP-AT project uses UART protocol for data communication by default, but UART protocol is not applicable in some
application scenarios that need high-speed data transmission. In this case, the SPI protocol which supports a higher
transmission rate is a better choice.
You can configure and enable SPI AT through the following steps:
1. ./build.py menuconfig -> Component config -> AT -> communicate method for AT
command -> AT through HSPI to enable SPI AT.
2. ./build.py menuconfig -> Component config -> AT -> communicate method for AT
command -> AT SPI Data Transmission Mode to choose the SPI data transmission mode.
3. ./build.py menuconfig -> Component config -> AT -> communicate method for AT
command -> AT SPI GPIO settings to change the default pin assignments for SPI AT.
4. ./build.py menuconfig -> Component config -> AT -> communicate method for AT
command -> AT SPI driver settings to choose the SPI slave mode, and config the buffer size for
data transmission.
5. Recompile the esp-at project(see Build Your Own ESP-AT Project), download AT bin into flash.
Note 1: QUADWP and QUADHD signals are only used for 4-bit (qio/qout) transactions.
You can change the default pin assignments by ./build.py menuconfig > Component config > AT >
communicate method for AT command > AT through HSPI > AT SPI GPIO settings and com-
pile the project (see Build Your Own ESP-AT Project).
When SPI AT is usedESP device works in SPI half-duplex mode as a slave. Usually, when SPI protocol works in
half-duplex mode, it is the SPI master that starts the read/write operation. However, when AT command is used for
data interaction, ESP device (slave) is required to actively report some information. Therefore, we add a handshake
line between SPI master and slave to realize the purpose. The specific methods of using handshake line are as follows:
• When master sends AT commands to slave via SPI, the workflow with an extra handshake line is as follows:
1. The master sends a request for data transmission to the slave, and then waits for the signal sent by the slave
to the handshake line to allow data transmission.
2. After the master detects the permission signal sent by the slave on the handshake line, it starts to send data.
3. After sending the data, the master notifies slave that the data transmission is finished.
• When slave sends AT responses to master via SPI, the workflow with an extra handshake line is as follows:
1. The slave sends a signal through the handshake line to inform the master to start receiving data.
2. The master receives data and notifies slave that the data transmission is finished after receiving all data.
Communication Formats
The communication format used by SPI AT is CMD+ADDR+DUMMY+DATA (Read or Write). When using SPI AT,
some communication messages used by SPI master are described as follows:
• The message used by the master to send data to slave:
• The message used by the master to inform the slave all data has been sent:
• The message used by the master to receive data from the slave:
• The message used by the master to inform the slave all data has been received:
The 4-byte length data_info contains the information about the packet to be sent. The specific format is as follows:
1. 0~15 bits: the length of the data that the master want to send to the slave.
2. 16~23 bits: the sequence number of the packet sent by the master to the slave.
3. 24~31 bits: the magic num, and default value is 0xFE.
• After receiving the signal from the handshake line, the master can send the message to query the read or write
status of the slave:
After sending the query request, the slave’s status returned will be stored in the 4-byte length slave_status, the
specific format is as follows:
1. 0~15 bits: the length of the data the slave want to sent to the master. This field is valid only when the slave is
readable.
2. 16~23 bits: the sequence number of the packet to been sent. The maximum sequence number is 0xFF, and if the
number is reached, the sequence number is incremented by 1 from 0.
3. 24~31 bits: the slave status(readable/writable).
SPI AT Workflow
A code example of SPI AT master can be found under the directory AT ESP32 SPI Master Example.
• An ESP32-DevKitC development board is been used as SPI master. The application runs in the board can be
found under the directory at_spi_master/spi/esp32_c_series of the ESP-AT project. Some related configurations
are described below:
1. Hardware configuration: The frequency of CPU is 240 MHzflash SPI mode is in QIO mode with 40 MHz.
2. Software configuration: The ESP-IDF version is v4.3. The size of streambuffer is 8192 bytes.
• An ESP32-C3-DevKitC development board is been used as SPI slave. Please refer to Build Your Own ESP-AT
Project to build your own ESP-AT project and flash the generated binary files into the board. The board works
in the TCP passthrough mode, and some related configurations are described below:
1. Hardware configuration: The frequency of CPU is 160 MHz.
2. Software configuration: The size of streambuffer is 8192 bytes, the sdkconfig is sdkconfig.defaults.esp32c3.
Reference Results
The table below shows the throughput results we got in a shield box.
Note 1: When SPI clock frequency is high, due to the limitation of upper network components, the communication
rate of Dual or Quad mode is not significantly improved compared with Standard mode.
Note 2: For more information about SPI communication, please refer to the Technical Reference Manuals.
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 http://iot.espressif.cn. If using SSL OTA, it should be https://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.
4. A key is generated when the device is successfully created, as the figure below shows.
5. Use the key to compile your own OTA BIN. The process of configuring the AT OTA token key is as follows:
Note: If using SSL OTA, the option “OTA based upon ssl” should be selected.
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.
7. Click on the ota.bin to save it as the current version.
8. Run the command AT+CIUPDATE on the ESP device. If the network is connected, OTA update will be done.
The esp-at project supports two platforms by default, ESP32 UART AT and ESP8266 UART AT. Each of the platform
has a set of configurations, you can configure its directory by setting the ESP_AT_MODULE_CONFIG_DIR in the
Makefile. The default directory of ESP32 UART AT is module_config/module_esp32_default, and
the ESP8266 UART AT is module_config/module_esp8266_default, version information is in the file
IDF_VERSION. For example, the version info of module_esp32_default is:
branch:master
commit:7fa98593bc179ea50a1bc8244d5b94bac59c9a10
repository:https://github.com/espressif/esp-idf.git
branch: branch of the idfcommit: commit id of the idfrepository: url of the idf
To update the idf/SDK, you need to change the branch, commit and repository to be the ones that you want to update
to.
It is suggested that you can delete the original idf/SDK after updating the file IDF_VERSION. In this case, the
esp-at will clone the new idf/SDK according to the file IDF_VERSION firstly in next compilation.
Notice: If you changed the repository url in the file IDF_VERSION, then you have to delete the original idf/SDK
in the project. Otherwise, the update may fail.
Since the esp-at project supports different module, for example, WROOM-32, WROVER-32, ESP8266_1MB, even
supports WROOM-5V2L, when compiling the esp-at project, users can set different configurations to generate AT
firmware for different ESP modules. The detailed information are in the esp-at/module_config directory.In
order to facilitate customers to understand the differences between different modules of the same platform, they will
be summarized in the following list.
2. Hardware differences
3. AT pin
See: https://docs.espressif.com/projects/esp-at/en/latest/AT_Binary_Lists/index.html
2. Hardware differences
3. AT pin
See: https://docs.espressif.com/projects/esp-at/en/latest/AT_Binary_Lists/index.html
2. Hardware differences
3. AT pin
See: https://docs.espressif.com/projects/esp-at/en/latest/AT_Binary_Lists/index.html
2. Hardware differences
3. AT pin
See: https://docs.espressif.com/projects/esp-at/en/latest/AT_Binary_Lists/index.html
• at/include/esp_at_core.h
5.15.2 Functions
Parameters
• netconn_max: the maximum number of the link in the at module
• custom_version: version information by custom
Return
• ESP_AT_PARA_PARSE_RESULT_OK : succeed
• ESP_AT_PARA_PARSE_RESULT_FAIL : fail
• ESP_AT_PARA_PARSE_RESULT_OMITTED : this parameter is OMITTED
Parameters
• para_index: the index of parameter
• value: the value parsed
Return
• ESP_AT_PARA_PARSE_RESULT_OK : succeed
• ESP_AT_PARA_PARSE_RESULT_FAIL : fail
• ESP_AT_PARA_PARSE_RESULT_OMITTED : this parameter is OMITTED
Parameters
• para_index: the index of parameter
• result: the pointer that point to the result.
Parameters
• len: data length
Return
• true : succeed
• false : fail
Parameters
• len: data length
• msec: timeout time,The unit is millisecond. It waits forever,if msec is portMAX_DELAY.
void esp_at_transmit_terminal_from_isr(void)
terminal transparent transmit mode,This function MUST be used in isr.
void esp_at_transmit_terminal(void)
terminal transparent transmit mode,This function MUST NOT be used in isr.
bool esp_at_custom_cmd_array_regist(const esp_at_cmd_struct *custom_at_cmd_array,
uint32_t cmd_num)
regist at command set, which defined by custom,
Parameters
• custom_at_cmd_array: at command set
• cmd_num: command number
Parameters
• ops: device operate functions set
Parameters
• ops: custom operate functions set
uint32_t esp_at_get_version(void)
get at module version number,
Return at version bit31~bit24: at main version bit23~bit16: at sub version bit15~bit8 : at test version bit7~bit0
: at custom version
Parameters
• result_code: see esp_at_result_code_string_index
Return
• >= 0 : the real length of the data written
• others : fail.
Parameters
• data: data buffer to be written
• len: data length
Return
• >= 0 : the real length of the data read from device
• others : fail
Parameters
• data: data buffer
• len: data length
Return
• true : succeed,transmit data completely
• false : fail
Parameters
• timeout_msec: timeout time,The unit is millisecond.
int32_t esp_at_port_get_data_length(void)
get the length of the data received,
Return
• >= 0 : the length of the data received
• others : fail
bool esp_at_base_cmd_regist(void)
regist at base command set. If not,you can not use AT base command
bool esp_at_user_cmd_regist(void)
regist at user command set. If not,you can not use AT user command
bool esp_at_wifi_cmd_regist(void)
regist at wifi command set. If not,you can not use AT wifi command
bool esp_at_net_cmd_regist(void)
regist at net command set. If not,you can not use AT net command
bool esp_at_mdns_cmd_regist(void)
regist at mdns command set. If not,you can not use AT mdns command
bool esp_at_driver_cmd_regist(void)
regist at driver command set. If not,you can not use AT driver command
bool esp_at_wps_cmd_regist(void)
regist at wps command set. If not,you can not use AT wps command
bool esp_at_smartconfig_cmd_regist(void)
regist at smartconfig command set. If not,you can not use AT smartconfig command
bool esp_at_ping_cmd_regist(void)
regist at ping command set. If not,you can not use AT ping command
bool esp_at_http_cmd_regist(void)
regist at http command set. If not,you can not use AT http command
bool esp_at_mqtt_cmd_regist(void)
regist at mqtt command set. If not,you can not use AT mqtt command
bool esp_at_ble_cmd_regist(void)
regist at ble command set. If not,you can not use AT ble command
bool esp_at_ble_hid_cmd_regist(void)
regist at ble hid command set. If not,you can not use AT ble hid command
bool esp_at_blufi_cmd_regist(void)
regist at blufi command set. If not,you can not use AT blufi command
bool esp_at_bt_cmd_regist(void)
regist at bt command set. If not,you can not use AT bt command
bool esp_at_bt_spp_cmd_regist(void)
regist at bt spp command set. If not,you can not use AT bt spp command
bool esp_at_bt_a2dp_cmd_regist(void)
regist at bt a2dp command set. If not,you can not use AT bt a2dp command
bool esp_at_fs_cmd_regist(void)
regist at fs command set. If not,you can not use AT fs command
bool esp_at_eap_cmd_regist(void)
regist at WPA2 Enterprise AP command set. If not,you can not use AT EAP command
bool esp_at_eth_cmd_regist(void)
regist at ethernet command set. If not,you can not use AT ethernet command
bool esp_at_custom_cmd_line_terminator_set(uint8_t *terminator)
Set AT command terminator, by default, the terminator is “\r\n” You can change it by calling this function, but
it just supports one character now.
Return
• true : succeed,transmit data completely
• false : fail
Parameters
• terminator: the line terminator
uint8_t *esp_at_custom_cmd_line_terminator_get(void)
Get AT command line terminator,by default, the return string is “\r\n”.
Return pointer to esp_partition_t structure, or NULL if no partition is found. This pointer is valid for the
lifetime of the application
Parameters
• type: the type of the partition
• subtype: the subtype of the partition
• label: Partition label
Parameters
• callback: which will be called when received data from AT port
void esp_at_port_exit_specific(void)
Exit AT core as specific status.
const uint8_t *esp_at_get_current_cmd_name(void)
Get current AT command name.
esp_err_t esp_at_wifi_event_handler(void *ctx, system_event_t *event)
Wi-Fi event handler callback, which used in AT core.
Return
• ESP_OK: succeed
• others: fail
Parameters
• ctx: reserved for user
• event: event type defined in this file
5.15.3 Structures
struct esp_at_cmd_struct
esp_at_cmd_struct used for define at command
Public Members
char *at_cmdName
at command name
uint8_t (*at_testCmd)(uint8_t *cmd_name)
Test Command function pointer
uint8_t (*at_queryCmd)(uint8_t *cmd_name)
Query Command function pointer
Public Members
Public Members
Public Members
Public Members
5.15.4 Macros
ESP_AT_ERROR_NO(subcategory, extension)
ESP_AT_CMD_ERROR_OK
No Error
ESP_AT_CMD_ERROR_NON_FINISH
terminator character not found (“\r\n” expected)
ESP_AT_CMD_ERROR_NOT_FOUND_AT
Starting “AT” not found (or at, At or aT entered)
ESP_AT_CMD_ERROR_PARA_LENGTH(which_para)
parameter length mismatch
ESP_AT_CMD_ERROR_PARA_TYPE(which_para)
parameter type mismatch
ESP_AT_CMD_ERROR_PARA_NUM(need, given)
parameter number mismatch
ESP_AT_CMD_ERROR_PARA_INVALID(which_para)
the parameter is invalid
ESP_AT_CMD_ERROR_PARA_PARSE_FAIL(which_para)
parse parameter fail
ESP_AT_CMD_ERROR_CMD_UNSUPPORT
the command is not supported
ESP_AT_CMD_ERROR_CMD_EXEC_FAIL(result)
the command execution failed
ESP_AT_CMD_ERROR_CMD_PROCESSING
processing of previous command is in progress
ESP_AT_CMD_ERROR_CMD_OP_ERROR
the command operation type is error
5.15.6 Enumerations
enum esp_at_status_type
esp_at_status some custom function interacting with AT
Values:
ESP_AT_STATUS_NORMAL = 0x0
Normal mode.Now mcu can send AT command
ESP_AT_STATUS_TRANSMIT
Transparent Transmition mode
enum esp_at_module
module number,Now just AT module
Values:
ESP_AT_MODULE_NUM = 0x01
AT module
enum esp_at_error_code
subcategory number
Values:
ESP_AT_SUB_OK = 0x00
OK
ESP_AT_SUB_COMMON_ERROR = 0x01
reserved
ESP_AT_SUB_NO_TERMINATOR = 0x02
terminator character not found (“\r\n” expected)
ESP_AT_SUB_NO_AT = 0x03
Starting “AT” not found (or at, At or aT entered)
ESP_AT_SUB_PARA_LENGTH_MISMATCH = 0x04
parameter length mismatch
ESP_AT_SUB_PARA_TYPE_MISMATCH = 0x05
parameter type mismatch
ESP_AT_SUB_PARA_NUM_MISMATCH = 0x06
parameter number mismatch
ESP_AT_SUB_PARA_INVALID = 0x07
the parameter is invalid
ESP_AT_SUB_PARA_PARSE_FAIL = 0x08
parse parameter fail
ESP_AT_SUB_UNSUPPORT_CMD = 0x09
the command is not supported
ESP_AT_SUB_CMD_EXEC_FAIL = 0x0A
the command execution failed
ESP_AT_SUB_CMD_PROCESSING = 0x0B
processing of previous command is in progress
ESP_AT_SUB_CMD_OP_ERROR = 0x0C
the command operation type is error
enum esp_at_para_parse_result_type
the result of AT parse
Values:
ESP_AT_PARA_PARSE_RESULT_FAIL = -1
parse fail,Maybe the type of parameter is mismatched,or out of range
ESP_AT_PARA_PARSE_RESULT_OK = 0
Successful
ESP_AT_PARA_PARSE_RESULT_OMITTED
the parameter is OMITTED.
enum esp_at_result_code_string_index
the result code of AT command processing
Values:
ESP_AT_RESULT_CODE_OK = 0x00
“OK”
ESP_AT_RESULT_CODE_ERROR = 0x01
“ERROR”
ESP_AT_RESULT_CODE_FAIL = 0x02
“ERROR”
ESP_AT_RESULT_CODE_SEND_OK = 0x03
“SEND OK”
ESP_AT_RESULT_CODE_SEND_FAIL = 0x04
“SEND FAIL”
ESP_AT_RESULT_CODE_IGNORE = 0x05
response nothing, just change internal status
ESP_AT_RESULT_CODE_PROCESS_DONE = 0x06
response nothing, just change internal status
ESP_AT_RESULT_CODE_MAX
• at/include/esp_at.h
5.15.8 Functions
bool esp_at_web_server_cmd_regist(void)
regist WiFi config via web command. If not,you can not use web server to config wifi connect
5.15.9 Macros
ESP_AT_PORT_TX_WAIT_MS_MAX
ESP_AT_FACTORY_PARAMETER_SIZE
Please refer to [Chinese version]. The English version is not provided since the firmware and commands are applicable
to the Chinese market (Tencent).
ESP8266
• ESP8266-WROOM-02 Series
– QCloud_AT_ESP8266_v2.2.0
– QCloud_AT_ESP8266_v2.1.1
311
ESP-AT User Guide
Index of Abbreviations
313
ESP-AT User Guide
315
ESP-AT User Guide
317
ESP-AT User Guide
esp_at_custom_net_ops_struct::recv_data 308
(C++ member), 306 esp_at_ping_cmd_regist (C++ function), 303
esp_at_custom_ops_regist (C++ function), 302 esp_at_port_enter_specific (C++ function),
esp_at_custom_ops_struct (C++ class), 306 304
esp_at_port_exit_specific (C++ function),
esp_at_custom_ops_struct::pre_deepsleep_callback
(C++ member), 307 305
esp_at_port_get_data_length (C++ function),
esp_at_custom_ops_struct::pre_restart_callback
(C++ member), 307 303
esp_at_custom_ops_struct::status_callback esp_at_port_read_data (C++ function), 302
(C++ member), 307 esp_at_port_recv_data_notify (C++ func-
esp_at_custom_partition_find (C++ func- tion), 301
tion), 304 esp_at_port_recv_data_notify_from_isr
esp_at_device_ops_regist (C++ function), 302 (C++ function), 301
esp_at_device_ops_struct (C++ class), 306 esp_at_port_specific_callback_t (C++
esp_at_device_ops_struct::get_data_length type), 307
(C++ member), 306 ESP_AT_PORT_TX_WAIT_MS_MAX (C macro), 310
esp_at_device_ops_struct::read_data esp_at_port_wait_write_complete (C++
(C++ member), 306 function), 303
esp_at_device_ops_struct::wait_write_completeesp_at_port_write_data (C++ function), 302
(C++ member), 306 esp_at_response_result (C++ function), 302
esp_at_device_ops_struct::write_data ESP_AT_RESULT_CODE_ERROR (C++ enumerator),
(C++ member), 306 309
esp_at_driver_cmd_regist (C++ function), 303 ESP_AT_RESULT_CODE_FAIL (C++ enumerator),
esp_at_eap_cmd_regist (C++ function), 304 309
esp_at_error_code (C++ type), 308 ESP_AT_RESULT_CODE_IGNORE (C++ enumerator),
ESP_AT_ERROR_NO (C macro), 307 309
esp_at_eth_cmd_regist (C++ function), 304 ESP_AT_RESULT_CODE_MAX (C++ enumerator), 309
ESP_AT_FACTORY_PARAMETER_SIZE (C macro), ESP_AT_RESULT_CODE_OK (C++ enumerator), 309
310 ESP_AT_RESULT_CODE_PROCESS_DONE (C++
esp_at_fs_cmd_regist (C++ function), 304 enumerator), 309
esp_at_get_current_cmd_name (C++ function), ESP_AT_RESULT_CODE_SEND_FAIL (C++ enumer-
305 ator), 309
esp_at_get_current_module_name (C++ func- ESP_AT_RESULT_CODE_SEND_OK (C++ enumera-
tion), 309 tor), 309
esp_at_get_module_id (C++ function), 309 esp_at_result_code_string_index (C++
esp_at_get_module_name_by_id (C++ func- type), 309
tion), 309 esp_at_smartconfig_cmd_regist (C++ func-
esp_at_get_para_as_digit (C++ function), 300 tion), 303
esp_at_get_para_as_str (C++ function), 301 ESP_AT_STATUS_NORMAL (C++ enumerator), 308
esp_at_get_version (C++ function), 302 ESP_AT_STATUS_TRANSMIT (C++ enumerator), 308
esp_at_http_cmd_regist (C++ function), 303 esp_at_status_type (C++ type), 308
esp_at_mdns_cmd_regist (C++ function), 303 ESP_AT_SUB_CMD_EXEC_FAIL (C++ enumerator),
esp_at_module (C++ type), 308 308
esp_at_module_init (C++ function), 300 ESP_AT_SUB_CMD_OP_ERROR (C++ enumerator),
ESP_AT_MODULE_NUM (C++ enumerator), 308 308
esp_at_mqtt_cmd_regist (C++ function), 303 ESP_AT_SUB_CMD_PROCESSING (C++ enumerator),
esp_at_net_cmd_regist (C++ function), 303 308
ESP_AT_PARA_PARSE_RESULT_FAIL (C++ enu- ESP_AT_SUB_COMMON_ERROR (C++ enumerator),
merator), 309 308
ESP_AT_PARA_PARSE_RESULT_OK (C++ enumera- ESP_AT_SUB_NO_AT (C++ enumerator), 308
tor), 309 ESP_AT_SUB_NO_TERMINATOR (C++ enumerator),
ESP_AT_PARA_PARSE_RESULT_OMITTED (C++ 308
enumerator), 309 ESP_AT_SUB_OK (C++ enumerator), 308
esp_at_para_parse_result_type (C++ type), ESP_AT_SUB_PARA_INVALID (C++ enumerator),
318 Index
ESP-AT User Guide
L
LWT, 313
M
MAC, 314
mDNS, 314
MSB, 314
MTU, 314
N
Normal Transmission Mode, 314
NVS, 314
P
Passthrough Mode, 314
Passthrough Receiving Mode, 315
PBC, 315
PCI Authentication, 315
PLCP, 315
PMF, 315
PSK, 315
Index 319