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

LCD and its Controller
SPI Communication Protocol:

Note: The SPI interface here is specifically designed for screen display, therefore the data line from slave to master (MISO) is omitted.
RESX is the Reset pin; it is pulled low during module power-up and is normally set to 1.
CSX is the slave chip select pin; the chip is enabled only when CS is low
D/CX is the data/command control pin of the chip. When DC = 0, commands are written; when DC = 1, data is written.
SDA is the data transmission pin, specifically for RGB data.
SCL is the SPI communication clock pin.
For SPI communication, data transmission follows a specific timing sequence, which are determined by the combination of clock phase (CPHA) and clock polarity (CPOL):
The level of CPHA determines whether data is captured on the first or second clock transition edge of the serial synchronous clock. When CPHA = 0, data is captured on the first transition edge;
The level of CPOL determines the idle level of the serial synchronous clock. CPOL = 0 means the idle state is low level.
As can be seen from the diagram, data transmission begins at the first falling edge of SCL. One clock cycle transmits 1 bit of data, using SPI0 mode, transmitted bit by bit with the Most Significant Bit (MSB) first and the Least Significant Bit (LSB) last.
When using the GPIO terminals reserved on the ESP32-Touch-LCD-3.5 board, pay attention to the wire colors and their corresponding functions to avoid burnout of the development board due to wiring habits


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.
You can click this link to download the example package for the ESP32-Touch-LCD-3.5 board from the 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 |
|---|---|---|---|
| ESP32-audioI2S-master | Audio processing library | v3.4.0 | Via Library Manager or manual |
| GFX_Library_for_Arduino | GFX graphics library | v1.6.0 | Via Library Manager or manual |
| lvgl | LVGL graphics library | v8.4.0 | Via Library Manager or manual |
| OneButton | Button library | v2.6.1 | Via Library Manager or manual |
| SensorLib | Sensor driver library | v0.3.1 | Via Library Manager or manual |
| TCA9554 | I/O expander library | v0.1.2 | Via Library Manager or manual |
| XPowersLib | Power management library | v0.2.9 | Via Library Manager or manual |
| ESP32-A2DP | Bluetooth audio processing | — | Manual |
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 example package.
Copy all folders (GFX_Library_for_Arduino, ESP32-audioI2S-master, etc.) in the Arduino\libraries directory to the Arduino libraries 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.
For ESP32-Touch-LCD-3.5 Arduino project parameter setting, you need to select the ESP32 Dev Module.

The Arduino examples are located in the Arduino/examples directory of the example package.
| Example | Basic Description | Dependency Library |
|---|---|---|
| 01_i2s_audio | Read audio files from the TF card and play them | ESP32-audioI2S-master |
| 02_axp2101_example | Print data from the power management IC | XPowersLib |
| 03_button_example | Button test | OneButton |
| 04_es8311_example | Record audio for a period and play it back | es8311 |
| 05_pcf85063_example | Print data from the RTC | SensorLib |
| 06_tca9554_example | I/O expander test | TCA9554 |
| 07_sd_card_test | Test TF card read/write | - |
| 08_gfx_helloworld | Display "HelloWorld" on the screen | GFX_Library_for_Arduino, TCA9554 |
| 09_lvgl_arduino_v8 | lvgl v8.4.0 example program | GFX_Library_for_Arduino, TCA9554, lvgl, SensorLib |
| 10_lvgl_arduino_v9 | lvgl v9.3.0 example program | GFX_Library_for_Arduino, TCA9554, lvgl, SensorLib |
| 11_bt_music_receiver_arduino_i2s | Bluetooth music playback example | ESP32-A2DP, GFX_Library_for_Arduino, TCA9554, OneButton |
This example demonstrates the ESP32-Touch-LCD-3.5 reading audio files from the TF card and playing them through the speaker, supporting MP3, AAC, WAV, and other formats.
The device will play auido directly without showing content on the screen
Initialize the I2C peripheral, configure the ES8311 codec, and enable the PA_CTRL amplifier pin:
Wire.begin(I2C_SDA, I2C_SCL);
TCA.begin();
TCA.pinMode1(2,OUTPUT);
TCA.write1(2, 1);
es8311_codec_init();
Initialize the I2S peripheral, mount the TF card, set the playback volume, and play the MP3 file at path music/1.mp3:
SPI.begin(SPI_SCK, SPI_MISO, SPI_MOSI, SD_CS);
if (!SD.begin(SD_CS)) {
esp_rom_printf("Card Mount Failed\n");
while (1) {
};
}
audio.setPinout(I2S_BCLK, I2S_LRC, I2S_DOUT);
audio.setVolume(21); // 0...21
audio.connecttoFS(SD, "music/1.mp3");
This example demonstrates using XPowers to drive the AXP2101 and prints data over the serial port.

Initialize the I2C peripheral and the AXP2101 battery management IC:
bool result = power.begin(Wire, AXP2101_SLAVE_ADDRESS, i2c_sda, i2c_scl);
if (result == false) {
Serial.println("power is not online...");
while (1) delay(50);
}
This example demonstrates using the OneButton library to read the single-click, double-click, and long-press states of the BOOT, PWR, and PLUS buttons, and prints them over the serial port.

Bind button event callback functions:
button1.attachClick(click1);
button1.attachDoubleClick(doubleclick1);
button1.attachLongPressStart(longPressStart1);
button1.attachLongPressStop(longPressStop1);
button1.attachDuringLongPress(longPress1);
This example demonstrates driving the ES8311 audio codec with the ESP32-Touch-LCD-3.5 to implement audio recording and playback.
Initialize I2C, ES8311 and I2S:
Wire.begin(I2C_SDA, I2C_SCL);
es8311_codec_init();
setupI2S();
Record audio for 5 seconds and play the recorded content:
wav_buffer = i2s.recordWAV(5, &wav_size);
delay(1000);
Serial.println("I2S playWAV");
i2s.playWAV(wav_buffer, wav_size);
This example demonstrates driving the PCF85063 with the ESP32-Touch-LCD-3.5 to set and retrieve time and date.

Initialization:
// Try to initialize the RTC module using I2C with specified SDA and SCL pins
if (!rtc.begin(Wire, SENSOR_SDA, SENSOR_SCL)) {
Serial.println("Failed to find PCF85063 - check your wiring!");
// Enter an infinite loop to halt the program
while (1) {
delay(1000);
}
}
Set the time and date:
rtc.setDateTime(year, month, day, hour, minute, second);
Get the time and date:
RTC_DateTime datetime = rtc.getDateTime();
This example demonstrates driving the TCA9554 with ESP32-Touch-LCD-3.5 to perform read and write operations on the pins of the extended IO.

Set pin mode:
TCA.pinMode1(pin, OUTPUT);
Set pin level:
TCA.write1(pin, LOW);
Read pin level:
int val = TCA.read1(pin);
This example demonstrates testing TF card read/write functionality with the ESP32-Touch-LCD-3.5.
*Connect the board to the computer *Insert the TF card into the card slot (the TF card must be formatted as FAT32)

Initialization:
if(!SD_MMC.setPins(clk, cmd, d0)){
Serial.println("Pin change failed!");
return;
}
if (!SD_MMC.begin( "/sdcard", true)) {
Serial.println("Card Mount Failed");
return;
}
This example demonstrates using the GFX_Library_for_Arduino library to drive the screen on the ESP32-Touch-LCD-3.5 and display "HelloWorld".

Configure the screen interface and resolution, etc.:
Arduino_DataBus *bus = new Arduino_ESP32SPI(27 /* DC */, 5 /* CS */, 18 /* SCK */, 23 /* MOSI */, 19 /* MISO */);
Arduino_GFX *gfx = new Arduino_ST7796(bus, GFX_NOT_DEFINED /* RST */, 0 /* rotation */, true /* IPS */);
This example demonstrates running an LVGL (v8.4.0) example program on the ESP32-Touch-LCD-3.5.


setup():
loop():
lv_timer_handler to let LVGL handle GUI tasksThis example demonstrates running an LVGL (v9.3.0) example program on the ESP32-Touch-LCD-3.5.


my_disp_flush():
gfx object function to draw the bitmap to the specified area.loop():
lv_timer_handler to let LVGL handle GUI tasksdelay(5) to increase the data polling frequency, ensuring timely retrieval of sensor data and display updates.This example demonstrates using the ESP32-Touch-LCD-3.5 to connect via Bluetooth and play music, with song information displayed on the screen.

*QQ Music: Settings ->Lyrics ->Car Bluetooth Lyrics *NetEase Cloud Music: Settings - > General - > External Devices - > External Devices Bluetooth Lyrics
*Connect to Bluetooth from your phone or tablet. (Model: ESP32-Touch-LCD-3.5) *The song information is displayed on the screen.

This chapter includes 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.
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.
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.
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).

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 examples are located in the ESP-IDF directory of the example package.
This example is a comprehensive demonstration for the ESP32-Touch-LCD-3.5 and is also the factory-default flashed example.





Code Analysis
Initialize various system peripherals and load the LVGL display demo:
esp_i2c_port_init(&i2c_bus_handle);
esp_spi_port_init(LCD_BUFFER_SIZE);
esp_sdcard_port_init();
io_expander_init();
esp_3inch5_display_port_init(&io_handle, &panel_handle, LCD_BUFFER_SIZE);
esp_3inch5_touch_port_init(&touch_handle, i2c_bus_handle, EXAMPLE_LCD_H_RES, EXAMPLE_LCD_V_RES, EXAMPLE_DISPLAY_ROTATION);
esp_axp2101_port_init(i2c_bus_handle);
vTaskDelay(pdMS_TO_TICKS(200));
esp_es8311_port_init(i2c_bus_handle);
esp_pcf85063_port_init(i2c_bus_handle);
esp_wifi_port_init("WSTEST", "waveshare0755");
esp_3inch5_brightness_port_init();
esp_3inch5_brightness_port_set(80);
lv_port_init();
This example demonstrates using the XPowersLib library to drive the AXP2101 on the ESP32-Touch-LCD-3.5 and prints battery information over the serial port.

This example demonstrates using the espressif/button library to drive the button on the ESP32-Touch-LCD-3.5 and uses the BOOT button to wake the system from sleep mode.

This example demonstrates driving the PCF85063 on the ESP32-Touch-LCD-3.5 using the sensorlib library and prints its data over the serial port.

This example demonstrates driving the TCA9554 on the ESP32-Touch-LCD-3.5 using the espressif/esp_io_expander_tca9554 library, allowing input/output operations on the I/O expander.

This example demonstrates testing TF card read/write functionality with the ESP32-Touch-LCD-3.5.
*Connect the board to the computer *Insert the TF card into the card slot (the TF card must be formatted as FAT32)

SPI initialization:
spi_bus_config_t bus_cfg = {
.mosi_io_num = PIN_NUM_MOSI,
.miso_io_num = PIN_NUM_MISO,
.sclk_io_num = PIN_NUM_CLK,
.quadwp_io_num = -1,
.quadhd_io_num = -1,
.max_transfer_sz = 4000,
};
ret = spi_bus_initialize(host.slot, &bus_cfg, SDSPI_DEFAULT_DMA);
if (ret != ESP_OK) {
ESP_LOGE(TAG, "Failed to initialize bus.");
return;
}
Initialize and mount the TF card:
sdspi_device_config_t slot_config = SDSPI_DEVICE_CONFIG_DEFAULT();
slot_config.gpio_cs = PIN_NUM_CS;
slot_config.host_id = host.slot;
ESP_LOGI(TAG, "Mounting filesystem");
ret = esp_vfs_fat_sdspi_mount(mount_point, &host, &slot_config, &mount_config, &card);
This example demonstrates running an LVGL example program on the ESP32-Touch-LCD-3.5.

Initialize LCD, screen touch, and LVGL:
app_i2c_init();
app_io_expander_init();
/* LCD HW initialization */
ESP_ERROR_CHECK(app_lcd_init());
/* Touch initialization */
ESP_ERROR_CHECK(app_touch_init());
/* LVGL initialization */
ESP_ERROR_CHECK(app_lvgl_init());
This example uses LVGL to implement an MP3 player. The example scans MP3 files in the root directory of the memory card for playback.
*Insert the TF card into the card slot (the TF card must be formatted as FAT32 and have MP3 files placed in its root directory).

Initialize I2C, I2S, and the audio codec:
app_i2c_init();
app_io_expander_init();
ESP_ERROR_CHECK(esp_board_init(16000, 2, 16));
Initialize the screen, memory card, and player, then scan MP3 files on the memory card and save them to an array:
/* LCD HW initialization */
ESP_ERROR_CHECK(app_lcd_init());
esp_sdcard_init("/sdcard", 5);
Audio_Play_Init();
Search_mp3_Music();
Initialize touch and LVGL, and load the player interface:
/* Touch initialization */
ESP_ERROR_CHECK(app_touch_init());
/* LVGL initialization */
ESP_ERROR_CHECK(app_lvgl_init());
lvgl_port_lock(0);
lv_app_music_init();
lvgl_port_unlock();
This example uses LVGL to display images and supports switching between images by swiping left or right.

Load the image and initialize gesture swipe events; switch images in the gesture event:
lvgl_port_lock(0);
image_slider_init();
lvgl_port_unlock();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:
This product provides test firmware that can be flashed directly to verify whether the onboard devices are functioning properly.
Firmware directory of the example package.0x00The following uses flashing the ESP32-S3-Touch-LCD-2.8 factory firmware as an example. The same steps apply when flashing other firmware.
Download and extract Espressif's official Flash Download Tool (Download)
Run flash_download_tool_3.9.7.exe and select the development board's MCU and download interface, such as ESP32-S3 and USB (most devices use USB; refer to the product's hardware design for the correct interface).

Parameter settings

Wait for flashing to complete (this may take some time; please be patient)
Press the reset button and verify the result

Development Board Design Files
ESP32 Chip Official Manuals
Onboard Component Datasheets
Monday-Friday (9:30-6:30) Saturday (9:30-5:30)
Email: services01@spotpear.com