Skip to main content

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.

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

info

For the ESP32-S3-Touch-LCD-1.83 development board, ESP-IDF V5.3.1 or above is required.

note

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

  1. 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.

    Download EIM and offline package

    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).

    Download EIM and offline package 2

    Please wait for both files to finish downloading.

  2. 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.

    Auto-detect offline package

    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.

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

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

    Install drivers via ESP-IDF Installation Manager

Install Visual Studio Code and the ESP-IDF Extension

  1. Download and install Visual Studio Code.

  2. During installation, it is recommended to check Add "Open with Code" action to Windows Explorer file context menu to facilitate opening project folders quickly.

  3. In VS Code, click the Extensions icon Extensions Icon in the Activity Bar on the side (or use the shortcut Ctrl + Shift + X) to open the Extensions view.

  4. Enter ESP-IDF in the search box, locate the ESP-IDF extension, and click Install.

    Search and install ESP-IDF extension in VS Code

  5. 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.

ExampleBasic Description
01_AXP2101Drive AXP2101 via the ported XPowersLib to obtain power‑related data
02_lvgl_demo_v9Run the LVGL V9 demo
03_esp-brookesiaRun the esp-brookesia example (based on the V0.4.2 release version)
04_Immersive_blockUse the QMI8658 for an immersive block that tilts with gravity
05_Spec_AnalyzerImplement a simple audio spectrum analyzer using LVGL
06_videoplayerUse LVGL to play AVI video from a TF card, with audio playback

01_AXP2101

Example Description

  • This example demonstrates porting XPowersLib in ESP-IDF, and driving AXP2101 to obtain power-related data through the ported XPowersLib

Hardware Connection

  • Connect the development board to the computer

Code Analysis

  • i2c_init: Initializes the I2C master device, preparing it for communication with other devices (e.g., the PMU)
    • Configures I2C parameters, including setting the master device mode, specifying the SDA and SCL pins, enabling the pull-up resistor, and determining the clock frequency
    • Installs the I2C driver to apply the configuration to the actual hardware
  • pmu_register_read: Reads a series of byte data from a specific register of the PMU
    • Performs parameter checks to ensure the incoming parameters are valid and avoid invalid read operations
    • Performs I2C operations in two steps, first sends the register address to read, then reads the data During the reading process, different processing is carried out according to the length of bytes to be read to ensure accurate reading of the data. At the same time, handles error cases in the I2C communication process and returns the corresponding status code so that the upper-layer code can determine if the read operation is successful

Operation Result

  • This example will not light up the screen
  • The serial port monitor displays the parameters: chip temperature, charging state, discharging state, standby state, Vbus connection, Vbus condition, charger status, battery voltage, Vbus voltage, system voltage, battery percentage

    ESP32-S3-Touch-AMOLED-1.75_IDF_1

02_lvgl_demo_v9

Example Description

  • This example runs the LVGL V9 demo program

Hardware Connection

  • Connect the development board to the computer

Operation Result

ESP32-S3-Touch-AMOLED-1.75_IDF_1

03_esp-brookesia

Example Description

  • This example demonstrates the UI interface running with the esp-brookesia framework.

Hardware Connection

  • Connect the development board to the computer

Operation Result

ESP32-S3-Touch-1.83-idf-0301
ESP32-S3-Touch-1.83-idf-0303

04_Immersive_block

Example Description

  • This example demonstrates the QMI8658 driving effect, implementing multiple blocks that tilt immersively with gravity.

Hardware Connection

  • Connect the development board to the computer

Operation Result

ESP32-S3-Touch-1.83-idf-03
ESP32-S3-Touch-1.83-idf-04

05_Spec_Analyzer

Example Description

  • This example implements microphone audio capture, uses FFT to analyze the audio, and displays the results on the screen.

Hardware Connection

  • Connect the development board to the computer.

Operation Result

ESP32-S3-Touch-1.83_sound

06_videoplayer

Example Description

  • This example demonstrates playing an AVI video file from a TF card, with audio playback.

Hardware Connection

  • Connect the development board to the computer

Operation Result

ESP32-S3-Touch-lcd-1.83_sd1
ESP32-S3-Touch-lcd-1.83_sd2

Customizing the Video Users can customize the audio/video clip by following these steps (some programming experience is required):

  • Select the video you want to play (e.g., a.mp4).
  • Install the ffmpeg tool.
    • Use ffmpeg to convert the video file to AVI format:
      ffmpeg -i a.mp4 -vcodec mjpeg -s 'width'x'height' -r 30 -q:v 2 -acodec pcm_s16le -ar 44100 -ac 2 a.avi
    • Place the converted AVI file into the /avi/ directory on the TF card.
    • Insert the TF card into the development board.
  • Compile and flash the program.