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-CAM-OVxxxx development board, ESP-IDF version V5.5.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.

Demo

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

DemoBasic Description
01_simple_video_serverCreate multiple HTTP servers on different ports on the local network, accessible via a web browser, providing video streaming functionality
02_esp_srDemonstrate speech recognition and voice wake-up functions using the ESP-SR component
03_audio_playScan the TF card and play MP3 audio
04_dvp_camera_displayDisplay the camera feed on the LCD screen
05_lvgl_brookesiaShow LVGL APP style UI using the Brookesia component
06_usb_host_uvcSimulate a UVC device, demonstrating USB camera functionality

01_simple_video_server

Demo Description

  • This example demonstrates creating an HTTP server, accessing it via a browser, and obtaining a video stream

Hardware Connection

  • Connect the development board to the computer
  • Camera: Supports GC0308, GC2145, OV5640, OV3660

Code Analysis

  • example_connect(): Initialize Wi-Fi connection
    • Set SSID and password in the menuconfig configuration
    • Default SSID: WSTEST
    • Default password: waveshare0755
  • start_cam_web_server(): Initialize the HTTP server and camera
    • Initialize the camera first. If an unsupported camera or format is detected, an error will be reported and the program will exit
    • Wait for the camera to initialize successfully, then initialize the HTTP server

Operation Result

  • This demo will not light up the screen
  • Check the serial monitor for the printed IP address
  • Open the IP address in a browser. Ensure you are on the same local network.

02_esp_sr

Demo Description

  • This example demonstrates offline voice wake-up and speech recognition using the ESP-SR component

Hardware Connection

  • Connect the development board to the computer
  • Do not block the microphone

Code Analysis

  • Speech_Init(): Initialize the microphone and create recognition tasks
    • Obtain the microphone control handle via bsp_audio_codec_microphone_init()
    • Create data reading and detection/recognition tasks
  • Speech_register_callback(): Register a callback function for recognition events
    • Events can be obtained within the callback function

Operation Result

  • This demo will not light up the screen
  • Check the serial monitor for voice wake-up and recognition results

03_audio_play

Demo Description

  • This example demonstrates playing MP3 audio files from a TF card

Hardware Connection

  • Insert a memory card with an MP3 file placed in the root directory
  • Connect a speaker
  • Connect the development board to the computer

Code Analysis

  • bsp_io_expander_init();: Initialize the external I/O expander
    • Initialize the PA control pin to control audio output
  • bsp_sdcard_mount(): Mount the TF card
  • Search_Music(): Search for and save the paths of MP3 files on the TF card
  • Audio_Play_Init(): Initialize the audio player
  • Volume_Adjustment(): Set the volume level
  • Audio_Play_Music(): Play the MP3 file

Operation Result

  • This demo will not light up the screen
  • After running, it will automatically search for MP3 files on the TF card and play them

04_dvp_camera_display

Demo Description

  • This example is an app-style UI + camera demo. Tapping the camera app displays the image on the screen

Hardware Connection

  • Connect a DVP camera: Supports GC0308, GC2145, OV5640, OV3660
  • Connect a screen, supports 1.83, 2inch, 2.8inch, 3.5inch
  • Connect the development board to the computer

Code Analysis

  • bsp_display_start(): BSP initializes display-related resources
    • Initialize the LCD screen
    • Initialize LVGL
  • bsp_display_backlight_on(): Turn on the backlight
  • new ESP_Brookesia_Phone(disp): Initialize the Brookesia component
  • new PhoneCameraConf(1,0);: Install the camera app

Operation Result

  • Tap the camera app icon, the screen starts displaying the camera image. Tap anywhere on the screen to return to the camera settings interface

05_lvgl_brookesia

Demo Description

  • This example demonstrates a complete phone-style UI system, including components such as a status bar, navigation bar, app launcher, and gesture interaction

Hardware Connection

Code Analysis

  • bsp_display_start(): BSP initializes display-related resources
    • Initialize the LCD screen
    • Initialize LVGL

Operation Result

06_usb_host_uvc

Demo Description

  • This example simulates a UVC device, demonstrating USB camera functionality

Hardware Connection

  • Connect a DVP camera: Supports OV5640, OV3660
  • Connect the development board to the computer

Code Analysis

  • uvc_device_config(): Configure UVC device-related interface functions
  • uvc_device_init(): Start initializing the UVC device

Operation Result

  • Open the camera app on your computer to see the image. There may be some latency; wait a moment or try re-powering
  • This demo uses the USB programming interface. When programming again, you need to hold the BOOT button to enter download mode