Working with ESP-IDF
This chapter includes the following sections, please read as needed:
ESP-IDF Getting Started
New to ESP32 ESP-IDF development and looking to get started quickly? We have prepared a general Getting Started Tutorial for you.
- Section 1: Environment Setup
- Section 2: Running Examples
- Section 3: Creating a Project
- Section 4: Using Components
- Section 5: Debugging
- Section 6: FreeRTOS
- Section 7: Peripherals
- Section 8: Wi-Fi Programming
- Section 9: BLE Programming
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.
Setting Up Development Environment
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.
Install the ESP-IDF Development Environment
-
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 choose your desired version from the filter bar.

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.

Install Visual Studio Code and the ESP-IDF Extension
-
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.
Demo
The ESP-IDF demos are located in the ESP-IDF directory of the demo package.
01_Hello world
This example demonstrates outputting "Hello world!" to the TERMINAL window at 10-second intervals.

02_RGB
This example demonstrates the blinking of the onboard RGB LED at 1-second intervals.

03_UART
This example demonstrates UART self-transmission and reception by shorting GPIO4 and GPIO5.

Hardware Connection
- Short GPIO4 and GPIO5 using a female-to-female jumper wire.
| ESP32-C5-N16R4 | ESP32-C5-N16R4 (Same Board) |
|---|---|
| GPIO4 | GPIO5 |
Code Analysis
-
Send Task (tx_task):
Sends the string "Hello waveshare" via UART every 2 seconds. -
Receive Task (rx_task):
Continuously reads data from UART and prints the string if data is received.
04_IIC
This example lights up a 0.96inch OLED (B) and displays a character string.
![]() | ![]() |
|---|
Hardware Connection
- Insert the development board into the computer and connect the screen to the following pins using jumper wires.
| 0.96inch OLED (B) | ESP32-C5-N16R4 |
|---|---|
| VCC | 3V3 |
| GND | GND |
| DIN | GPIO3 |
| CLK | GPIO4 |
| CS | GND |
| D/C | GND |
| RST | GPIO9 |
05_WIFI
This example implements the functionality for ESP32-C5 to connect to WiFi and fetch data from the OpenWeather API.

06_WIFI_AP
This example enables the development board to create a WiFi hotspot and allows mobile devices to connect.

07_BLE
This example demonstrates a mobile device connecting to a Bluetooth BLE beacon and receiving broadcast data.
08_ZIGBEE
This example uses two ESP32-C5 boards, where the BOOT button on one board (flashed with the HA_on_off_switch program) controls the RGB LED ON/OFF on the other board.
- Note: First flash one board with the HA_on_off_switch program, then flash the other board with the HA_on_off_light program.

Hardware Connection
-
- Prepare two ESP32-C5-N16R4 development boards, ensuring they are powered correctly and ready for program flashing.
-
- Connect the first development board to the computer. Use the flashing tool to flash the HA_on_off_light program onto this board (this program controls the RGB LED). After flashing, keep the board powered on.
-
- Connect the second development board to the computer. Use the flashing tool to flash the HA_on_off_switch program onto this board (this program implements the control function via the BOOT button). After flashing, keep the board powered on.

