ESP32-S3-AUDIO-Board

From Waveshare Wiki
Jump to: navigation, search

ESP32-S3-AUDIO-Board
ESP32-S3-AUDIO-Board

I2C / SPI
{{{name2}}}

{{{name3}}}

{{{name4}}}

{{{name5}}}

{{{name6}}}

Introduction

Introduction

ESP32-S3-AUDIO-Board is an AI smart speaker development board based on the ESP32-S3, supporting 2.4GHz Wi-Fi and Bluetooth 5 (LE). It integrates large capacity Flash and PSRAM, features a dual-microphone array, speaker, RGB surround lighting effect, and various interfaces. It can be widely used for the rapid development of intelligent products such as AI speakers, voice interaction, HMI screen applications, and camera applications.

Features

  • High-performance controller: Equipped with ESP32-S3R8, an Xtensa 32-bit LX7 dual-core processor, with a clock frequency up to 240MHz
  • Wireless connection: Supports 2.4GHz Wi-Fi (802.11 b/g/n) and Bluetooth 5 (LE), with onboard antenna
  • Storage resources: Built-in 512KB SRAM, 384KB ROM, stacked with 8MB PSRAM, and external 16MB Flash
  • Voice interaction: Dual digital microphone array, supports noise reduction and echo cancellation, suitable for precise voice recognition and near-field/far-field wake-up
  • Clock management: Integrates PCF85063 RTC chip, supports RTC power-down time retention, can be used for alarms, scheduled tasks, or wake-ups, etc
  • Dazzling lighting effects: Onboard 7 ring RGB colorful lights that can be programmed to achieve a variety of dynamic lighting effects
  • Human-computer interaction: Reserve multiple buttons and battery switch for convenient custom function development
  • Expansion port:
    • SPI LCD screen interface (FPC / pin header)
    • DVP camera interface (24PIN header)
    • USB, I2C, and partial IO pins (compatible with screen interface pins)
  • Multimedia features: Onboard audio decoding chip, MIC, and speaker interface
  • Storage expansion: Supports TF card slot for storing audio files, etc
  • Power Management: Built-in battery charging management module, supports multiple power modes and low-power applications

Specifications

Parameter Name Parameter
Interface USB Type-C
Controller chip ESP32-S3
Onboard devices ES8311
ES7210
MIC
RTC clock chip
Camera interface
Screen interface
TF
Speaker header
Battery recharging manager module

Dimensions

ESP32-S3-AUDIO-Board-details-size.jpg

Onboard Resources

ESP32-S3-AUDIO-Board-details-intro.jpg

1. ESP32-S3R8
   Dual-core processor, up to 240MHz operating frequency

2. TCA9555PWR
   GPIO expansion chip

3. RTC clock chip: PCF85063
   RTC real-time clock

4. Keys
   RESET key, BOOT key, and user-defined keys

5. USB Type-C port
   Used to power the device and program flashing

6. Charge indicator
   When connected to the battery, lights up when charging, off when fully charged

7. Battery switch
   ON: Connected to the battery    OFF: Disconnected from the battery

8. 18PIN display interface
   For connecting to the display with corresponding pinout

9. Camera interface
   For connecting to the camera with corresponding pinout

10. TF card slot
   For inserting the TF card

11. Microphone

12. Pin header interface
   The GPIOs currently brought out by the pin headers are all used for the screen interface

13. IPEX Gen 1 connector
   Switches to use external antenna via resoldering the resistor

14. Patch ceramic antenna

15. Amplifier chip

16. ES8311
   Audio codec chip

17. 16MB Flash

18. RTC battery header
   For connecting the rechargeable RTC battery

19. ES7210
   Audio encoding chip

20. MP1605GTF-Z
   Power module, supporting up to 3.3V 2A output

21. Battery recharge manager Chip

22. RGB light bead
   7x surround RGB LEDs

23. Battery header
   MX1.25 2PIN connector, for 3.7V Lithium battery, supports charging and discharging

24. Speaker header

Pinout Definition

Esp32s3 audio boarddetails-inter-1.1.jpg

QSPI LCD pins SPI LCD pins ESP32S3
LCD_CS LCD_CS GPIO3
LCD_SCK LCD_SCK GPIO4
LCD_BL LCD_BL GPIO5
LCD_SDA3 NC GPIO6
LCD_SDA2 LCD_DC GPIO7
LCD_SDA1 LCD_MISO GPIO8
LCD_SDA0 LCD_MOSI GPIO9
LCD_RST LCD_RST EXIO0
TP_SCL TP_SCL GPIO10
TP_SDA TP_SDA GPIO11
TP_RST TP_RST EXIO1
TP_INT TP_INT EXIO2
  • Camera
Camera ESP32S3
CAM_D0 GPIO2
CAM_D1 GPIO17
CAM_D2 GPIO18
CAM_D3 GPIO39
CAM_D4 GPIO45
CAM_D5 GPIO46
CAM_D6 GPIO47
CAM_D7 GPIO48
CAM_HREF GPIO1
CAM_PCLK GPO44 when EXIO6 is high

GPIO19 when EXIO6 is low

CAM_XCLK GPIO43 when EXIO6 is high

GPIO20 when EXIO6 is low

CAM_PWDN EXIO5
Camera_SET EXIO6
  • TF Card
TF Card ESP32S3
SD_D0 / MISO GPIO41
SD_CMD / MOSI GPIO42
SD_SCK / SCLK GPIO40
SD_D3 / CS EXIO3
SD_D1 NC
SD_D2 NC
  • SPEAKER
ES8311 ESP32S3
I2C_SDA GPIO11
I2C_SCL GPIO10
I2S_MCLK GPIO12
I2S_SCLK GPIO13
I2S_LRCK GPIO14
I2S_DSDIN GPIO16
  • MIC
ES7210 ESP32S3
I2C_SDA GPIO11
I2C_SCL GPIO10
I2S_MCLK GPIO12
I2S_SCLK GPIO13
I2S_LRCK GPIO14
I2S_ASDOUT GPIO15

Usage Guide

ESP32-S3-AUDIO-Board currently provides two development tools and frameworks, Arduino IDE and ESP-IDF, providing flexible development options, you can choose the right development tool according to your project needs and personal habits.

Development Tool

180px-Arduino-IDE-logo.jpg

Arduino IDE

Arduino IDE is an open source electronic prototyping platform, convenient and flexible, easy to get started. After a simple learning, you can start to develop quickly. At the same time, Arduino has a large global user community, providing an abundance of open source code, project examples and tutorials, as well as rich library resources, encapsulating complex functions, allowing developers to quickly implement various functions.

180px-ESP-IDF-logo.jpg

ESP-IDF

ESP-IDF, or full name Espressif IDE, is a professional development framework introduced by Espressif Technology for the ESP series chips. It is developed using the C language, including a compiler, debugger, and flashing tool, etc., and can be developed via the command lines or through an integrated development environment (such as Visual Studio Code with the Espressif IDF plugin). The plugin offers features such as code navigation, project management, and debugging, etc.


Each of these two development approaches has its own advantages, and developers can choose according to their needs and skill levels. Arduino are suitable for beginners and non-professionals because they are easy to learn and quick to get started. ESP-IDF is a better choice for developers with a professional background or high performance requirements, as it provides more advanced development tools and greater control capabilities for the development of complex projects.

Components Preparation

  • ESP32-S3-AUDIO-Board x1
  • TF card with MP3 files x1
  • USB cable (Type-A male to Type-C male) x1
  • OV5640 camera x1
  • 1.47inch Touch LCD x1

Precautions

  • Please note that the computer username must be in English, the username in Chinese will lead to compilation errors
  • If you want to continue using the onboard Bluetooth device when enabling all onboard devices with the example provided, it is recommended to use a different audio library file with a small memory footprint (otherwise it will result in a large SRAM footprint)
  • The development board uses USB to download the demo. If the port cannot be recognized, please enter Boot mode (press and hold the Boot button, then connect to the computer, and then release the boot button). After downloading the demo, disconnect the device and reconnect it to the computer to run the demo.
  • The ESP32 3.0.2 on Arduino is based on ESP-IDF v5.1, which is quite different from the previous version based on ESP-IDF V4.X. After the following operations, the original demo may need to be adjusted for normal operation.
Before operating, it is recommended to browse the table of contents to quickly understand the document structure. For smooth operation, please read the FAQ carefully to understand possible problems in advance. All resources in the document are provided with hyperlinks for easy download.

Working with Arduino

This chapter introduces setting up the Arduino environment, including the Arduino IDE, management of ESP32 boards, installation of related libraries, program compilation and downloading, as well as testing demos. It aims to help users master the development board and facilitate secondary development. Arduino-flow-04.png

Environment Setup

Download and Install Arduino IDE

  • Click to visit the Arduino official website, select the corresponding system and system bit to download
    ESP32-S3-AMOLED-1.91-Ar-software-01.png
  • Run the installer and install all by default
The environment setup is carried out on the Windows 10 system, Linux and Mac users can access Arduino-esp32 environment setup for reference. (To use on Mac, you need to install the MAC driver.)

Install ESP32 Development Board

  • Before using ESP32-related motherboards with the Arduino IDE, you must first install the software package for the esp32 by Espressif Systems development board
  • According to board installation requirement, it is generally recommended to use Install Online. If online installation fails, use Install Offline.
  • For the installation tutorial, please refer to Arduino board manager tutorial
  • ESP32-S3-AUDIO-Board required development board installation description
Board name Board installation requirement Version number requirement
esp32 by Espressif Systems "Install Offline" / "Install Online" 3.2.0 and above

Install Library

  • When installing Arduino libraries, there are usually two ways to choose from: Install online and Install offline. If the library installation requires offline installation, you must use the provided library file
    For most libraries, users can easily search and install them through the online library manager of the Arduino software. However, some open-source libraries or custom libraries are not synchronized to the Arduino Library Manager, so they cannot be acquired through online searches. In this case, users can only manually install these libraries offline.
  • For library installation tutorial, please refer to Arduino library manager tutorial
  • ESP32-S3-AUDIO-Board library file is stored in the demo, click here to jump: ESP32-S3-AUDIO-Board Demo
    • ESP32-S3-AUDIO-Board library file installation description
Library Name Description Version Library Installation Requirement
LVGL Graphical library v8.3.10 "Install Offline"
ESP32-audioI2S-master Audio decoding library v2.0.0 "Install Offline"
es7210 Audio driver library xxx "Install Offline"
es8311 Audio driver library xxx "Install Offline"
esp_lcd_jd9853 LCD driver library xxx "Install Offline"
TCA9555 Expansion audio driver library xxx "Install Offline"
For more learning and use of LVGL, please refer to official documentation

Run the First Arduino Demo

If you are just getting started with ESP32 and Arduino, and you don't know how to create, compile, flash, and run Arduino ESP32 programs, then please expand and take a look. Hope it can help you!

New Project

  • Run the Arduino IDE and select File -> New Sketch
    ESP32-S3-AMOLED-1.91-Ar-study-01.png
  • Enter the code:
void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);
}

void loop() {
  // put your main code here, to run repeatedly:
  Serial.println("Hello, World!");
  delay(2000);
}
  • Save the project and select File -> Save As.... In the pop-up menu, select the path to save the project, and enter a project name, such as Hello_World, click Save

ESP32-S3-AMOLED-1.91-Ar-study-02.png

Compile and Flash Demos

  • Select the corresponding development board, take the ESP32S3 motherboard as an example:

①. Click to select the dropdown menu option Select Other Board and Port;
②. Search for the required development board model esp32s3 dev module and select;
③. Select COM Port;
④. Save the selection.
ESP32-S3-AMOLED-1.91-Ar-study-03.png

  • If the ESP32S3 mainboard only has a USB port, you need to enable USB CDC, as shown in the following diagram:

ESP32-S3-AMOLED-1.91-Ar-study-04.png

  • Compile and upload the program:

①. Compile the program; ②. Compile and download the program; ③. Download successful.
ESP32-S3-AMOLED-1.91-Ar-study-05.png

  • Open the Serial Monitor window, and the demo will print "Hello World!" every 2 seconds, and the operation is as follows:

ESP32-S3-AMOLED-1.91-Ar-study-06.png

Demo

Demo-flow-01.png

  • ESP32-S3-AUDIO-Board demo
Demo Basic Description Dependency Library
LVGL_Arduino Test onboard device functionality LVGL, ESP32-audioI2S-master

Arduino Project Parameter Setting

  • If the flashed demo has a speech recognition model, then select "ESP SR 16M (3MB APP/7MB SPIFFS/2.9MB MODEL)" for Partition Scheme
  • If the flashed demo doesn't have a speech recognition model, then select "16M Flash (3MB APP/9.9MB FATFS)" or other for Partition Scheme

ESP32-S3-Touch-LCD-1.46 Demo 2.png

LVGL_Arduino

Demo description


  • This demo demonstrates the functions of each device on the board. Screen 2 displays SD Card, Flash Size, Backlight brightness and other parameters, while screen 1 shows the music playback interface. In addition, this demo includes voice recognition function, which can only be used before playing audio
  • The demo can only run fully when the TF card with MP3 files, screen, and camera are connected.

Hardware connection


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

Code analysis


  • setup(): Initialize hardware, configure peripherals, etc.
    • Hardware initialization: setup() internally executes multiple initialization functions to configure and initialize hardware components connected to Arduino, such as RTC, gyroscope, LCD display, TF card, audio module, microphone, etc. With these initializations, it is ensured that the hardware is working properly
    • Graphics interface initialization: Call Lvgl_Init() to initialize LVGL (Light and Versatile Graphics Library), a widely used graphics library for embedded systems. Lvgl_Example1() is a demo that shows how to render a graphical interface on a display
    • Task scheduling: Driver_Loop() function creates a task (DriverTask) that manages and loops some peripheral operations
  • loop(): Mainly used for GUI updates and task scheduling
    • LVGL task loop: Lvgl_Loop() is a loop function of the LVGL library that handles graphical interface updates, event responses, and other UI-related operations. In embedded systems, graphics libraries often need to be called frequently in the main loop to keep the interface refreshed and the interaction real-time
    • Task scheduling control: vTaskDelay(pdMS_TO_TICKS(5)) is used to pause the task for 5 milliseconds. vTaskDelay is a delay function in FreeRTOS that aims to reduce CPU usage, avoid taking up too much time slice, and ensure that other tasks of the system, such as peripheral processing, can be performed on time

Result demonstration


  • LCD screen display parameter description
Parameter Function Description
SD Card Display TF card size Connect the TF card, if the recognition fails, please format the TF card to FAT32 format (please wait for a while to reset and check again if the recognition fails for the first time)
Flash Size Display Flash size Current onboard 16MB Flash
RTC Time Display RTC time Display current RTC time
If the RTC time is not consistent with the current time, because the data cannot be retained in the power-off state, if you need to keep the RTC time normal, you need to connect the RTC battery and update the RTC time
Backlight brightness Brightness slider Adjust screen brightness
  • Page 2 is the UI page for playing mp3 audio in the root directory of the TF card
  • This demo enables speech recognition by default, the wake-up word is "hi esp", after waking up, you can speak the command after the backlight is dimmed (if the backlight is not dimmed, it means that it has not been woken up, the recognition requirements are strict, the pronunciation needs to be standard, and the speech speed is slowed down)
  • The following are available in several formats of MIC test audio (Please note that every time the hi esp wake-up fails, please reset the audio to the playback location of the wake-up word and replay it)
  • Please do not perform speech recognition when using the speaker to play audio
  • The reason the wake-up word plays twice in the test audio is due to the current firmware version's initial wake-up requiring the device to be focused (an analogy), and the current firmware does not permit the disabling of this function
// Commands
Turn on the backlight
Turn off the backlight
Backlight is brightest
Backlight is darkest
*Note: The voice recognition feature is only available before playing the audio in the current demo.
  • Click the BOOT button to switch to displaying the images captured by the camera, and click it again to switch to the parameter display interface
  • LCD screen display

1800px-ESP32-S3-AUDIO-Board-Arduino.jpg

Switch to Chinese/English recognition model

The initial environment setting is for English recognition, and you can switch to Chinese recognition model or back to English recognition model by following these steps

Switch to Chinese recognition model


Chinese recognition environment setup

  • Download the provided demo file Demo using Chinese model
  • Enter the path C:\Users\Waveshare\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.0.2\libraries\ESP_SR\src (Waveshare is the computer username)
  • Replace the esp32-hal-sr.c in this path with the downloaded file
  • Download the Chinese model Chinese model - wake-up word hi 乐鑫
  • Enter the path C:\Users\Waveshare\AppData\Local\Arduino15\packages\esp32\tools\esp32-arduino-libs\idf-release_v5.1-bd2b9390ef\esp32s3\esp_sr (Waveshare is the computer username)
  • Replace the srmodels.bin in this path with the downloaded file
  • Modify the recognition command in the demo to Chinese command (Pinyin)

ESP32-S3-Touch-LCD-1.85 Program parsing 2.png

Switch to English recognition model


   English recognition environment setup

  • The initial state of the environment is the English recognition environment by default, and if it is not converted to Chinese, the following modifications are not made
  • If it has been previously modified to Chinese recognition, download the provided demo file Demo using English model
  • Enter the path C:\Users\Waveshare\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.0.2\libraries\ESP_SR\src (Waveshare is the computer username)
  • Replace the esp32-hal-sr.c in this path with the downloaded file
  • Download the English model English model - wake-up word hi esp
  • Enter the path C:\Users\Waveshare\AppData\Local\Arduino15\packages\esp32\tools\esp32-arduino-libs\idf-release_v5.1-bd2b9390ef\esp32s3\esp_sr (Waveshare is the computer username)
  • Replace the srmodels.bin in this path with the downloaded file
  • Modify the recognition command in the demo to English command (phonemes)

ESP32-S3-Touch-LCD-1.85 Program parsing 1.png

Working with ESP-IDF

This chapter introduces setting up the ESP-IDF environment setup, including the installation of Visual Studio and the Espressif IDF plugin, program compilation, downloading, and testing of demos, to assist users in mastering the development board and facilitating secondary development. ESP-IDF-flow-01.png

Environment Setup

Download and Install Visual Studio

  • Open the download page of VScode official website, choose the corresponding system and system bit to download
    ESP32-S3-AMOLED-1.91-VScode-01.png
  • After running the installation package, the rest can be installed by default, but here for the subsequent experience, it is recommended to check boxes 1, 2, and 3
    ESP32-S3-AMOLED-1.91-VScode-02.png
    • After the first two items are enabled, you can open VSCode directly by right-clicking files or directories, which can improve the subsequent user experience.
    • After the third item is enabled, you can select VSCode directly when you choose how to open it
The environment setup is carried out on the Windows 10 system, Linux and Mac users can access ESP-IDF environment setup for reference

Install Espressif IDF Plugin

  • It is generally recommended to use Install Online. If online installation fails due to network factor, use Install Offline
  • For more information about how to install the Espressif IDF plugin, see Install Espressif IDF Plugin
  • ESP32-S3-AUDIO-Board required Espressif IDF version description
Plugin name Plugin installation requirement Version number requirement
Espressif IDF "Install Offline" / "Install Online" 5.5.0

Run the First ESP-IDF Demo

If you are just getting started with ESP32 and ESP-IDF, and you don't know how to create, compile, flash, and run ESP-IDF ESP32 programs, then please expand and take a look. Hope it can help you!

New Project

ESP32-S3-AMOLED-1.91-study-01.png

ESP32-S3-AMOLED-1.91-study-02.png

Create Demo

  • Using the shortcut F1, enter esp-idf:show examples projects

ESP32-S3-AMOLED-1.91-study-03.png

  • Select your current IDF version

ESP32-S3-AMOLED-1.91-study-04.png

  • Take the Hello world demo as an example

①Select the corresponding demo
②Its readme will state what chip the demo applies to (how to use the demo and the file structure are described below, omitted here)
③Click to create the demo
ESP32-S3-AMOLED-1.91-study-05.png

  • Select the path to save the demo, and require that the demos cannot use folders with the same name

ESP32-S3-AMOLED-1.91-study-06.png

Modify COM Port

  • The corresponding COM ports are shown here, click to modify them
  • Please select the COM ports according to your device (You can view it from the device manager)
  • In case of a download failure, please press the Reset button for more than 1 second or enter download mode, and wait for the PC to recognize the device again before downloading once more

ESP32-S3-AMOLED-1.91-study-07.png

Modify Driver Object

  • Select the object we need to drive, which is our main chip ESP32S3

ESP32-S3-AMOLED-1.91-study-08.png

  • Choose the openocd path, it doesn't affect us here, so let's just choose one

ESP32-S3-AMOLED-1.91-study-09.png

Other Status Bar Functions

①.ESP-IDF Development Environment Version Manager, when our project requires differentiation of development environment versions, it can be managed by installing different versions of ESP-IDF. When the project uses a specific version, it can be switched to by utilizing it
②.Device flashing COM port, select to flash the compiled program into the chip
③.Select set-target chip model, select the corresponding chip model, for example, ESP32-P4-NANO needs to choose esp32p4 as the target chip
④.menuconfig, click it to modify sdkconfig configuration file, please refer to project configuration details
⑤.fullclean button, when the project compilation error or other operations pollute the compiled content, you can clean up all the compiled content by clicking it
⑥.Build project, when a project satisfies the build, click this button to compile
⑦.Current download mode, the default is UART
⑧.flash button, when a project build is completed, select the COM port of the corresponding development board, and click this button to flash the compiled firmware to the chip
⑨.monitor enable flashing port monitoring, when a project passes through Build --> Flash, click this button to view the log of output from flashing port and debugging port, so as to observe whether the application works normally
⑩.Debug
⑪.Build Flash Monitor one-click button, which is used to continuously execute Build --> Flash --> Monitor, often referred to as "little flame"

ESP32-S3-AMOLED-1.91-study-10.png

Compile, Flash and Serial Port Monitor

  • Click on the all-in-one button we described before to compile, flash and open the serial port monitor

ESP32-S3-AMOLED-1.91-study-11.png

  • It may take a long time to compile especially for the first time

ESP32-S3-AMOLED-1.91-study-12.png

  • During this process, the ESP-IDF may take up a lot of CPU resources, so it may cause the system to lag
  • If it is the first time to flash the program for a new project, you will need to select the download method, and select UART

ESP32-S3-AMOLED-1.91-study-13.png

  • This can also be changed later in the Download methods section (click on it to pop up the options)

ESP32-S3-AMOLED-1.91-study-14.png

  • As it comes with the onboard automatic download circuit, it can be downloaded automatically without manual operation
  • After successful download, it will automatically enter the serial monitor, you can see the chip output the corresponding information and be prompted to restart after 10S

ESP32-S3-AMOLED-1.91-study-15.png

Use the IDF Demos

The following takes ESP32-S3-LCD-1.47-Demo as an example to introduce the two opening methods of the project and the general steps of use, and the detailed explanation of the ESP-IDF project. If you use other projects, the operation steps can be applied similarly.

Open In the Software

  • Open VScode software and select the folder to open the demo

ESP32-S3-AMOLED-1.91-study-16.png

  • Select the provided ESP-IDF example and click to select the file (located in the /Demo/ESP-IDF path under demo)

ESP32-S3-AMOLED-1.91-study-17.png

Open from Outside the Software

  • Select the project directory correctly and open the project, otherwise it will affect the compilation and flashing of subsequent programs

ESP32-S3-AMOLED-1.91-study-18.png

  • After connecting the device, select the COM port and model, click below to compile and flash to achieve program control

ESP32-S3-AMOLED-1.91-study-19.png

ESP-IDF Project Details

  • Component: The components in ESP-IDF are the basic modules for building applications, each component is usually a relatively independent code base or library, which can implement specific functions or services, and can be reused by applications or other components, similar to the definition of libraries in Python development.
    • Component reference: The import of libraries in the Python development environment only requires to "import library name or path", while ESP-IDF is based on the C language, and the importing of libraries is configured and defined through CMakeLists.txt.
    • The purpose of CmakeLists.txt: When compiling ESP-IDF, the build tool CMake first reads the content of the top-level CMakeLists.txt in the project directory to read the build rules and identify the content to be compiled. When the required components and demos are imported into the CMakeLists.txt, the compilation tool CMake will import each content that needs to be compiled according to the index. The compilation process is as follows:

ESP32-P4 VSCode ESP-IDF GettingStart 240906 02.png

Demo

Demo-flow-01.png

  • EESP32-S3-AUDIO-Board demo
Demo Basic Description
factory_01 Factory demo running voice wake-up and recognition and controlling MP3 playback and lighting control at the same time
esp_sr_02 Runs the ESP-SR demo to achieve voice wake-up and recognition
mp3_play_03 Plays MP3 files from TF card
lvgl9_3_example_04 Run the LVGL9.3 demo

factory_01

Demo description


  • This demo integrates voice wake-up and recognition functions, supports MP3 playback control via buttons, and is paired with RGB lighting effects.
  • The demo requires a TF card with MP3 files to control the playback of MP3 with the keys.

Hardware connection


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

Code analysis


  • esp_board_init(): Initialize peripherals such as I2C, I2S, ES8311, and ES7210
    • Configure I2C parameters, including setting the master device mode, specifying the SDA and SCL pins, enabling the pull-up resistor, and determining the clock frequency
    • Configure I2S parameters and apply the configuration to actual hardware
    • Initialize ES8311 audio codec
    • Initialize ES7210
  • tca9555_driver_init(): Initialize and configure the external extension IO
    • Mount the TCA555 to the I2C bus device
    • Configure I/O port input and output
  • esp_sdcard_init(): Mount TF card
  • Speech_Init(): Initialize esp-sr to achieve voice wake-up and recognition
    • Create two tasks, one is to input I2S data to the ESP-SR model, and the other is to parse the recognition results
    • Speech_register_callback() is the callback function of the registration recognition result, and the user can define the processing logic of the callback function according to the needs. The same recognition result can correspond to multiple business operations without modifying the speech recognition module itself.
  • Audio_Play_Init(): Initialize the MP3 player to achieve functions such as playing, pausing, restoring, stopping, and adjusting volume
  • RGB_Example(): WS2812 initialization and related demonstration effects
  • key_module_init(): Initialize the key to achieve short and long presses
    • key_register_callback() registers a callback function for the key and handles user logic
  • Search_mp3_Music(): Search for MP3 files in the root directory of the TF card, and store the filenames and the number of MP3 files

Result demonstration


  • This demo will not light up the screen
  • This demo enables speech recognition by default, the wake-up word is "hi esp" (The recognition requirements are relatively strict, the pronunciation needs to be standard, and the speech speed is slowed down)
  • The following is the MIC test audio (Please note that every time the hi esp wake-up fails, please reset the audio to the playback location of the wake-up word and replay it)
  • The reason the wake-up word plays twice in the test audio is due to the current firmware version's initial wake-up requiring the device to be focused (an analogy), and the current firmware does not permit the disabling of this function
  • The K2 key can control MP3 playback and pause
  • Short press the K1 key to increase volume, long press to play the previous song
  • Short press the K3 key to decrease the volume, and long press to play the next song
  • The lights will cycle on when playing, and after recognizing the wake word "hi,esp", the lights will start to flash. If no other words are recognized within 6 seconds, it will time out and exit recognition
// Commands
灯光变成红色
灯光变成蓝色
灯光变成绿色
灯光变成白色
  • The serial monitor displays the following:

Audio demo1 1.png


esp_sr_02

Demo description


  • This example runs the ESP-SR demo

Hardware connection


  • Connect the development board to the computer

Result demonstration


// Commands
Turn on the backlight
Turn off the backlight
Backlight is brightest
Backlight is darkest

Audio demo2 1.png


mp3_play_03

Demo description


  • This example scans MP3 files in the root directory of the TF card upon startup and plays them

Hardware connection


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

Result demonstration


Audio demo3 1.png


lvgl9_3_example_04

Demo description


  • This demo demonstrates the functions of each device on the board. Screen 2 displays SD Card, Flash Size and other parameters, while screen 1 shows the music playback interface. In addition, this demo includes voice recognition function.

The demo can only run fully when the TF card with MP3 files, screen, and camera are connected.

Hardware connection


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

Code analysis


  • lcd_driver_init(): Initialize the screen
  • touch_driver_init(): Initialize the touch function
  • lvgl_driver_init(): Initialize the LVGL
  • Camera_Driver_Init(): Initializes the camera configuration parameters

Result demonstration


  • LCD screen display parameter description
Parameter Function Description
SD Card Display TF card size Connect the TF card, if the recognition fails, please format the TF card to FAT32 format (please wait for a while to reset and check again if the recognition fails for the first time)
Flash Size Display Flash size Current onboard 16MB Flash
RTC Time Display RTC time Display current RTC time
If the RTC time is not consistent with the current time, because the data cannot be retained in the power-off state, if you need to keep the RTC time normal, you need to connect the RTC battery and update the RTC time
camera test Display camera image Click on the blue box in the upper right corner to turn off the camera
Backlight brightness Brightness slider Adjust screen brightness
  • Page 2 is the UI page for playing mp3 audio in the root directory of the TF card
  • This demo enables speech recognition by default, the wake-up word is "hi esp", after waking up, you can speak the command after the backlight is dimmed (if the backlight is not dimmed, it means that it has not been woken up, the recognition requirements are strict, the pronunciation needs to be standard, and the speech speed is slowed down)
  • The following are available in several formats of MIC test audio (Please note that every time the hi esp wake-up fails, please reset the audio to the playback location of the wake-up word and replay it)
  • The reason the wake-up word plays twice in the test audio is due to the current firmware version's initial wake-up requiring the device to be focused (an analogy), and the current firmware does not permit the disabling of this function
// Commands
Turn on the backlight
Turn off the backlight
Backlight is brightest
Backlight is darkest
  • LCD screen display

Audio demo4 1.png


Switch to Chinese/English recognition model

The initial environment setting is for English recognition, and you can switch to Chinese recognition model or back to English recognition model by following these steps

Switch to Chinese/English recognition model


  • If the following two files exist in the project, delete these two files

ESP32-S3-Touch-LCD-1.85-demo-04.png

  • Enter the file sdkconfig.defaults, find here.
    • Use the "#" comment to switch to the English recognition model
    • Use the "#" comment to switch to the Chinese recognition model

Audio demo1 1.png

Generate Speech Control Command


Environment Preparation

  • Check if your computer has a Python environment
  • Open the command line: win+r -> enter cmd

①.Enter python --version and the python version number appears, which means that it is installed
②.Type where python to see where python is installed
Python-install-04.png
The Python environment under the C drive is the Python environment that is automatically installed when VS Code is installed;
The disk E contains the Python environment used in the following steps;

If you do not have installed environment, please refer to Python Environment Installation Tutorial, please continue if it is installed
  • On the command line, enter pip install g2p_en to install the g2p_en package
  • Install the resource package in the corresponding user's C:\Users\username\AppData\Roaming directory, and double-click to extract the file
  • On the command line, enter pip install pypinyin to install the pypinyin library

Generate Chinese Pinyin

  • Download the Chinese command generation file
  • Command line switches the path to Chinese command generation folder (the path varies from person to person, the following is only for reference)
cd /d E:\download\Generate_Chinese_command
  • Execute the command line multinet_pinyin.py to generate Chinese Pinyin
python multinet_pinyin.py "Chinese to be converted to Pinyin"
Example: Python multinet_pinyin.py "你好微雪电子"

ESP32-S3-Touch-LCD-1.85-demo-02.png

Generate English Phonemes

  • Download the English command generation file
  • Command line switch path to English command generation folder (the path varies from person to person, the following is only for reference)
cd /d E:\download\Generate_English_command
  • Execute the command line gen_sr_commands.py to generate English phonemes
python gen_sr_commands.py "English to be converted to phonemes"
Example: python gen_sr_commands.py "hello waveshare"

ESP32-S3-Touch-LCD-1.85-demo-03.png

Command Modification

In Arduino

ESP32-S3-Touch-LCD-1.85-demo-06.png

In ESP-IDF

  • Chinese commands

ESP32-S3-Touch-LCD-1.85-demo-10.png

  • English commands

ESP32-S3-Touch-LCD-1.85-demo-09.png

Flash Firmware Flashing and Erasing


  • The current demo provides test firmware, which can be used to test whether the onboard device functions properly by directly flashing the test firmware
  • bin file path:
    ..\ESP32-S3-AUDIO-Board-Demo\Firmware

Resources

Demo

Datasheets

ESP32-S3

Software Tools

Arduino

VScode

Firmware Flashing Tool

Other Resource Links

FAQ


 Answer:
  • Click the Reset button for more than 1 second, wait for the PC to re-recognize the device and then download again
  • Long press the BOOT button, press RESET at the same time, then release RESET, then release the BOOT button, at this time the module can enter the download mode, which can solve most of the problems that can not be downloaded.
  • Press and hold the BOOT button to reconnect the USB cable, and then release the BOOT button after the USB cable is connected, at this time the module can enter the download mode, which can solve most of the problems that can not be downloaded.


 Answer:

It may be due to Flash blank and the USB port is not stable, you can long-press the BOOT button, press RESET at the same time, and then release RESET, and then release the BOOT button, at this time the module can enter the download mode to flash the firmware (demo) to solve the situation.


 Answer:
  • It's normal for the first compilation to be slow, just be patient


 Answer:
  • Some AppData folders are hidden by default and can be set to show.
  • English system: Explorer->View->Check "Hidden items"
  • Chinese system: File Explorer -> View -> Display -> Check "Hidden Items"


 Answer:
  • Windows system:

①View through Device Manager: Press the Windows + R keys to open the "Run" dialog box; input devmgmt.msc and press Enter to open the Device Manager; expand the "Ports (COM and LPT)" section, where all COM ports and their current statuses will be listed.
②Use the command prompt to view: Open the Command Prompt (CMD), enter the "mode" command, which will display status information for all COM ports.
③Check hardware connections: If you have already connected external devices to the COM port, the device usually occupies a port number, which can be determined by checking the connected hardware.

  • Linux system:

①Use the dmesg command to view: Open the terminal.
①Use the ls command to view: Enter ls /dev/ttyS* or ls /dev/ttyUSB* to list all serial port devices.
③Use the setserial command to view: Enter setserial -g /dev/ttyS* to view the configuration information of all serial port devices.


 Answer:
  • This situation is that the TF card is not installed or the TF card cannot be recognized. If this situation occurs, please wait for a period of time to reset the device. If it still cannot be resolved, please format the TF card to FAT32 format. If it still fails, please try a different TF card



 Answer:

Depending on the demo you run, different demos have different refresh frame rates.


 Answer:

Whether you use the USB to UART tool to connect the UART pins, or enable USB CDC in Tools


 Answer:

Yes, it can be used simultaneously, but due to the larger memory usage of audio, the audio function cannot be turned on at the same time


 Answer:

MX1.25 interface 3.7V lithium battery


 Answer:

Use the one that corresponds to our interface and output voltage, the capacity depending on customer needs


 Answer:
  • Check the schematic diagram for different development boards with Type-C interfaces, and handle the output accordingly:
    • For development boards with direct USB output, printf function is supported for printing output. If you want to support output via the Serial function, you will need to enable the USB CDC On Boot feature or declare HWCDC.
    • For development boards with UART to USB conversion, both printf and Serial functions are supported for printing output, and there is no need to enable USB CDC On Boot.




 Answer:

OK, just the functions related to TF card cannot be used, and other functions are not affected


 Answer:

The screen and back panel of this type of product adopt an integrated bonding design. To ensure normal use, it is recommended to avoid disassembling or prying open the adhesive layer by yourself. If the screen is damaged due to disassembly, it cannot be repaired


Support



Technical Support

If you need technical support or have any feedback/review, please click the Submit Now button to submit a ticket, Our support team will check and reply to you within 1 to 2 working days. Please be patient as we make every effort to help you to resolve the issue.
Working Time: 9 AM - 6 PM GMT+8 (Monday to Friday)