### ESP32 Bluetooth Initialization and Discovery Example Source: https://docs.espressif.com/projects/esp-at/en/latest/esp32/AT_Command_Set/BT_AT_Commands This example demonstrates initializing the Bluetooth module, setting the scan mode, and starting a Bluetooth discovery process with specific parameters. ```text AT+BTINIT=1 AT+BTSCANMODE=2 AT+BTSTARTDISC=0,10,10 ``` -------------------------------- ### Example ESP32 AT Commands for Starting BLE Advertising Source: https://docs.espressif.com/projects/esp-at/en/latest/esp32/AT_Command_Set/BLE_AT_Commands Shows the basic sequence to initialize the ESP32 as a BLE server and then start the advertising process using default parameters if not previously set. ```AT Command AT+BLEINIT=2 // Role: server AT+BLEADVSTART ``` -------------------------------- ### Advertising Setup (ESP32 Bluetooth LE Server) Source: https://docs.espressif.com/projects/esp-at/en/latest/esp32/AT_Command_Examples/bluetooth_le_at_examples Configures and starts advertising for the ESP32 Bluetooth LE server. This involves setting advertising parameters and data, allowing clients to discover the server. ```AT Commands AT+BLEADDR? +BLEADDR:"24:0a:c4:d6:e4:46" OK AT+BLEADVPARAM=50,50,0,0,7,0,, OK AT+BLEADVDATA="0201060A09457370726573736966030302A0" OK AT+BLEADVSTART OK ``` -------------------------------- ### BluFi Provisioning API Source: https://docs.espressif.com/projects/esp-at/en/latest/esp32/AT_Command_Examples/network_provisioning_examples This section details the steps and AT commands for configuring and using BluFi provisioning, which utilizes a Bluetooth channel for Wi-Fi setup. ```APIDOC ## AT+BLUFINAME Set BluFi Name ### Description Sets the name for the BluFi service on the ESP32 device. ### Method AT Command ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ``` AT+BLUFINAME="blufi_test" ``` ### Response #### Success Response (200 OK) - **OK** (string) - Indicates the command was successful. #### Response Example ``` OK ``` ## AT+BLUFI Enable/Disable BluFi ### Description Enables or disables the BluFi feature on the ESP32 device. ### Method AT Command ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ``` AT+BLUFI=1 ``` ### Response #### Success Response (200 OK) - **OK** (string) - Indicates the command was successful. #### Response Example ``` OK ``` ## AT+BLUFISEND Send Custom Data via BluFi ### Description Sends custom user data through the established BluFi connection. ### Method AT Command ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ``` AT+BLUFISEND=4 ``` ### Response #### Success Response (200 OK) - **>** (string) - Prompt to input data. - **OK** (string) - Indicates the data was sent successfully. #### Response Example ``` > OK ``` ## AT+BLUFI Disable BluFi (Implicit Disconnect) ### Description Disables BluFi on the ESP32 device, which also disconnects the current BluFi connection. ### Method AT Command ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ``` AT+BLUFI=0 ``` ### Response #### Success Response (200 OK) - **+BLUFIDISCONN** (string) - Indicates BluFi disconnection. - **OK** (string) - Indicates the command was successful. #### Response Example ``` +BLUFIDISCONN OK ``` ``` -------------------------------- ### HTTP GET Method Example Source: https://docs.espressif.com/projects/esp-at/en/latest/esp32/AT_Command_Examples/http_at_examples This example demonstrates how to download an image file using an HTTP GET request with the AT+HTTPCLIENT command. ```APIDOC ## AT+HTTPCLIENT (GET Method) ### Description Sends an HTTP GET request to a specified URL and downloads content, such as an image file. ### Method AT Command ### Endpoint N/A (Command-based) ### Parameters #### Command Parameters - **opt** (integer) - Required - `2` for GET method. - **connect_id** (integer) - Required - Typically `0`. - **url** (string) - Required - The URL of the file to download. - **transport_type** (integer) - Required - `2` for HTTP_TRANSPORT_OVER_SSL. ### Request Example ``` AT+HTTPCLIENT=2,0,"https://www.espressif.com/sites/all/themes/espressif/images/about-us/solution-platform.jpg",,,2 ``` ### Response #### Success Response - **+HTTPCLIENT** (string) - Contains data chunks of the downloaded file, often represented in hex or with escape sequences. - **OK** #### Response Example ``` +HTTPCLIENT:512,<0xff><0xd8><0xff><0xe2><0x0c>XICC_PROFILE <0x01><0x01> <0x0c>HLino<0x02><0x10> mntrRGB XYZ <0x07><0xce> <0x02> ... +HTTPCLIENT:512,<0xeb><0xe2>v<0xcb><0x98>-<0xf8><0x8a><0xae><0xf3><0xc8><0xb6><0xa8><0x86><0x02>j<0x06><0xe2> "<0xaa>*p<0x7f>2",h<0x12>N<0xa5><0x1e><0xd2>bp<0xea><0x1e><0xf5><0xa3>x<0xa6>J<0x14>Ti<0xc3>m<0x1a>m<0x94>T<0xe1>I<0xb6><0x90><0xdc>_<0x11>QU;<0x94><0x97><0xcb><0xdd><0xc7><0xc6><0x85><0xd7>U<0x02><0xc9>W<0xa4><0xaa><0xa1><0xa1><0x08>hB<0x1a><0x10><0x86><0x84>!<0xa1><0x08>hB<0x1a><0x10><0x9b><0xb9>K<0xf5>5<0x95>5-=<0x8a><0xcb><0xce><0xe0><0x91><0xf0>m<0xa9><0x04>C<0xde>k<0xe7><0xc2>v<0xb8>L<0x91>=<0xda>_<0x94><0xde><0xd0><0xa9><0xc0><0xdd>8<0x9a>B<0xaa><0x1a><0x10><0x86><0x84>$<0xf4><0xd6><0xf2><0xa3><0x92><0xe7><0xa8>I<0xa3>b<0x1f>)<0xe1>z<0xc4>y<0xae><0xca><0xed><0xec><0x1e>|^<0xd7>E<0xa2>_<0x13><0x9e>;{|<0xb5>Q<0x97><0xa5>P<0xdf><0xa1>#3vn<0x1b><0xc3>-<0x92><0xe2>dIn<0x9c><0xb8> <0xc7><0xa9><0xc6>(<0xe0><0xd3>i-<0x9e>@<0xbb><0xcc><0x88><0xd5>K<0xe3><0xf0>O<0x9f>Km<0xb3>h<0xa8>omR<0xfe><0x8b><0xf9><0xa4><0xa6><0xff> aU<0xdf><0xf3><0xa3>:A<0xe2>UG<0x04>k<0xaa>*<0xa1><0xa1><0x0b><0xca><0xec><0xd8>Q<0xfb><0xbc>yqY<0xec><0xfb>?<0x16>CM<0xf6>|}<0xae><0xf3><0x1e><0xdf>%<0xf8><0xe8><0xb1>B<0x8f>[<0xb3>><0x04><0xec><0xeb>f<0x06><0x1c><0xe8><0x92><0xc9><0x8c><0xb0>I<0xd1><0x8b>%<0x99><0x04><0xd0><0xbb>s<0x8b>xj<0xe2>4f<0xa0><0x8e>+E<0xda><0xab><0xc7>=<0xab><0xc7><0xb9>xz1f<0xba><0xfd>_e6<0xff> (w<0xa7>b<0xe3>m<0xf0>|<0x82><0xc9><0xfb><0x8b><0xac>r<0x95><0x94><0x96><0xd9>i<0xe9>RVA<0x91><0x83><0x8b>M'<0x86><0x8f><0xa3>A<0xd8><0xd8>"r"<0x8a><0xa8><0x9e>zl=<0xcd><0x16><0x07>D<0xa2><0xd0>u(<0xc2><0x8b><0x0b><0xc4><0xf1><0x87><0x9c><0x93><0x8f><0xe3><0xd5>U<0x12>]<0x8e><0x91>]<0x91><0x06>#l<0xbe><0xf4>t0?<0xd7><0x85>%<0xee>UUT<0xe7><0xdf><0xa0><0xb9><0xce><0xe2>U@<0x03><0x82>S<0xe9>*<0xa8>hB<0x1a><0x10><0xa1><0xaf>V<0x19>U<0x9d><0xb3>x<0xa6><0xc7><0xe2><0x86><0x8e>d[<0x89>e<0x05>l<0x80>H<0x91>#<0xd2><0x8c><0xe1>j<0x1b>rH<0x04><0x89><0x98><0xd3>lZW]q><0xc2><';<0x93><0xb4><0xf5>&<0x9d><0xa0>^Wp<0xa9>6`<0xe2>T<0xa2><0xc2><0xb1>*<0xbc><0x13><0x13><0xa0><0xc4>)<0x83><0xb6><0xbe><0x86><0xb9><0x88>-<0x1a> OK ``` ``` -------------------------------- ### Start ESP32 Classic Bluetooth SPP Profile Source: https://docs.espressif.com/projects/esp-at/en/latest/esp32/AT_Command_Examples/classic_bluetooth_at_examples Starts the Classic Bluetooth SPP profile, making the ESP32 ready to accept SPP connections initiated by other devices. This command should be issued after initialization and configuration. ```text AT+BTSPPSTART ``` -------------------------------- ### ESP32 Bluetooth LE Initialization and Service Setup (AT Commands) Source: https://docs.espressif.com/projects/esp-at/en/latest/esp32/AT_Command_Examples/bluetooth_le_at_examples This snippet demonstrates the initial AT commands required to set up the ESP32 as a Bluetooth LE server. It includes initializing the Bluetooth LE module, creating a GATT server, and starting the services. These commands prepare the ESP32 to advertise and accept connections. ```AT Commands AT+BLEINIT=2 OK AT+BLEGATTSSRVCRE OK AT+BLEGATTSSRVSTART OK ``` -------------------------------- ### Service Creation and Start (ESP32) Source: https://docs.espressif.com/projects/esp-at/en/latest/esp32/AT_Command_Examples/bluetooth_le_at_examples On the server side, this creates and starts the GATT services. The client also performs service creation and starting, typically to register its own services. ```AT Commands ESP32 Bluetooth LE server: AT+BLEGATTSSRVCRE OK AT+BLEGATTSSRVSTART OK ESP32 Bluetooth LE client: AT+BLEGATTSSRVCRE OK AT+BLEGATTSSRVSTART OK ``` -------------------------------- ### ESP-AT Project Build and Configuration Example (Linux/macOS) Source: https://docs.espressif.com/projects/esp-at/en/latest/esp32/Compile_and_Develop/How_to_clone_project_and_compile_it Demonstrates the interactive process of installing the ESP-AT project environment on Linux/macOS, including selecting platform, module, and silence mode, followed by the build command. ```bash $ ./build.py install Ready to install ESP-IDF prerequisites.. ... (more lines of install ESP-IDF prerequisites) Ready to install ESP-AT prerequisites.. ... (more lines of install ESP-IDF prerequisites) Platform name: 1. PLATFORM_ESP32 ... choose(range[1,7]):1 Module name: 1. WROOM-32 (Firmware description: ...) ... choose(range[1,7]):1 Enable silence mode to remove some logs and reduce the firmware size? 0. No 1. Yes choose(range[0,1]):1 Platform name:ESP32 Module name:WROOM-32 Silence:1 Cloning into 'esp-idf'... ... (more lines of clone esp-idf) Ready to set up ESP-IDF tools.. ... (more lines of set up ESP-IDF tools) All done! You can now run: ./build.py build ``` -------------------------------- ### ESP32 AT: HTTP PUT with Query Parameters Source: https://docs.espressif.com/projects/esp-at/en/latest/esp32/AT_Command_Examples/http_at_examples Illustrates how to send an HTTP PUT request using the AT+HTTPCLIENT command. This example shows how to include query string parameters in the URL for a PUT request. It covers basic Wi-Fi setup before executing the PUT command. ```AT Command AT+RESTORE AT+CWMODE=1 AT+CWJAP="espressif","1234567890" AT+HTTPCLIENT=4,0,"http://httpbin.org/put?user=foo",,,1 ``` -------------------------------- ### ESP32 Bluetooth LE Server: Create and Start Services Source: https://docs.espressif.com/projects/esp-at/en/latest/esp32/AT_Command_Examples/bluetooth_le_at_examples Commands for the ESP32 Bluetooth LE server to create and start its GATT services. ```APIDOC ## ESP32 Bluetooth LE Server: Create and Start Services ### Description These commands are executed on the ESP32 acting as the Bluetooth LE server. `AT+BLEGATTSSRVCRE` creates the GATT services, and `AT+BLEGATTSSRVSTART` starts them, making them discoverable by clients. ### Method AT Command ### Parameters #### Query Parameters - **`AT+BLEGATTSSRVCRE`** - No parameters. Creates default GATT services. - **`AT+BLEGATTSSRVSTART`** - No parameters. Starts the GATT server services. ### Request Example *Server: `AT+BLEGATTSSRVCRE`* *Server: `AT+BLEGATTSSRVSTART`* ### Response #### Success Response (200) - **`OK`** - Indicates successful execution of the command. #### Response Example ``` OK ``` ``` -------------------------------- ### Bluetooth LE GATT Service Start Source: https://docs.espressif.com/projects/esp-at/en/latest/esp32/AT_Command_Examples/bluetooth_le_at_examples Starts the previously created GATT service, making it available for clients to connect to and interact with. ```APIDOC ## AT+BLEGATTSSRVSTART ### Description Starts the GATT service on the ESP32. ### Method AT Command ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ``` AT+BLEGATTSSRVSTART ``` ### Response #### Success Response (200) - **OK** (string) - Indicates successful service start. #### Response Example ``` OK ``` ``` -------------------------------- ### HTTP HEAD Method Example Source: https://docs.espressif.com/projects/esp-at/en/latest/esp32/AT_Command_Examples/http_at_examples This example demonstrates how to send an HTTP HEAD request using the AT+HTTPCLIENT command. ```APIDOC ## AT+HTTPCLIENT (HEAD Method) ### Description Sends an HTTP HEAD request to a specified URL. ### Method AT Command ### Endpoint N/A (Command-based) ### Parameters #### Command Parameters - **opt** (integer) - Required - `1` for HEAD method. - **connect_id** (integer) - Required - Typically `0`. - **url** (string) - Required - The URL to send the request to. - **transport_type** (integer) - Required - `1` for HTTP_TRANSPORT_OVER_TCP. ### Request Example ``` AT+HTTPCLIENT=1,0,"http://httpbin.org/get",,,1 ``` ### Response #### Success Response - **+HTTPCLIENT** (string) - Contains header information. - **OK** #### Response Example ``` +HTTPCLIENT:35, Date: Sun, 26 Sep 2021 06:59:13 GMT +HTTPCLIENT:30, Content-Type: application/json +HTTPCLIENT:19, Content-Length: 329 +HTTPCLIENT:22, Connection: keep-alive +HTTPCLIENT:23, Server: gunicorn/19.9.0 +HTTPCLIENT:30, Access-Control-Allow-Origin: * +HTTPCLIENT:38, Access-Control-Allow-Credentials: true OK ``` ``` -------------------------------- ### Configure ESP32 for Wi-Fi Provisioning via AT Commands Source: https://docs.espressif.com/projects/esp-at/en/latest/esp32/AT_Command_Examples/Web_server_AT_Examples This sequence of AT commands configures the ESP32 to act as a SoftAP, create a web server on port 80, and enable multiple client connections. This setup allows STA devices to connect to the ESP32's SoftAP and provision Wi-Fi credentials through a web browser. Ensure the default firmware supports web server AT commands; otherwise, enable them first. ```AT Commands AT+RESTORE AT+CWMODE=3 AT+CWSAP="pos_softap","",11,0,3 AT+CIPMUX=1 AT+WEBSERVER=1,80,25 ``` -------------------------------- ### Example AT+CIUPDATE Commands for OTA Upgrade Source: https://docs.espressif.com/projects/esp-at/en/latest/esp32/AT_Command_Set/TCP-IP_AT_Commands Provides a series of example AT commands demonstrating various configurations for initiating an OTA firmware upgrade using the AT+CIUPDATE command. These examples cover different scenarios, including basic upgrades, specifying OTA modes, versions, and non-blocking behavior. ```AT Commands AT+CWMODE=1 AT+CWJAP="1234567890","1234567890" AT+CIUPDATE AT+CIUPDATE=1 AT+CIUPDATE=1,"v1.2.0.0" AT+CIUPDATE=1,"v2.2.0.0","mqtt_ca" AT+CIUPDATE=1,"v2.2.0.0","ota",1 AT+CIUPDATE=1,,,1 AT+CIUPDATE=1,,"ota",1 AT+CIUPDATE=1,"v2.2.0.0",,1 ``` -------------------------------- ### Start Bluetooth LE Server Services (AT Commands) Source: https://docs.espressif.com/projects/esp-at/en/latest/esp32/AT_Command_Examples/bluetooth_le_at_examples Starts the previously created GATT services on the ESP32 Bluetooth Low Energy (LE) server, making them available for clients to discover and connect to. ```AT Commands AT+BLEGATTSSRVSTART ``` -------------------------------- ### Example System Prompt Configuration (AT+SYSMSG) Source: https://docs.espressif.com/projects/esp-at/en/latest/esp32/AT_Command_Set/Basic_AT_Commands Provides examples of configuring system prompt information using the AT+SYSMSG command. These examples demonstrate setting different combinations of prompt behaviors for quitting modes and connection status changes. ```plaintext // print no prompt info when quitting Wi-Fi passthrough mode // print detailed connection prompt info // print no prompt info when the connection status is changed AT+SYSMSG=2 ``` ```plaintext // In the transparent transmission mode, a prompt message will be printed when the Wi-Fi, socket, Bluetooth LE or Bluetooth status changes AT+SYSMSG=4 ``` -------------------------------- ### Install ESP-AT Environment on Windows Source: https://docs.espressif.com/projects/esp-at/en/latest/esp32/Compile_and_Develop/How_to_clone_project_and_compile_it Installs the necessary environment for compiling ESP-AT projects on Windows. It uses the `build.py` script with Python to automate the installation of Python packages, ESP-IDF, and required tools. ```python python build.py install ``` -------------------------------- ### Download Picture via HTTP using AT Command Source: https://docs.espressif.com/projects/esp-at/en/latest/esp32/AT_Command_Examples/at_msg_resp_fmt_ctrl_examples Initiates an HTTP GET request to download a file from a specified URL. It configures buffer sizes and a network timeout. The MCU transparently receives the downloaded content. The response indicates the start of data reception and may include error messages if the download fails. ```AT Command AT+HTTPCGET="https://www.espressif.com/sites/default/files/home/hardware.png",2048,2048,5000 ``` ```AT Response // Here, the MCU transparently receives the entire picture resource from https://www.espressif.com/sites/default/files/home/hardware.png. ``` -------------------------------- ### Configure MQTT User (Publisher) Source: https://docs.espressif.com/projects/esp-at/en/latest/esp32/AT_Command_Examples/MQTT_AT_Examples Sets up user credentials for the MQTT publisher. Requires the AT command set for ESP32. No specific input/output dependencies beyond the AT command syntax. ```AT Command AT+MQTTUSERCFG=0,1,"publisher","espressif","123456789",0,0,"" ``` -------------------------------- ### ESP32 AT Commands: Send HTTP GET Request Source: https://docs.espressif.com/projects/esp-at/en/latest/esp32/AT_Command_Examples/http_at_examples Sends an HTTP GET request to download a resource from a specified URL. This command is used for retrieving content, such as images or files. It requires parameters for the request type, URL, and transport protocol. ```text AT+HTTPCLIENT=2,0,"https://www.espressif.com/sites/all/themes/espressif/images/about-us/solution-platform.jpg",,,2 +HTTPCLIENT:512,<0xff><0xd8><0xff><0xe2><0x0c>XICC_PROFILE <0x01><0x01> <0x0c>HLino<0x02><0x10> mntrRGB XYZ <0x07><0xce> <0x02> ... +HTTPCLIENT:512,<0xeb><0xe2>v<0xcb><0x98>-<0xf8><0x8a><0xae><0xf3><0xc8><0xb6><0xa8><0x86><0x02>j<0x06><0xe2> "<0xaa>*p<0x7f>2",h<0x12>N<0xa5><0x1e><0xd2>bp<0xea><0x1e><0xf5><0xa3>x<0xa6>J<0x14>Ti<0xc3>m<0x1a>m<0x94>T<0xe1>I<0xb6><0x90><0xdc>_<0x11>QU;<0x94><0x97><0xcb><0xdd><0xc7><0xc6><0x85><0xd7>U<0x02><0xc9>W<0xa4><0xaa><0xa1><0xa1><0x08>hB<0x1a><0x10><0x86><0x84>!<0xa1><0x08>hB<0x1a><0x10><0x9b><0xb9>K<0xf5>5<0x95>5-=<0x8a><0xcb><0xce><0xe0><0x91><0xf0>m<0xa9><0x04>C<0xde>k<0xe7><0xc2>v<0xb8>L<0x91>=<0xda>_<0x94><0xde><0xd0><0xa9><0xc0><0xdd>8<0x9a>B<0xaa><0x1a><0x10><0x86><0x84>$<0xf4><0xd6><0xf2><0xa3><0x92><0xe7><0xa8>I<0xa3>b<0x1f>)<0xe1>z<0xc4>y<0xae><0xca><0xed><0xec><0x1e>|^<0xd7>E<0xa2>_<0x13><0x9e>;{|<0xb5>Q<0x97><0xa5>P<0xdf><0xa1>#3vn<0x1b><0xc3>-<0x92><0xe2>dIn<0x9c><0xb8> <0xc7><0xa9><0xc6>(<0xe0><0xd3>i-<0x9e>@<0xbb><0xcc><0x88><0xd5>K<0xe3><0xf0>O<0x9f>Km<0xb3>h<0xa8>omR<0xfe><0x8b><0xf9><0xa4><0xa6><0xff> aU<0xdf><0xf3><0xa3>:A<0xe2>UG<0x04>k<0xaa>*<0xa1><0xa1><0x0b><0xca><0xec><0xd8>Q<0xfb><0xbc>yqY<0xec><0xfb>?<0x16>CM<0xf6>|}<0xae><0xf3><0x1e><0xdf>%<0xf8><0xe8><0xb1>B<0x8f>[<0xb3>><0x04><0xec><0xeb>f<0x06><0x1c><0xe8><0x92><0xc9><0x8c><0xb0>I<0xd1><0x8b>%<0x99><0x04><0xd0><0xbb>s<0x8b>xj<0xe2>4f<0xa0><0x8e>+E<0xda><0xab><0xc7>=<0xab><0xc7><0xb9>xz1f<0xba><0xfd>_e6<0xff> (w<0xa7>b<0xe3>m<0xf0>|<0x82><0xc9><0xfb><0x8b><0xac>r<0x95><0x94><0x96><0xd9>i<0xe9>RVA<0x91><0x83><0x8b>M'<0x86><0x8f><0xa3>A<0xd8><0xd8>"r"<0x8a><0xa8><0x9e>zl=<0xcd><0x16><0x07>D<0xa2><0xd0>u(<0xc2><0x8b><0x0b><0xc4><0xf1><0x87><0x9c><0x93><0x8f><0xe3><0xd5>U<0x12>]<0x8e><0x91>]<0x91><0x06>#l<0xbe><0xf4>t0?<0xd7><0x85>%<0xee>UUT<0xe7><0xdf><0xa0><0xb9><0xce><0xe2>U@<0x03><0x82>S<0xe9>*<0xa8>hB<0x1a><0x10><0xa1><0xaf>V<0x19>U<0x9d><0xb3>x<0xa6><0xc7><0xe2><0x86><0x8e>d[<0x89>e<0x05>l<0x80>H<0x91>#<0xd2><0x8c><0xe1>j<0x1b>rH<0x04><0x89><0x98><0xd3>lZW]q><0xc2><';<0x93><0xb4><0xf5>&<0x9d><0xa0>^Wp<0xa9>6`<0xe2>T<0xa2><0xc2><0xb1>*<0xbc><0x13><0x13><0xa0><0xc4>)<0x83><0xb6><0xbe><0x86><0xb9><0x88>-<0x1a> OK ``` -------------------------------- ### Check ESP32 Initialization Log for AT Firmware Source: https://docs.espressif.com/projects/esp-at/en/latest/esp32/Get_Started/Downloading_guide This snippet shows a sample ESP32 startup log. This log is used to verify if the ESP-AT firmware has initialized correctly, which is a crucial step when troubleshooting AT command functionality. The log provides details about the boot process and firmware status. ```text rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT) configsip: 0, SPIWP:0xee clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00 mode:DIO, clock div:2 load:0x3fff0030,len:5884 ho 0 tail 12 room 4 load:0x40078000,len:15844 load:0x40080400,len:3560 entry 0x40080604 I (29) boot: ESP-IDF v5.0-541-g885e501d99-dirty 2nd stage bootloader I (29) boot: compile time 08:40:13 I (29) boot: chip revision: v1.0 I (34) boot.esp32: SPI Speed : 40MHz I (38) boot.esp32: SPI Mode : DIO I (43) boot.esp32: SPI Flash Size : 4MB I (47) boot: Enabling RNG early entropy source... I (53) boot: Partition Table: I (56) boot: ## Label Usage Type ST Offset Length I (64) boot: 0 phy_init RF data 01 01 0000f000 00001000 I (71) boot: 1 otadata OTA data 01 00 00010000 00002000 I (78) boot: 2 nvs WiFi data 01 02 00012000 0000e000 I (86) boot: 3 at_customize unknown 40 00 00020000 000e0000 I (93) boot: 4 ota_0 OTA app 00 10 00100000 00180000 I (101) boot: 5 ota_1 OTA app 00 11 00280000 00180000 I (108) boot: End of partition table I (113) esp_image: segment 0: paddr=00100020 vaddr=3f400020 size=1a854h (108628) map I (161) esp_image: segment 1: paddr=0011a87c vaddr=3ff80063 size=00008h ( 8) load I (161) esp_image: segment 2: paddr=0011a88c vaddr=3ffbdb60 size=04d5ch ( 19804) load I (174) esp_image: segment 3: paddr=0011f5f0 vaddr=40080000 size=00a28h ( 2600) load I (176) esp_image: segment 4: paddr=00120020 vaddr=400d0020 size=11f5c0h (1177024) map I (609) esp_image: segment 5: paddr=0023f5e8 vaddr=40080a28 size=1e948h (125256) load I (660) esp_image: segment 6: paddr=0025df38 vaddr=400c0000 size=00064h ( 100) load I (676) boot: Loaded app from partition at offset 0x100000 I (676) boot: Disabling RNG early entropy source... no external 32k oscillator, disable it now. at param mode: 1 AT cmd port:uart1 tx:17 rx:16 cts:15 rts:14 baudrate:115200 module_name: WROOM-32 max tx power=78, ret=0 2.5.0 ``` -------------------------------- ### Enable Multiple Connections and Start UDP Transmission (ESP-AT) Source: https://docs.espressif.com/projects/esp-at/en/latest/esp32/AT_Command_Examples/TCP-IP_AT_Examples Enables multiple network connections and then starts a UDP transmission. It specifies the connection link ID, protocol, remote IP, remote port, local port, and a mode parameter to fix the remote host details. ```AT Command AT+CIPMUX=1 AT+CIPSTART=4,"UDP","192.168.3.102",8080,1112,0 ``` -------------------------------- ### Create a Secure WebSocket Server (WSS) on PC using Python Source: https://docs.espressif.com/projects/esp-at/en/latest/esp32/AT_Command_Examples/websocket_at_examples This section details how to set up a secure WebSocket server on a PC using Python. It includes the necessary code and instructions for configuring TLS certificates and running the server. ```APIDOC ## Create a Secure WebSocket Server (WSS) on PC using Python ### Description This example demonstrates how to create a secure WebSocket server (WSS) on a personal computer using Python. It utilizes the `websockets` library and Python's `ssl` module for TLS encryption. The server is configured to echo any received messages back to the client. ### Prerequisites - Python installed on your PC. - `websockets` library installed: `pip install websockets` - TLS certificates (CA, server certificate, and private key) generated or obtained. ### Server Code (`wss-server.py`) ```python #!/usr/bin/env python import asyncio import ssl import websockets host = 'YOUR_PC_IP_ADDRESS' # Replace with your PC's IP address port = 8766 wss_ca = '/path/to/your/wss_ca.crt' # Replace with the path to your CA certificate wss_cert = '/path/to/your/wss_server.crt' # Replace with the path to your server certificate wss_key = '/path/to/your/wss_server.key' # Replace with the path to your server private key async def echo(websocket, path): async for message in websocket: await websocket.send(message) ssl_context = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER) ssl_context.load_cert_chain(certfile=wss_cert, keyfile=wss_key) ssl_context.verify_mode = ssl.CERT_REQUIRED ssl_context.load_verify_locations(wss_ca) start_server = websockets.serve(echo, host, port, ssl=ssl_context) asyncio.get_event_loop().run_until_complete(start_server) print(f"Server started at wss://{host}:{port}") asyncio.get_event_loop().run_forever() ``` ### Running the Server 1. Save the code above as `wss-server.py`. 2. Replace `YOUR_PC_IP_ADDRESS` with your PC's actual IP address. 3. Update `wss_ca`, `wss_cert`, and `wss_key` with the correct paths to your TLS certificate files. 4. Run the server from your terminal: ```bash python wss-server.py ``` ### Server Configuration Notes - The default port is `8766`, but you can change it. - For custom certificate configurations or multiple certificate sets, refer to the documentation on PKI configuration. ``` -------------------------------- ### Example: Connect and Publish MQTT String Message Source: https://docs.espressif.com/projects/esp-at/en/latest/esp32/AT_Command_Set/MQTT_AT_Commands Demonstrates a sequence of AT commands to set Wi-Fi mode, connect to a network, configure MQTT user credentials, establish an MQTT connection, and publish a string message using AT+MQTTPUB. ```bash AT+CWMODE=1 AT+CWJAP="ssid","password" AT+MQTTUSERCFG=0,1,"ESP32","espressif","1234567890",0,0,"" AT+MQTTCONNCFG=0,"192.168.10.234",1883,0 AT+MQTTPUB=0,"topic","\"{\"timestamp\":\"20201121085253\"}\"",0,0 ``` -------------------------------- ### ESP32 Bluetooth LE Server Operations Source: https://docs.espressif.com/projects/esp-at/en/latest/esp32/AT_Command_Examples/bluetooth_le_at_examples Commands for the ESP32 acting as a Bluetooth LE server, including getting the server's address, creating and starting services, and discovering characteristics. ```APIDOC ## ESP32 Bluetooth LE Server Operations ### Description Commands executed on the ESP32 acting as a Bluetooth LE server. ### Method AT Command ### Endpoint N/A ### Parameters #### Path Parameters N/A #### Query Parameters - **AT+BLEADDR?** - Retrieves the Bluetooth LE address of the server. - **AT+BLEGATTSSRVCRE** - Creates GATT services on the server. - **AT+BLEGATTSSRVSTART** - Starts the GATT services on the server. - **AT+BLEGATTSCHAR?** - Discovers characteristics of the services on the server. - **AT+BLEADVSTART** - Starts Bluetooth LE advertising. ### Request Example Get Server Address: ``` AT+BLEADDR? ``` Create Services: ``` AT+BLEGATTSSRVCRE ``` Start Services: ``` AT+BLEGATTSSRVSTART ``` Discover Characteristics: ``` AT+BLEGATTSCHAR? ``` Start Advertising: ``` AT+BLEADVSTART ``` ### Response #### Success Response (200) - **OK** (string) - Indicates successful execution. - **+BLEADDR:"
"** (string) - The Bluetooth LE address of the server. - **+BLEGATTSCHAR:"","","","",""** (string) - Details of discovered characteristics. #### Response Example Get Server Address Response: ``` +BLEADDR:"24:0a:c4:d6:e4:46" OK ``` Discover Characteristics Response: ``` +BLEGATTSCHAR:"char",1,1,0xC300,0x02 +BLEGATTSCHAR:"desc",1,1,1,0x2901 ... OK ``` ``` -------------------------------- ### ESP32 Bluetooth LE Server: Advertising Configuration Source: https://docs.espressif.com/projects/esp-at/en/latest/esp32/AT_Command_Examples/bluetooth_le_at_examples Configuration steps for the ESP32 Bluetooth LE server to set up advertising parameters and data, and then start advertising. ```APIDOC ## ESP32 Bluetooth LE Server: Advertising Configuration ### Description Configures the advertising parameters, sets the advertising data, and then starts the advertising process for the ESP32 Bluetooth LE server. This makes the server discoverable by clients. ### Method AT Command ### Parameters #### Query Parameters - **`AT+BLEADDR?`** - Retrieves the Bluetooth LE address of the server. - **`AT+BLEADVPARAM=,,,,,,,`** - Sets advertising parameters. Specific values are provided in the example. - **`AT+BLEADVDATA=""`** - Sets the data to be advertised. The example shows a specific data string. - **`AT+BLEADVSTART`** - Starts the advertising process. ### Request Example *Server: `AT+BLEADDR?`* *Server: `AT+BLEADVPARAM=50,50,0,0,7,0,,`* *Server: `AT+BLEADVDATA="0201060A09457370726573736966030302A0"`* *Server: `AT+BLEADVSTART`* ### Response #### Success Response (200) - **`+BLEADDR:"
"`** - The Bluetooth LE address of the server (for `AT+BLEADDR?`). - **`OK`** - Indicates successful execution of the command. #### Response Example ``` +BLEADDR:"24:0a:c4:d6:e4:46" OK ``` ``` -------------------------------- ### ESP32 Wi-Fi Station Mode Setup (AT Commands) Source: https://docs.espressif.com/projects/esp-at/en/latest/esp32/AT_Command_Examples/websocket_at_examples Configures the ESP32 to operate in Wi-Fi station mode, allowing it to connect to an existing wireless network. ```AT Commands AT+CWMODE=1 ``` -------------------------------- ### Example ESP32 AT Commands for Stopping BLE Advertising Source: https://docs.espressif.com/projects/esp-at/en/latest/esp32/AT_Command_Set/BLE_AT_Commands Demonstrates the sequence to initialize the ESP32 as a BLE server, start advertising, and then explicitly stop the advertising process. ```AT Command AT+BLEINIT=2 // Role: server AT+BLEADVSTART AT+BLEADVSTOP ``` -------------------------------- ### POST /api/websites/espressif_projects_esp-at_en_esp32/delete Source: https://docs.espressif.com/projects/esp-at/en/latest/esp32/AT_Command_Examples/http_at_examples This section explains how to perform an HTTP DELETE request using the ESP32 HTTP client AT commands. It covers the necessary setup and command structure for sending a DELETE request. ```APIDOC ## AT+HTTPCLIENT: Send Data via HTTP DELETE ### Description This endpoint allows you to send data to a specified URL using the HTTP DELETE method. It supports various transport types and optional parameters for request configuration. ### Method DELETE (via AT Command) ### Endpoint `https://httpbin.org/delete` (example URL) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **opt** (integer) - Required - Operation code. `5` for DELETE method. - **connect_time** (integer) - Optional - Connection timeout in seconds. - **url** (string) - Required - The URL to send the DELETE request to. - **receive_time** (integer) - Optional - Receive timeout in seconds. - **transport_type** (integer) - Optional - Transport protocol. `1` for HTTP_TRANSPORT_OVER_TCP. ### Request Example ``` AT+HTTPCLIENT=5,0,"https://httpbin.org/delete",,,1 ``` ### Response #### Success Response (200 OK) - **+HTTPCLIENT: [status],[response_body]** - Indicates successful request and the server's response. #### Response Example ```json +HTTPCLIENT:282,{ "args": {}, "data": "", "files": {}, "form": {}, "headers": { "Content-Length": "0", "Content-Type": "application/x-www-form-urlencoded", "Host": "httpbin.org", "User-Agent": "ESP32 HTTP Client/1.0", "X-Amzn-Trace-Id": "Root=1-61504289-468a41737b0d251672acec9d" }, "json": null, "origin": "20.187.154.207", "url": "https://httpbin.org/delete" } OK ``` ### Error Handling - Standard AT command error responses apply. ``` -------------------------------- ### MQTT User Configuration Source: https://docs.espressif.com/projects/esp-at/en/latest/esp32/AT_Command_Examples/MQTT_AT_Examples Sets up user credentials for MQTT connections. This needs to be configured separately for both the publisher and subscriber. ```APIDOC ## MQTT User Configuration ### Description Sets up user credentials for MQTT connections. This needs to be configured separately for both the publisher and subscriber. ### Method AT Commands ### Endpoint N/A ### Parameters #### AT Commands * **For ESP32 MQTT Publisher**: * Command: `AT+MQTTUSERCFG=0,4,"publisher","espressif","123456789",0,0,""` * Description: Configures MQTT user settings for client ID `publisher` with username `espressif` and password `123456789`. The first parameter `0` indicates the MQTT client ID. * Response: `OK` * **For ESP32 MQTT Subscriber**: * Command: `AT+MQTTUSERCFG=0,4,"subscriber","espressif","123456789",0,0,""` * Description: Configures MQTT user settings for client ID `subscriber` with username `espressif` and password `123456789`. The first parameter `0` indicates the MQTT client ID. * Response: `OK` ``` -------------------------------- ### Start ESP32 Bluetooth LE Advertising Source: https://docs.espressif.com/projects/esp-at/en/latest/esp32/AT_Command_Examples/sleep_at_examples Initiates Bluetooth Low Energy advertising for the ESP32 device. This command should be used after the BLE role has been initialized. It makes the device discoverable by other BLE clients. ```AT Commands AT+BLEADVSTART ``` -------------------------------- ### Initialize ESP32 Bluetooth LE Server Source: https://docs.espressif.com/projects/esp-at/en/latest/esp32/AT_Command_Examples/sleep_at_examples Initializes the Bluetooth Low Energy (BLE) role as a server. This is the first step before starting advertising or establishing connections. It does not require specific inputs beyond the command itself. ```AT Commands AT+BLEINIT=2 ``` -------------------------------- ### Connect OpenSSL Client to ESP32 SSL Server Source: https://docs.espressif.com/projects/esp-at/en/latest/esp32/AT_Command_Examples/TCP-IP_AT_Examples Initiates an SSL client connection from a PC to the ESP32 SSL server. Requires OpenSSL to be installed on the PC. Uses the IP address and port configured on the ESP32. ```Shell openssl s_client -host 192.168.4.1 -port 8070 ``` -------------------------------- ### Configure MQTT User (Subscriber) Source: https://docs.espressif.com/projects/esp-at/en/latest/esp32/AT_Command_Examples/MQTT_AT_Examples Sets up user credentials for the MQTT subscriber. Requires the AT command set for ESP32. No specific input/output dependencies beyond the AT command syntax. ```AT Command AT+MQTTUSERCFG=0,1,"subscriber","espressif","123456789",0,0,"" ``` -------------------------------- ### Create a WebSocket Server using Python Source: https://docs.espressif.com/projects/esp-at/en/latest/esp32/AT_Command_Examples/websocket_at_examples A Python script to create a simple WebSocket echo server. It listens on a specified host and port, echoing any received messages back to the client. Requires the 'websockets' library. ```python #!/usr/bin/env python import asyncio from websockets.server import serve host = "192.168.200.249" port = 8765 async def echo(websocket): async for message in websocket: await websocket.send(message) async def main(): async with serve(echo, host, port): print(f"Server started at ws://{host}:{port}") await asyncio.get_running_loop().create_future() # run forever asyncio.run(main()) ```