Google Chat:---
+86-0755-88291180
sales@spotpear.com
dragon_manager@163.com
tech-support@spotpear.com
zhoujie@spotpear.com
WhatsApp:13246739196
WhatsApp:13424403025


This chapter contains the following sections. Please read as needed:
New to Arduino ESP32 development and looking for a quick start? We have prepared a comprehensive Getting Started Tutorial for you.
Note: This tutorial uses the ESP32-S3-Zero as a reference example, and all hardware code is based on its pinout. Before you start, we recommend checking the pinout of your development board to ensure the pin configuration is correct.
Please refer to the tutorial Installing and Configuring Arduino IDE to download and install the Arduino IDE and add ESP32 support.
Arduino directory. The Arduino\libraries directory within this package contains all the necessary library files required for this tutorial.| Library/File Name | Description | Version | Installation Method |
|---|---|---|---|
| GFX Library for Arduino | ST7789 display driver graphics library | v1.6.4 | Install via library manager or manually |
| SensorLib | PCF85063, QMI8658 sensor driver library | v0.3.3 | Install via library manager or manually |
| XPowersLib | AXP2101 driver library | v0.2.6 | Install via library manager or manually |
| lvgl | LVGL display framework | v8.4.0 | Install via library manager or manually |
| Mylibrary | Board pin macro definition | —— | Install manually |
| lv_conf.h | LVGL configuration file | —— | Install manually |
There are strong dependencies between versions of LVGL and its driver libraries. For example, a driver written for LVGL v8 may not be compatible with LVGL v9. To ensure that the examples can be reproduced reliably, it is recommended to use the specific versions listed in the table above. Mixing different versions of libraries may lead to compilation failures or runtime errors.
Installation Steps:
Download the demo package.
Copy all folders (Arduino_DriveBus, GFX_Library_for_Arduino, etc.) in the Arduino\libraries directory to the Arduino library folder.
The path to the Arduino libraries folder is typically: c:\Users\<username>\Documents\Arduino\libraries.
You can also locate it in the Arduino IDE by going to File > Preferences and checking the "Sketchbook location". The libraries folder is the libraries subfolder within this path.
For other installation methods, please refer to: Arduino Library Management Tutorial.
The Arduino demos are located in the Arduino/examples directory of the demo package.
| Demo | Basic Description | Dependency Library |
|---|---|---|
| 01_HelloWorld | Demonstrates the basic graphics library function and can also be used to test the basic performance of display screens and the display effect of random text | GFX_Library_for_Arduino |
| 02_GFX_AsciiTable | Prints ASCII characters in rows and columns on the screen according to the screen size | GFX_Library_for_Arduino |
| 03_LVGL_AXP2101_ADC_Data | Drives the AXP2101 using the ported XPowersLib to get power-related data | GFX_Library_for_Arduino |
| 04_LVGL_QMI8658_ui | LVGL draws an acceleration line chart | LVGL, SensorLib |
| 05_LVGL_Widgets | LVGL demonstration | LVGL, Arduino_DriveBus, Adafruit_XCA9554 |
| 06_ES7210 | ES7210 driver demo, picking up human voice for detection | —— |
| 07_ES8311 | ES8311 driver example, plays simple audio | —— |
Display initialization:
if (!gfx->begin()) {
USBSerial.println("gfx->begin() failed!");
}
Clear the screen and display text:
gfx->fillScreen(BLACK);
gfx->setCursor(10, 10);
gfx->setTextColor(RED);
gfx->println("Hello World!");
Animated display:
gfx->setCursor(random(gfx->width()), random(gfx->height()));
gfx->setTextColor(random(0xffff), random(0xffff));
gfx->setTextSize(random(6), random(6), random(2));
gfx->println("Hello World!");

Create data bus and graphic display objects
bus is created for communicating with the display, initialized with specific pin configurations. Then a graphics display object gfx is created, passing parameters such as the data bus, reset pin, rotation angle, whether it is an IPS panel, and the width and height of the display Arduino_DataBus *bus = new Arduino_ESP32QSPI(
LCD_CS /* CS */, LCD_SCLK /* SCK */, LCD_SDIO0 /* SDIO0 */, LCD_SDIO1 /* SDIO1 */,
LCD_SDIO2 /* SDIO2 */, LCD_SDIO3 /* SDIO3 */);
Arduino_GFX *gfx = new Arduino_SH8601(bus, -1 /* RST */,
0 /* rotation */, false /* IPS */, LCD_WIDTH, LCD_HEIGHT);
Draw row and column numbers and character table
gfx->setTextColor(GREEN);
for (int x = 0; x < numRows; x++) {
gfx->setCursor(10 + x * 8, 2);
gfx->print(x, 16);
}
gfx->setTextColor(BLUE);
for (int y = 0; y < numCols; y++) {
gfx->setCursor(2, 12 + y * 10);
gfx->print(y, 16);
}
char c = 0;
for (int y = 0; y < numRows; y++) {
for (int x = 0; x < numCols; x++) {
gfx->drawChar(10 + x * 8, 12 + y * 10, c++, WHITE, BLACK);
}
}

Screen on/off function
void toggleBacklight() {
USBSerial.println(backlight_on);
if (backlight_on) {
for (int i = 255; i >= 0; i--) {
gfx->Display_Brightness(i);
delay(3);
}
}else{
for(int i = 0;i <= 255;i++){
gfx->Display_Brightness(i);
delay(3);
}
}
backlight_on = !backlight_on;
}

setup: Responsible for initializing various hardware devices and the LVGL graphics library environment
USBSerial.begin(115200) prepares for serial debuggingloop
lv_timer_handler(): This is an important function in the LVGL graphics library, used to handle various timer events, animation updates, input processing, and other tasks for the graphical interface. Calling this function in each loop ensures the graphical interface runs smoothly and responds to interactions promptly
setup: Responsible for initializing various hardware devices and the LVGL graphics library environmentUSBSerial.begin(115200) prepares for serial debuggingWire.begin(IIC_SDA, IIC_SCL); initializes I2C bus for communicating with other I2C deviceslv_demo_widgets() to showcase LVGL example widgetslooplv_timer_handler(): This is an important function in the LVGL graphics library, used to handle various timer events, animation updates, input processing, and other tasks for the graphical interface. Calling this function in each loop ensures the graphical interface runs smoothly and responds to interactions promptlydelay(5): Adds a small delay to avoid excessive CPU resource consumption
es8311_codec_init: Initializes the ES8311 audio codecsetup: Performs overall initialization settings, including serial port, pins, I2S, and the ES8311 codeces8311_codec_init function to initialize the ES8311 codecThis chapter contains the following sections. Please read as needed:
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.
For the ESP32-S3-Touch-AMOLED-2.16 development board, ESP-IDF V5.5 or above is required.
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.
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.

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

Please wait for both files to finish downloading.
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.

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.

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

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

Download and install Visual Studio Code.
During installation, it is recommended to check Add "Open with Code" action to Windows Explorer file context menu to facilitate opening project folders quickly.
In VS Code, click the Extensions icon in the Activity Bar on the side (or use the shortcut Ctrl + Shift + X) to open the Extensions view.
Enter ESP-IDF in the search box, locate the ESP-IDF extension, and click Install.

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.
The ESP-IDF demos are located in the ESP-IDF directory of the demo package.
| Demo | Basic Description |
|---|---|
| 01_AXP2101 | Gets power-related data by driving the AXP2101 via the ported XPowersLib |
| 02_lvgl_demo_v9 | LVGL Demonstration |
| 03_esp-brookesia | Demonstrates a complete phone-style UI system, including status bar, navigation bar, app launcher, and gesture interaction components |
| 04_Immersive_block | Uses the QMI8658 six-axis sensor to collect acceleration data, driving randomly generated geometric shapes rendered by the LVGL graphics library to move in sync with device tilt |
| 05_Spec_Analyzer | Showcases a real-time audio spectrum visualization analyzer, presenting audio frequency distribution intuitively via 64 colored symmetrical spectrum bars with peak tracking |
i2c_init: Initializes the I2C master device, preparing it for communication with other devices (e.g., the PMU)pmu_register_read: Reads a series of byte data from a specific register of the PMU

![]() ![]() ![]() |
|---|
generate_random_shapes(): Generates graphics randomlylv_obj_set_pos) and stores it in the shapes arrayperform_level_calibration(): Core function for horizontal calibrationaccel_bias_x/y)calibration_done flag and prints the bias information
timer_cb: LVGL timer callback function, responsible for spectrum visualization renderinglv_canvas_finish_layer to commit the layer rendering and updates the canvas displaylv_example_canvas_10: Canvas initializationLV_DRAW_BUF_DEFINE_STATIC to define a 300×150 pixel RGB565 format draw buffertimer_cb callback function, and passes the canvas object as user data to enable timed rendering
XiaozhiAI (XiaoZhi AI) is an open-source AI voice chatbot project based on the ESP32 development board, aiming to bring the general intelligence of large language models (LLMs) to edge devices. It provides a software-hardware integrated solution supporting full-duplex voice conversations and IoT device control, dedicated to assisting developers in building highly customized physical AI agents quickly and at low cost.
This article demonstrates how to flash firmware for Waveshare ESP32 development boards that support XiaoZhi AI, covering two methods: flashing without a development environment (directly flashing precompiled firmware) and flashing with a development environment (compiling from source and flashing).
This section uses the ESP32-S3-Touch-AMOLED-1.8 development board as an example. The steps are similar for other development boards.
Please first confirm that your hardware is listed in the XiaoZhi AI Supported Products List.

Visit the XiaoZhi GitHub to download the firmware file for your device. Click Assets to expand the full file list:

Refer to the Flash Firmware Flashing and Erasing Tutorial to complete the firmware flashing.
This repository aggregates firmware for Waveshare ESP32 development boards that support XiaoZhi AI. All firmware has been tested and verified on the corresponding boards, making it convenient for users to find and download. Firmware versions may be updated slightly later than the official XiaoZhi repository.
Visit the Waveshare GitHub repository and download the appropriate firmware version for your needs:

Refer to the Flash Firmware Flashing and Erasing Tutorial to complete the firmware flashing.
Visit the XiaoZhi AI Chatbot repository to download the complete project code:

Refer to the ESP-IDF Environment Setup Tutorial to configure the development environment.
Click to select the target device. Choose the chip model corresponding to your development board (e.g.,
esp32s3):

When setting the target device, ESP-IDF will automatically configure the corresponding toolchain and libraries. This process may take some time, please be patient. For more details, please refer to the Official Documentation.
Click to open the ESP-IDF terminal, then execute the command
idf.py menuconfig to enter the configuration interface. Select Xiaozhi Assistant:

Select Board Type to choose the development board type:

Choose the product model corresponding to your development board:

Press the S key to save the configuration and exit. Then click the to automatically complete compilation, flashing, and serial monitoring.
Connect your phone or computer to the device's Wi-Fi hotspot: Xiaozhi-xxxxxx. After successful connection, the configuration page should automatically pop up. If not, manually open a browser and visit http://192.168.4.1.
On the network configuration page, select the Wi-Fi name you want to connect to (only 2.4G band is supported; to connect to an iPhone hotspot, enable Max Compatibility in your phone's system settings). The SSID will be auto-filled. Enter the password and click Connect to start connecting:

Ensure the device has successfully connected to the Internet. The device will then broadcast a 6-digit device verification code (you can wake the device again to replay the code).
Visit the XiaoZhi AI Console. If you haven't registered, complete the registration and log in:



Enter the 6-digit verification code. The device will automatically activate and appear on the Device Management page, ready for normal use.
Say the wake word "Hello XiaoZhi" to wake the device and start voice conversations.
ESP32-S3-Touch-AMOLED-1.8 Button Instructions:

Development Board Design Files
Official ESP32-S3 Chip Manuals
Datasheets