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

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.

Demo

The ESP-IDF demos are located in the ESP-IDF directory of the demo package.

ESP32-S3-LCD-2.8C-Test

Demo Description

  • This example demonstrates how to integrate the LVGL graphics library on an embedded device. By coordinating hardware initialization and graphics library initialization, a complete graphical interface runtime environment is built. Continuously calling the LVGL core loop ensures that the graphical interface responds to user interactions and refreshes system status in real time while properly managing CPU resource usage.

Hardware Connection

  • Insert the TF card into the development board
  • Connect the development board to the computer

Code Analysis

  • Driver_Init():

    • This function initializes the hardware and creates a task. It initializes the flash memory, the battery, the I2C bus, the real-time clock, the gyroscope, and external IO. It then creates a task Driver_Loop that continuously processes the gyroscope, real-time clock, and battery voltage, performing loop operations every 100 milliseconds.
  • Driver_Loop():

    • Runs as a continuous task, repeatedly processing gyroscope and real-time clock operations and obtaining battery voltage. This ensures that the status of these hardware devices is continuously updated.
  • app_main():

    • This is the main entry function of the program. It first initializes the wireless module, then calls Driver_Init for hardware initialization. Next, initialize the LCD display, TF card, LVGL graphics library and analog touch input in sequence. Next, it initializes the LCD display, TF card, LVGL graphics library, and simulates touch input. In the main loop, it delays for 10 milliseconds and calls lv_timer_handler to process LVGL timer events, ensuring proper operation and updating of the graphical interface.

Operation Result

  • LCD screen display:
  • After the program is successfully flashed, use the BOOT button to control the interface:
    • Single click: select the next control option
    • Double click: select the previous control option
    • Long press: control the selected control option
  • Parameter description:
ParameterFunctionDescription
SD CardDisplays the TF card sizeConnect a TF card. If recognition fails, please format the TF card to FAT32 (if initial recognition fails, wait a moment and then reset to check again)
Flash SizeDisplays the Flash sizeOnboard 16MB Flash
Battery VoltageBattery voltageBattery voltage can be detected when a battery is connected
Angular deflectionDisplays the board's angular deviationDisplays deviation in three directions
RTC TimeDisplays RTC timeThe RTC time may not match the current time because data cannot be retained when power is off. To keep the RTC time accurate, you need to connect an RTC battery and update the RTC time
Wireless scanDisplays the number of Wi-Fi networks scannedScan ends with "Scan Finish" at the end
The buzzer testBuzzer control pageAllows controlling the buzzer on/off
Backlight brightnessBrightness sliderAdjusts screen brightness