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

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 pins reserved on the ESP32-C6-Touch-LCD-1.83 board, pay attention to the wire colors and 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.
To run the example, you need to install the corresponding library. The example code uses the GFX Library for Arduino library to drive the ST7789 display and the Arduino_DriveBus library to drive the CST816 touch controller.
You can click this link to download the example package for the ESP32-C6-Touch-LCD-1.83 board from the Arduino directory. The Arduino\libraries directory within this package contains all the necessary library files required for this tutorial.
| Library or File Name | Description | Version | Installation Method |
|---|---|---|---|
| GFX Library for Arduino | ST7789 display driver graphics library | v1.6.0 | Install via library manager or manually |
| SensorLib | PCF85063, QMI8658 sensor driver library | v0.3.1 | Install via library manager or manually |
| XPowersLib | AXP2101 driver library | v0.3.0 | Install via library manager or manually |
| lvgl | LVGL display framework | v8.4.0 | Install via library manager or manually |
| Arduino_DriveBus | I2C, touch driver library | v1.0.1 | 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 example 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.
You need to select and configure the development board for ESP32-C6-Touch-LCD-1.83.

The printf() function can be used directly;
To use the Serial.println() function, additional configuration is required: Enable the "USB CDC On Boot" option in the IDE's Tools menu, or declare an HWCDC object in your code to handle USB serial communication.
The Arduino examples are located in the Arduino/examples directory of the example package.
| Example | Basic Description | Dependency Library |
|---|---|---|
| 01_sd_test | Demonstrates basic TF card mounting process, file read/write test | |
| 02_audio_out | Play MP3 audio | |
| 03_axp2101_example | Power management chip AXP2101 test | XPowersLib |
| 04_qmi8658_example | IMU QMI8658 test | SensorLib |
| 05_pcf85063_example | RTC real-time clock PCF85063 test | SensorLib |
| 06_gfx_helloworld | A simple ST7789 screen driver example | GFX_Library_for_Arduino |
| 07_LVGL_Arduino | LVGL v8.4 example program | Arduino_DriveBus, GFX_Library_for_Arduino, lvgl |
This example demonstrates how to use SPI to mount a TF card and test file read/write operations

Initialize SPI and mount the TF card:
#ifdef REASSIGN_PINS
SPI.begin(sck, miso, mosi, cs);
if (!SD.begin(cs)) {
#else
if (!SD.begin()) {
#endif
Serial.println("Card Mount Failed");
return;
}
uint8_t cardType = SD.cardType();
if (cardType == CARD_NONE) {
Serial.println("No TF card attached");
return;
}
Serial.print("TF Card Type: ");
if (cardType == CARD_MMC) {
Serial.println("MMC");
} else if (cardType == CARD_SD) {
Serial.println("SDSC");
} else if (cardType == CARD_SDHC) {
Serial.println("SDHC");
}else{
Serial.println("UNKNOWN");
}
uint64_t cardSize = SD.cardSize() / (1024 * 1024);
Serial.printf("TF Card Size: %lluMB\n", cardSize);
Test file read/write:
listDir(SD, "/", 0);
createDir(SD, "/mydir");
listDir(SD, "/", 0);
removeDir(SD, "/mydir");
listDir(SD, "/", 2);
writeFile(SD, "/hello.txt", "Hello ");
appendFile(SD, "/hello.txt", "World!\n");
readFile(SD, "/hello.txt");
deleteFile(SD, "/foo.txt");
renameFile(SD, "/hello.txt", "/foo.txt");
readFile(SD, "/foo.txt");
testFileIO(SD, "/test.txt");
Serial.printf("Total space: %lluMB\n", SD.totalBytes() / (1024 * 1024));
Serial.printf("Used space: %lluMB\n", SD.usedBytes() / (1024 * 1024));
This example demonstrates how to play audio using I2S. It has no display on the screen, and will automatically play audio after flashing
Initialize peripherals such as I2C, I2S, and configure the ES8311 decoder:
Serial.begin(115200);
Wire.begin(I2C_SDA, I2C_SCL);
es8311_codec_init();
setupI2S();
Serial.println("I2S Initialized");
pinMode(PA_CTRL_PIN, OUTPUT);
digitalWrite(PA_CTRL_PIN, HIGH);
This example demonstrates how to use a power management chip and print battery-related information

Initialize QMI8658:
bool result = power.begin(Wire, AXP2101_SLAVE_ADDRESS, i2c_sda, i2c_scl);
This example prints the running results of imu qmi8658

Initialize qmi8658:
ret = qmi.begin(Wire, QMI8658_L_SLAVE_ADDRESS, SENSOR_SDA, SENSOR_SCL);
This example prints the value of RTC real-time clock pcf85063

Initialize qmi8658:
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:
uint16_t year = 2023;
uint8_t month = 9;
uint8_t day = 7;
uint8_t hour = 11;
uint8_t minute = 24;
uint8_t second = 30;
// Set the defined date and time on the RTC
rtc.setDateTime(year, month, day, hour, minute, second);
This example drives the screen and continuously prints "Hello World!" on the screen.

Initialize the SPI bus and the screen:
Arduino_DataBus *bus = new Arduino_HWSPI(LCD_DC, LCD_CS, LCD_SCK, LCD_DIN);
Arduino_GFX *gfx = new Arduino_ST7789(
bus, LCD_RST, 0 /* rotation */, true /* IPS */,
240 /* width */, 284 /* height */);
Fill with "Hello World":
gfx->setCursor(random(gfx->width()), random(gfx->height()));
gfx->setTextColor(random(0xffff), random(0xffff));
gfx->setTextSize(random(6) /* x scale */, random(6) /* y scale */, random(2) /* pixel_margin */);
gfx->println("Hello World!");
This example uses the Arduino_GFX_Library to drive the ST7789 screen, while porting LVGL and the touch driver

Initialize the SPI bus and the screen:
Arduino_DataBus *bus = new Arduino_HWSPI(LCD_DC, LCD_CS, LCD_SCK, LCD_DIN);
Arduino_GFX *gfx = new Arduino_ST7789(
bus, LCD_RST, 0 /* rotation */, true /* IPS */,
LCD_WIDTH /* width */, LCD_HEIGHT /* height */);
Initialize the CST816 touch controller:
std::unique_ptr<Arduino_IIC> CST816T(new Arduino_CST816x(IIC_Bus, CST816T_DEVICE_ADDRESS,
-1, TP_INT, Arduino_IIC_Touch_Interrupt));
Initialize LVGL, configure the touch driver, and load the LVGL example program:
screenWidth = gfx->width();
screenHeight = gfx->height();
lv_init();
lv_color_t *buf1 = (lv_color_t *)heap_caps_malloc(screenWidth * screenHeight / 4 * sizeof(lv_color_t), MALLOC_CAP_DMA);
lv_color_t *buf2 = (lv_color_t *)heap_caps_malloc(screenWidth * screenHeight / 4 * sizeof(lv_color_t), MALLOC_CAP_DMA);
String LVGL_Arduino = "Hello Arduino! ";
LVGL_Arduino += String('V') + lv_version_major() + "." + lv_version_minor() + "." + lv_version_patch();
USBSerial.println(LVGL_Arduino);
USBSerial.println("I am LVGL_Arduino");
#if LV_USE_LOG != 0
lv_log_register_print_cb(my_print); /* register print function for debugging */
#endif
lv_disp_draw_buf_init(&draw_buf, buf1, buf2, screenWidth * screenHeight / 4);
/*Initialize the display*/
static lv_disp_drv_t disp_drv;
lv_disp_drv_init(&disp_drv);
/*Change the following line to your display resolution*/
disp_drv.hor_res = screenWidth;
disp_drv.ver_res = screenHeight;
disp_drv.flush_cb = my_disp_flush;
disp_drv.draw_buf = &draw_buf;
lv_disp_drv_register(&disp_drv);
/*Initialize the (dummy) input device driver*/
static lv_indev_drv_t indev_drv;
lv_indev_drv_init(&indev_drv);
indev_drv.type = LV_INDEV_TYPE_POINTER;
indev_drv.read_cb = my_touchpad_read;
lv_indev_drv_register(&indev_drv);
lv_obj_t *label = lv_label_create(lv_scr_act());
lv_label_set_text(label, "Hello Ardino and LVGL!");
lv_obj_align(label, LV_ALIGN_CENTER, 0, 0);
const esp_timer_create_args_t lvgl_tick_timer_args = {
.callback = &example_increase_lvgl_tick,
.name = "lvgl_tick"
};
const esp_timer_create_args_t reboot_timer_args = {
.callback = &example_increase_reboot,
.name = "reboot"
};
esp_timer_handle_t lvgl_tick_timer = NULL;
esp_timer_create(&lvgl_tick_timer_args, &lvgl_tick_timer);
esp_timer_start_periodic(lvgl_tick_timer, EXAMPLE_LVGL_TICK_PERIOD_MS * 1000);
lv_demo_widgets();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 uses lvgl and brookesia components to build an APP-style interface that can be developed and installed independently for various applications.






This example uses the ES7210 encoding chip for recording tests, and the audio file is stored in the root directory of the TF card.

Code Analysis
Initialize the TF card and the ES7210 chip:
/* Init I2C bus to configure ES7210 and I2S bus to receive audio data from ES7210 */
i2s_chan_handle_t i2s_rx_chan = es7210_i2s_init();
/* Create ES7210 device handle and configure codec parameters */
es7210_codec_init();
/* Mount TF card, the recorded audio file will be saved into it */
sdmmc_card_t *sdmmc_card = mount_sdcard();
Start recording:
esp_err_t err = record_wav(i2s_rx_chan);
This example uses ES8311 to play MP3 audio from the TF card, the audio name needs to be set to 1.MP3.

Code Analysis
Initialize the TF card and the ES8311 chip, and initialize the MP3 playback library:
sd_card_init();
ESP_ERROR_CHECK(esp_board_init(16000, 1, 16));
//esp_sdcard_init("/sdcard", 10);
Audio_Play_Init();
Play the MP3:
Audio_Play_Music("file://sdcard/1.mp3");
This example ports LVGL and plays the LVGL example

Code Analysis
Initialize I2C, LCD, touch IC, and LVGL:
i2c_master_init();
lcd_driver_init();
touch_driver_init();
lvgl_driver_init();
Use the LVGL mutex to load the official LVGL example:
lvgl_port_lock(0);
lv_demo_stress();
lvgl_port_unlock();
This example drives the AXP2101 and prints battery-related information

Code Analysis
Initialize I2C and the AXP2101:
ESP_ERROR_CHECK(i2c_init());
ESP_LOGI(TAG, "I2C initialized successfully");
ESP_ERROR_CHECK(pmu_init());
Create a printing task:
xTaskCreate(pmu_hander_task, "App/pwr", 4 * 1024, NULL, 10, NULL);
This example uses lvgl to display images, and you can switch between images by swiping left and right.

Code Analysis
Use the LVGL mutex to initialize image display:
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.
ESP32-C6-Touch-LCD-1.83-Demo\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-C6 Chip Official Manuals
Datasheets
Monday-Friday (9:30-6:30) Saturday (9:30-5:30)
Email: services01@spotpear.com