ESP-IDF
This chapter contains 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 the Development Environment
For the ESP32-S3-Touch-LCD-2 development board, ESP-IDF V5.5.0 or later is required.
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.
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 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.

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.
Example
The ESP-IDF examples are located in the ESP-IDF directory of the example package.
| Example | Basic Program Description | Dependency Library |
|---|---|---|
| 01_sd_card_test | Test TF card | - |
| 02_lvgl_qmi8658 | Display QMI8658 data using LVGL | - |
| 03_lvgl_brightness | Control and display screen brightness using LVGL | - |
| 04_lvgl_battery | Display battery voltage using LVGL | - |
| 05_lvgl_camera | Display camera image using LVGL | - |
| 06_lvgl_example | Display LVGL example program | - |
01_sd_card_test
Example Description
- This example demonstrates testing TF card read/write functionality on the ESP32-S3-Touch-LCD-2.
Hardware Connection
- Connect the board to the computer.
- Insert the TF card into the card slot (the TF card needs to be formatted as FAT32).
Code Analysis
-
SPI initialization
sdmmc_host_t host = SDSPI_HOST_DEFAULT();spi_bus_config_t bus_cfg = {.mosi_io_num = PIN_NUM_MOSI,.miso_io_num = PIN_NUM_MISO,.sclk_io_num = PIN_NUM_CLK,.quadwp_io_num = -1,.quadhd_io_num = -1,.max_transfer_sz = 4000,};ret = spi_bus_initialize(host.slot, &bus_cfg, SDSPI_DEFAULT_DMA);if (ret != ESP_OK) {ESP_LOGE(TAG, "Failed to initialize bus.");return;} -
TF card initialization and mounting
sdspi_device_config_t slot_config = SDSPI_DEVICE_CONFIG_DEFAULT();slot_config.gpio_cs = PIN_NUM_CS;slot_config.host_id = host.slot;ESP_LOGI(TAG, "Mounting filesystem");ret = esp_vfs_fat_sdspi_mount(mount_point, &host, &slot_config, &mount_config, &card);
Operation Result
- Open the serial monitor

- Insert the TF card into the computer; three files appear:
test.txt,FOO.TXT,NIHAO.TXT. The content ofFOO.TXTisHello SD!, the content ofNIHAO.TXTisHello SD!, andtest.txtis empty.
02_lvgl_qmi8658
Example Description
- This example demonstrates reading QMI8658 data on the ESP32-S3-Touch-LCD-2 and displaying it using the LVGL library.
Hardware Connection
- Connect the board to the computer.
Code Analysis
-
Initialize the UI and create a 100ms timer to obtain QMI8658 data.
lvgl_qmi8658_ui_init(lv_scr_act());
Operation Result

03_lvgl_brightness
Example Description
- This example demonstrates using the LVGL library on the ESP32-S3-Touch-LCD-2 to display screen brightness, with a slider to control the brightness.
Hardware Connection
- Connect the board to the computer.
Code Analysis
-
Initialize the UI and create a slider value change callback; when the slider value changes, the screen brightness is adjusted.
lvgl_brightness_ui_init(lv_scr_act());
Operation Result
04_lvgl_battery
Example Description
- This example demonstrates using the LVGL library on the ESP32-S3-Touch-LCD-2 to display battery voltage and ADC values on the screen.
Hardware Connection
- Connect the board to the computer.
- Insert the battery into the battery header.
Code Analysis
-
Initialize the UI and create a 1000ms timer to obtain ADC data and convert it to voltage.
lvgl_battery_ui_init(lv_scr_act());
Operation Result

05_lvgl_camera
Example Description
- This example displays camera images on the ESP32-S3-Touch-LCD-2 screen using the LVGL library.
Hardware Connection
- Connect the board to the computer.
- Insert the
OV5640camera into the24Pin Camera Interfaceon the board.
Code Analysis
-
Create a dedicated task to capture camera images.
xTaskCreatePinnedToCore(camera_task, "camera_task_task", 1024 * 3, NULL, 1, NULL, 0); -
Capture camera image and update the display.
camera_fb_t *pic;lv_img_dsc_t img_dsc;img_dsc.header.always_zero = 0;img_dsc.header.w = 480;img_dsc.header.h = 320;img_dsc.data_size = 320 * 480 * 2;img_dsc.header.cf = LV_IMG_CF_TRUE_COLOR;img_dsc.data = NULL;// lv_img_set_src(img_camera, &pic);while (1){pic = esp_camera_fb_get();if (NULL != pic){img_dsc.data = pic->buf;if (lvgl_lock(-1)){lv_img_set_src(img_camera, &img_dsc);lvgl_unlock();}}esp_camera_fb_return(pic);vTaskDelay(pdMS_TO_TICKS(1));}
Operation Result
06_lvgl_example
Example Description
- This example demonstrates running the LVGL example program on the ESP32-S3-Touch-LCD-2.
Hardware Connection
- Connect the board to the computer.
Code Analysis
-
Initialization
lv_init();display_init();lv_port_disp_init();lvgl_tick_timer_init(EXAMPLE_LVGL_TICK_PERIOD_MS);bsp_brightness_init();bsp_brightness_set_level(80); -
Select the LVGL example to run.
lv_demo_widgets();// lv_demo_benchmark();// lv_demo_keypad_encoder();// lv_demo_music();// lv_demo_stress();
Operation Result
- Touch operation is supported.
