Skip to main content

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.

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.

Set Up the Development Environment​

info

For the ESP32-S3-LCD-1.85 development board, ESP-IDF version 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.

Version Selection

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​

  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 the ESP-IDF version you need (the version shown in the screenshot is for reference only — choose the version that fits your actual needs).

    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​

Demo-flow-01

ESP32-S3-LCD-1.85 Example Programs

ExampleBasic Description
ESP32-S3-LCD-1.85-TestTest onboard device functions

ESP32-S3-LCD-1.85-Test​

Example Description

  • This example demonstrates the functionality of various onboard devices. Page 1 displays parameters such as SD Card, Flash Size, Battery Voltage, etc., while Page 2 is the music playback interface. Additionally, this example includes voice recognition functionality.

Hardware Connection

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

ESP32-S3-LCD-1

Code Analysis

  • MIC_Speech_init()
    • This function is mainly used to initialize the speech recognition module. First, it sets the initial state, then initializes the I2S interface to receive microphone audio data. Then it configures the AFE (Audio Front End) module parameters and creates an AFE data instance. Finally, it creates two tasks: one responsible for audio data reading and processing (feed_handler), and the other responsible for speech command detection and recognition (detect_hander)
  • detect_hander()
    • This function runs in an independent task and processes the output results of the AFE module to detect speech commands. It determines the multi-net model according to the configuration and prints the active speech commands. In the loop, it continuously obtains results from the AFE module and processes them according to different wake-up states and multi-net detection states, such as performing corresponding operations when a wake word is detected, and setting the command state and adjusting the LCD backlight when a speech command is detected. At the end of the task, it destroys the multi-net model instance to release resources

Expected Behavior

  • LCD Screen Display 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 the RTC timeDisplays the current RTC time. If the RTC time is inconsistent with the current time, it is because the RTC does not retain data when powered off. To keep the RTC time accurate, 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
Backlight brightnessBrightness sliderAdjusts screen brightness
  • Page 2 is the UI page for playing mp3 audio files located in the root directory of the TF card
  • This example can use the BOOT button and the PWR button for component selection to simulate the touch function; pressing both buttons at the same time indicates a confirmed press
  • This program enables voice recognition by default. The wake word is "hi esp". After waking up, the backlight dims, and you can speak the command (if the backlight does not dim, it means it was not woken up; recognition requires standard pronunciation and a slower speaking pace)
  • Several MIC test audio formats are provided below (Note: if the "hi esp" wake-up fails, please reposition the audio to the point where the wake word is played and try again)
  • Please do not perform voice recognition while audio is being played through the speaker
  • The reason the test audio plays the wake word twice is that the current firmware version requires a focus step for the first wake-up (metaphorically), and the current firmware does not allow disabling this feature.
// Commands
Turn on the backlight
Turn off the backlight
Backlight is brightest
Backlight is darkest

Switching to the Chinese/English Recognition Model​

The environment defaults to the English recognition environment in its initial state. Follow the steps below to switch to the Chinese recognition model or the English recognition model

Switching to the Chinese/English Recognition Model​

  • Delete the two files in the project
ESP32-S3-Touch-LCD-1
  • Open the file sdkconfig.defaults and find this location.
    • Comment out ① with "#" to switch to the English recognition model
    • Comment out ② with "#" to switch to the Chinese recognition model
      ESP32-S3-Touch-LCD-1

Generating Voice Control Commands​

Environment Preparation​
  • Check if Python is installed on the computer
  • Open the command line: Win+R -> enter cmd
    Python-install-04
  • ①. Enter python --version. If a Python version number appears, it means it is installed
  • ②. Enter where python to view the Python installation location
    • The Python environment under the C drive is the one automatically installed when VS Code was installed
    • The environment under the E drive is the Python environment used for the following steps
info

If no environment is installed, please refer to the python Environment Installation Tutorial. If already installed, please continue

  • Enter pip install g2p_en at the command line to install the g2p_en package
  • Install the resource package and place it under the corresponding user's C:\Users\username\AppData\Roaming path. Double-click to extract the file
  • Enter pip install pypinyin at the command line to install the pypinyin library
Generating Chinese Pinyin​
  • Download the Chinese command generation file
  • Switch the command line path to the Chinese command generation folder (the path varies by user; the following is for reference only)
cd /d E:\download\Generate_Chinese_command
  • Execute multinet_pinyin.py at the command line to generate Chinese Pinyin

    python multinet_pinyin.py "要转为拼音的中文"

    Example:

    python multinet_pinyin.py "你好微雪电子"
    ESP32-S3-Touch-LCD-1
Generating English Phonemes​
  • Download the English command generation file

  • Switch the command line path to the English command generation folder (the path varies by user; the following is for reference only)

    cd /d E:\download\Generate_English_command
  • Execute gen_sr_commands.py at the command line to generate phoneme commands

    python gen_sr_commands.py "English text to convert to phonemes"

    Example:

    python gen_sr_commands.py "hello waveshare"
    ESP32-S3-Touch-LCD-1
Modifying Commands​
  • Under Arduino

    ESP32-S3-Touch-LCD-1
  • Under ESP-IDF

    • Chinese Commands
    ESP32-S3-Touch-LCD-1
    • English Commands
    ESP32-S3-Touch-LCD-1