Google Chat:---
+86-0755-88291180
sales@spotpear.com
dragon_manager@163.com
tech-support@spotpear.com
zhoujie@spotpear.com
WhatsApp:13246739196
WhatsApp:13424403025



This chapter introduces the Arduino development environment for the ESP32-DEV-KIT-XX and the example programs provided in examples/Arduino/examples.
Please refer to the tutorial Install and Configure Arduino IDE to download and install the Arduino IDE and add ESP32 support.
After installing Arduino IDE, add the Espressif Arduino-ESP32 board index in "Preferences -> Additional Boards Manager URLs", and install the Arduino-ESP32 via the "Boards Manager". Once installed, select ESP32 Dev Module under "Tools -> Board".
Connect the board via USB and select the corresponding serial port under "Tools -> Port". Unless otherwise noted, all examples in this directory use the serial monitor with a baud rate of 115200 bps.
Each example directory contains a .ino main file with the same name as the directory. Open the file in Arduino IDE, then compile and upload it.
01_Board_Info, 02_WS2812_RGB, 03_WiFi, 04_UART_Loopback, and 05_SerialToSerialBT only use components provided by the Arduino-ESP32 board package.
The example programs are located in the examples/Arduino/examples directory of the example package. Examples involving peripherals such as LCD or UART require wiring according to the corresponding sections before running.
| Example | Description |
|---|---|
| 01_Board_Info | Prints chip, Flash, program, and memory information via serial |
| 02_WS2812_RGB | Controls the WS2812 RGB LED to display red, green, blue, white, and off in sequence |
| 03_WiFi | Scans for 2.4 GHz Wi-Fi networks and connects to a specified network |
| 04_UART_Loopback | Uses UART1 to send and receive data, verifying serial loopback |
| 05_SerialToSerialBT | Bidirectionally forwards data between the USB serial port and classic Bluetooth SPP |
After startup, the program prints the chip model, chip revision, CPU frequency, Flash size, program size, remaining heap memory, and base MAC address. This example does not require additional hardware and can be used to verify program upload and serial output.

The data pin of the WS2812 RGB LED is GPIO27. The program uses the Arduino-ESP32 rgbLedWriteOrdered() interface to set brightness to 32 and cycles through red, green, blue, white, and off every second. The serial output simultaneously prints the current RGB values.
This example does not rely on third‑party libraries. If the LED color does not match expectations, check whether COLOR_ORDER needs to match the actual color order of the LED.

This example sets the chip to STA mode, scans for 2.4 GHz Wi-Fi networks, and lists SSID, RSSI, signal quality, channel, and security type over serial. The classic ESP32 chip used on the ESP32-DEV-KIT-XX does not support 5 GHz Wi-Fi.
To test network connectivity, first modify the configuration at the top of the source code:
constexpr char WIFI_SSID[] = "your_ssid";
constexpr char WIFI_PASSWORD[] = "your_password";
After uploading, the program waits up to 20 seconds to connect to the specified Wi-Fi. On successful connection, the serial output shows the IP address, gateway, RSSI, and channel. If connection fails, it retries every 15 seconds; while disconnected, it rescans networks every 60 seconds.

This example uses UART1 for a self‑loopback test with the following initialization:
| Signal | GPIO | Parameters |
|---|---|---|
| UART1 TX | GPIO4 | 115200 bps, 8N1 |
| UART1 RX | GPIO5 | 115200 bps, 8N1 |
Connect GPIO4 and GPIO5 with a wire, then upload the program. GPIO4 and GPIO5 must not be connected to 5 V. The program sends an incrementing counter message every 2 seconds via TX, and outputs [RX PASS] or [RX FAIL] based on whether the same content is received on RX within 500 ms, while also printing transmit/receive statistics.

This example creates a classic Bluetooth SPP serial port with the device name ESP32-BT-Slave. The program bidirectionally forwards data byte‑by‑byte between the USB serial port and the Bluetooth serial port, with the USB serial baud rate set to 115200 bps.
After uploading, search for and pair with ESP32-BT-Slave on a computer or mobile device that supports classic Bluetooth SPP. Data sent via the Bluetooth serial port appears in the Arduino serial monitor; data sent from the Arduino serial monitor is forwarded to the Bluetooth client.
This example uses classic Bluetooth SPP, not BLE. The SPP functionality of BluetoothSerial is only available on classic ESP32 chips; select ESP32 Dev Module when compiling.
Make sure the Espressif Arduino-ESP32 board package has been installed via the "Boards Manager", then reopen the "Tools" > "Board" menu.
Verify that WIFI_SSID and WIFI_PASSWORD have been changed to your actual network credentials, and confirm that the target network is 2.4 GHz. The scan results from the serial can be used to confirm whether the target network is visible.
Confirm that GPIO4 and GPIO5 are directly connected with no other peripherals attached. The [RX FAIL] output distinguishes between receive timeout, content mismatch, and receive buffer overflow.
Make sure the client supports classic Bluetooth SPP and search for the device name ESP32-BT-Slave. BLE debug tools cannot connect to the SPP serial port provided by this example.
This chapter includes the following sections, please read as needed:
New to ESP32 ESP-IDF development and looking to get started quickly? We have prepared a general Getting Started Tutorial for you.
Please Note: This tutorial uses the ESP32-S3-Zero as a teaching example, and all hardware code is based on its pinout. Before you start, it is recommended that you check the pinout of your development board to ensure the pin configuration is correct.
The following guide uses Windows as an example, demonstrating development using VS Code + the ESP-IDF extension. macOS and Linux users should refer to the official documentation.
The screenshots in this section use ESP-IDF V5.5.2 as an example. When installing, please select the ESP-IDF version that matches your board's example.
Download the installation manager from the ESP-IDF Installation Manager page. This is Espressif's latest cross-platform installer. The following steps demonstrate how to use its offline installation feature.
Click the Offline Installer tab on the page, then select Windows as the operating system and the ESP-IDF version you need (the version shown in the screenshot is for reference only — choose the version that fits your actual needs).

After confirming your selection, click the download button. The browser will automatically download two files: the ESP-IDF Offline Package (.zst) and the ESP-IDF Installer (.exe).

Please wait for both files to finish downloading.
Once the download is complete, double-click to run the ESP-IDF Installer (eim-gui-windows-x64.exe).
The installer will automatically detect if the offline package exists in the same directory. Click Install from archive.

Next, select the installation path. We recommend using the default path. If you need to customize it, ensure the path does not contain Chinese characters or spaces. Click Start installation to proceed.

When you see the following screen, the ESP-IDF installation is successful.

We recommend installing the drivers as well. Click Finish installation, then select Install driver.

Download and install Visual Studio Code.
During installation, it is recommended to check Add "Open with Code" action to Windows Explorer file context menu to facilitate opening project folders quickly.
In VS Code, click the Extensions icon in the Activity Bar on the side (or use the shortcut Ctrl + Shift + X) to open the Extensions view.
Enter ESP-IDF in the search box, locate the ESP-IDF extension, and click Install.

For ESP-IDF extension versions ≥ 2.0, the extension will automatically detect and recognize the ESP-IDF environment installed in the previous steps, requiring no manual configuration.
The ESP-IDF example programs are located in the examples/ESP-IDF directory of the example package. Each example is an independent project and targets the esp32 chip.
COM5 under Windows).Navigate to the corresponding example directory and run:
idf.py set-target esp32
idf.py build
idf.py -p COM5 flash monitor
Replace COM5 with the actual serial port name. To exit the serial monitor, press Ctrl-]. On the first build, the component manager will automatically download the dependencies declared by the project, so a network connection is required.
This example prints Hello world!, chip features, Flash size, and minimum free heap size to the serial port; then it outputs a restart countdown every second and reboots automatically when the countdown ends. It can be used to verify that the ESP-IDF environment, flashing path, and serial monitor are working properly.

This example drives the onboard addressable RGB LED. The current sdkconfig selects the RMT driver, the data pin is GPIO27, and the blinking period is 1000 ms. The RGB value when the LED is on is (16, 16, 16).

This example uses UART1 for asynchronous transmission and reception, with the chip's internal software loopback enabled, so no external jumper is required. A transmit task sends the string Hello world every 2 seconds. A receive task reads the loopback data and outputs it to the serial monitor in both text and hexadecimal formats.
The current communication parameters are 115200 bps, 8 data bits, no parity, 1 stop bit, and no hardware flow control.
This example connects to Wi-Fi, then sends an HTTP request to the OpenWeather API to obtain real-time weather data for Beijing and outputs the server response to the serial port. After one request completes, it waits for 30 minutes before sending the next request.
Before flashing, run idf.py menuconfig and enter the Wi-Fi SSID and password in Example Connection Configuration. When connecting to a 2.4 GHz network, make sure the router has the corresponding band enabled.
Note: The weather API URL, location, and access key are fixed in
main/main.cand use plain HTTP. Before using this in a product or on a public network, you should replace these with your own key and use HTTPS, certificate validation, and secure key management.

This example starts a BLE GATT Server with the advertisement name ESP_GATTS_DEMO, waiting for a phone or other BLE GATT Client to connect. The service contains two 16‑bit UUIDs:
| Service UUID | Characteristic UUID | Features |
|---|---|---|
0x00FF | 0xFF01 | Read, Write, Notify, Indicate |
0x00EE | 0xEE01 | Read, Write, Notify |
Use a phone BLE debugging tool to scan and connect to ESP_GATTS_DEMO, then read or write data.
idf.py fullclean and idf.py set-target esp32, then build again.03_UART example is flashed and check the serial log for UART initialization errors.ESP32 Chip Official Manuals
Monday-Friday (9:30-6:30) Saturday (9:30-5:30)
Email: services01@spotpear.com