ESP32-S3-Touch-LCD-2

From Waveshare Wiki
Jump to: navigation, search
ESP32-S3-Touch-LCD-2
ESP32-S3-Touch-LCD-2

2inch, 240×320, I2C/SPI
{{{name2}}}

{{{name3}}}

{{{name4}}}

{{{name5}}}

{{{name6}}}

Overview

Introduction

It is a low-cost, high-performance MCU board designed by Waveshare. Despite its compact size, it integrates a 2inch capacitive touch LCD, a lithium-ion battery charging chip, an IMU sensor, camera interface and various other peripherals on board for easy development and embedding into the product.

Features

  • Equipped with ESP32-S3R8 high-performance Xtensa 32-bit LX7 dual-core processor, up to 240 MHz main frequency
  • Supports 2.4GHz Wi-Fi (802.11 b/g/n) and Bluetooth 5 (BLE), with onboard antenna
  • Built in 512KB SRAM and 384KB ROM, with onboard 8MB PSRAM and an external 16MB Flash
  • ype-C connector, keeps it up to date, easier to use
  • Built-in 2inch capacitive touch LCD screen with a resolution of 240×320, 262K colors for clear color pictures
  • Embedded with ST7789T3 driver chip and CST816D capacitive touch control chip, using SPI and I2C communication respectively, minimizes required IO pins
  • Onboard QMI8658 6-axis IMU (3-axis accelerometer and 3-axis gyroscope)
  • Onboard 3.7V MX1.25 lithium battery recharge/discharge header
  • Onboard USB Type-C port for power supply, firmware downloading and debugging, making development more convenient
  • Onboard TF card slot, supporting external TF card storage for pictures or files
  • 22 × GPIO pins for flexible configuration of peripheral functions
  • On-board camera interface, compatible with mainstream cameras such as OV2640 and OV5640, suitable for image and video capture

Specifications

Parameter name Parameter
Interface USB Type-A
Controller chip ESP32-S3
LCD type ISP
LCD controller chip Display: ST7789T3
Onboard devices TF

Onboard Resources

ESP32-S3-Touch-LCD-2-details-13.jpg

Interfaces

ESP32-S3-Touch-LCD-2-details-inter.jpg

Dimensions

ESP32-S3-Touch-LCD-2-details-size.jpg

Usage Instructions

ESP32-S3-Touch-LCD-2 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 Tools

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-Touch-LCD-2 x1
  • OV5640 camera x1
  • TF card x 1 (32GB and below)
  • Card reader x1
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.

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

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-Touch-LCD-2 required development board installation description
Board name Board installation requirement Version number requirement
esp32 by Espressif Systems "Install Offline" / "Install Online" ≥3.0.0

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-Touch-LCD-2.8B library file path:
    ..\ESP32-S3-Touch-LCD-2.8B-Demo\Arduino\libraries
  • ESP32-S3-Touch-LCD-2 Library file installation instructions
Library Name Description Version Library Installation Requirement
lvgl Graphical library v8.4.0 "Install Online" (requires copying the demos folder to src)
GFX_Library_for_Arduino LCD driver library v1.5.0 "Install Online"
FastIMU IUM driver library v1.2.6 "Install Online"
bsp_cst816 Touch driver library -- "Install Offline"

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

  • Some development boards with specified version numbers support direct model selection, for example, "Waveshare ESP32-S3-LCD-1.69":

ESP32-S3-AMOLED-1.91-Ar-study-07.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

  • ESP32-S3-Touch-LCD-2 Demo
Demo Basic Description Dependency Library
01_factory Comprehensive testing program lvgl, GFX_Library_for_Arduino, FastIMU
02_gfx_helloworld HelloWorld is displayed on the screen GFX_Library_for_Arduino
03_sd_card_test Test TF card --
04_qmi8658_output Serial port prints QMI8658 data FastIMU
05_lvgl_qmi8658 Use the LVGL library to display QMI8658 data lvgl, FastIMU, bsp_cst816
06_lvgl_battery Use the LVGL library to display the battery voltage lvgl, GFX_Library_for_Arduino, bsp_cst816
07_lvgl_brightness Use the LVGL library to control and display screen brightness lvgl, GFX_Library_for_Arduino, bsp_cst816
08_lvgl_example lvgl demos lvgl, GFX_Library_for_Arduino, bsp_cst816
09_lvgl_camera Use the LVGL library to display the camera images lvgl, GFX_Library_for_Arduino, bsp_cst816
10_camera_web_server Display the camera images on the web page --

Arduino Project Parameter Setting

  • Each demo must be configured with parameters before flashing

ESP32-S3-Touch-LCD-2-demo-17.png

01_factory

【Demo description】


This demo tests the functionality of the ESP32-S3-Touch-LCD-2 onboard module, the information of each module will be displayed on the screen, and the user can switch between pages through the touch screen

【Hardware connection】


  • Connect the board to the computer
  • Plug the OV5640 camera into the 24Pin socket on the board (if it is not available, it will not affect the use of other functions)
  • Insert the TF card into the card slot (if it is not available, it will not affect the use of other functions)

400px-ESP32-S3-Touch-LCD-2-demo-01.png

【Code analysis】


  • Hardware initialization
Serial.begin(115200);
bsp_i2c_init();          //Initialize I2C bus, commonly used to connect sensors, displays, etc.
bsp_lv_port_init();      //Initialize the LVGL graphics library port to output graphics to display devices such as LCD
bsp_spi_init();          //Initialize SPI bus, commonly used for communication with sensors, external storage, screens, etc.
  • LVGL graphics library configuration
bsp_lv_port_run();       //Run LVGL-related drivers or loops, such as refreshing the display, etc.
if (lvgl_lock(-1)) {     //Lock LVGL resources to ensure they do not conflict with other tasks when updating the UI
  lvgl_ui_init();        //Initialize UI, possibly including layout and control settings
  lvgl_unlock();         //Unlock LVGL, allowing other tasks to access LVGL
}
  • Peripheral initialization
app_qmi8658_init();                     //Initialize QMI8658 sensor (such as accelerometer, gyroscope, etc.)
app_system_init();                      //Perform system-level initialization, such as clock, memory, reset, etc
app_camera_init();                      //Initialize the camera module, prepare for image capture
app_wifi_init(sta_ssid, sta_pass);      //Initialize Wi-Fi module, connect to specified Wi-Fi network
  • Application layer tasks running
app_qmi8658_run();       //Start QMI8658 sensor-related tasks, such as data acquisition, processing, etc.
app_system_run();        //Start system tasks to ensure that system functions are running properly
app_camera_run();        //Start camera-related tasks, usually to obtain image data and process or transmit it
app_wifi_run();          //Start Wi-Fi related tasks, such as connection management, data transmission, etc.

【Result demonstration】


  • System interface

400px-ESP32-S3-Touch-LCD-2-demo-02.png

  • QMI8658 interface, where you can see the acceleration and angular velocity data of the acquired X, Y, and Z axes

400px-ESP32-S3-Touch-LCD-2-demo-03.png

  • Camera interface, where you can see the images captured by the camera

400px-ESP32-S3-Touch-LCD-2-demo-04.png

  • WiFi interface, showing the WiFi name and password to be connected, IP will be displayed after successful connection

400px-ESP32-S3-Touch-LCD-2-demo-05.png


02_gfx_helloworld

【Demo description】


This demo demonstrates the ESP32-S3-Touch-LCD-2 using the GFX_Library_for_Arduino library to drive the screen and display HelloWorld on the screen.

【Hardware connection】


  • Connect the board to the computer

【Code analysis】


  • Create an object bus of the Arduino_ESP32SPI class to configure the SPI bus GPIO, and create an object gfx of the Arduino_ST7789 class to drive the ST7789 display
Arduino_DataBus *bus = new Arduino_ESP32SPI(
  EXAMPLE_PIN_NUM_LCD_DC /* DC */, EXAMPLE_PIN_NUM_LCD_CS /* CS */,
  EXAMPLE_PIN_NUM_LCD_SCLK /* SCK */, EXAMPLE_PIN_NUM_LCD_MOSI /* MOSI */, EXAMPLE_PIN_NUM_LCD_MISO /* MISO */);

/* More display class: https://github.com/moononournation/Arduino_GFX/wiki/Display-Class */
Arduino_GFX *gfx = new Arduino_ST7789(
  bus, EXAMPLE_PIN_NUM_LCD_RST /* RST */, EXAMPLE_LCD_ROTATION /* rotation */, true /* IPS */,
  EXAMPLE_LCD_H_RES /* width */, EXAMPLE_LCD_V_RES /* height */);

【Result demonstration】


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


03_sd_card_test

【Demo description】


This demo demonstrates how to use ESP32-S3-Touch-LCD-2 to test the read and write functions of the TF card

【Hardware connection】


  • Connect the board to the computer
  • Insert the TF card into the card slot (TF card needs to be formatted as FAT32)

【Code analysis】


  • SPI interface initialization and TF card initialization
  SPI.begin(sck, miso, mosi, cs);
  if (!SD.begin(cs)) {
    Serial.println("Card Mount Failed");
    return;
  }

【Result demonstration】


  • Open the serial port monitor

ESP32-S3-Touch-LCD-2-demo-07.png

  • Insert the TF card into the computer, and you can find two more files: test.txt and foo.test. The content of the foo.txt is Hello World!, and the content of the test.txt is empty

ESP32-S3-Touch-LCD-2-Demo-Arduino-3-2.png


04_qmi8658_output

【Demo description】


This demo demonstrates how to use ESP32-S3-Touch-LCD-2 to acquire QMI8658 data and print using serial port

【Hardware connection】


  • Connect the board to the computer

【Code analysis】


  • Initialize QMI8658
int err = IMU.init(calib, IMU_ADDRESS);
if (err != 0) {
  Serial.print("Error initializing IMU: ");
  Serial.println(err);
  while (true) {
    ;
  }
}

【Result demonstration】


  • Open the serial port monitor to see the printed x, y, z axis accel and gyro as well as the qmi8658 internal temperature sensor data

ESP32-S3-Touch-LCD-2-demo-08.png


05_lvgl_qmi8658

【Demo description】


This demo demonstrates how to use ESP32-S3-Touch-LCD-2 to acquire QMI8658 data and display it using the lvgl library

【Hardware connection】


  • Connect the board to the computer

【Code analysis】


  • Initialize the UI and create a 100ms timer to obtain data from QMI8658
lvgl_qmi8658_ui_init(lv_scr_act());

【Result demonstration】


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


06_lvgl_battery

【Demo description】


This demo demonstrates how to use ESP32-S3-Touch-LCD-2 to display battery voltage and ADC values on the screen using the lvgl library

【Hardware connection】


  • Connect the board to the computer
  • Insert the battery into the battery holder

【Code analysis】


  • Initialize the UI and create a 1000ms timer to obtain the data of the adc and convert the data into a voltage
lvgl_battery_ui_init(lv_scr_act());

【Result demonstration】


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


07_lvgl_brightness

【Demo description】


This demo demonstrates how to use ESP32-S3-Touch-LCD-2 to display the screen brightness on the screen using the lvgl library, and the screen brightness can be controlled through the slider

【Hardware connection】


  • Connect the board to the computer

【Code analysis】


  • Initialize the UI, and create a slider value change callback, when the value of the slider changes, modify the screen brightness
lvgl_brightness_ui_init(lv_scr_act());

【Result demonstration】


ESP32-S3-Touch-LCD-2-demo-11.png


08_lvgl_example

【Demo description】


This demo demonstrates how to use ESP32-S3-Touch-LCD-2 to run the lvgl demos

【Hardware connection】


  • Connect the board to the computer

【Precautions】


  • If the lvgl library is installed online, you need to copy the demos folder to src

【Code analysis】


  • Select the lvgl demos to run
lv_demo_widgets();
// lv_demo_benchmark();
// lv_demo_keypad_encoder();
// lv_demo_music();
// lv_demo_stress();

【Result demonstration】


  • It can be operated by touch

ESP32-S3-Touch-LCD-2-demo-12.png

09_lvgl_camera

【Demo description】


This demo uses the LVGL library to display images captured from the camera on the ESP32-S3-Touch-LCD-2 screen

【Hardware connection】


  • Connect the board to the computer
  • Plug the OV5640 camera into the 24Pin socket on the board

【Code analysis】


  • Create a task specifically for acquiring camera images
xTaskCreatePinnedToCore(camera_task, "camera_task_task", 1024 * 3, NULL, 1, NULL, 0);
  • Obtain camera images and update display
    camera_fb_t *pic;
    lv_img_dsc_t img_dsc;
    img_dsc.header.always_zero = 0;
    img_dsc.header.w = 480;
    img_dsc.header.h = 320;
    img_dsc.data_size = 320 * 480 * 2;
    img_dsc.header.cf = LV_IMG_CF_TRUE_COLOR;
    img_dsc.data = NULL;
    // lv_img_set_src(img_camera, &pic);
    while (1)
    {
        pic = esp_camera_fb_get();

        if (NULL != pic)
        {
            img_dsc.data = pic->buf;
            if (lvgl_lock(-1))
            {
                lv_img_set_src(img_camera, &img_dsc);
                lvgl_unlock();
            }
        }
        esp_camera_fb_return(pic);
        vTaskDelay(pdMS_TO_TICKS(1));
    }

【Result demonstration】


400px-ESP32-S3-Touch-LCD-2-Demo-IDF-4-1.jpg


10_camera_web

【Demo description】


This demo demonstrates how to use ESP32-S3-Touch-LCD-2 to drive the camera. After connecting to WiFi, the program will create a web server, and users can access it by entering the device's IP address in the browser. Web pages can display images from cameras and support settings such as resolution and mirroring

【Hardware connection】


  • Connect the board to the computer
  • Plug the OV5640 camera into the 24Pin socket on the board

【Code analysis】


  • Select the camera model and define the relevant pins and configurations
#define CAMERA_MODEL_ESP_EYE  // Has PSRAM

#define PWDN_GPIO_NUM 17  // Power down is not used
#define RESET_GPIO_NUM -1 // Software reset will be performed
#define XCLK_GPIO_NUM 8
#define SIOD_GPIO_NUM 21
#define SIOC_GPIO_NUM 16

#define Y9_GPIO_NUM 2
#define Y8_GPIO_NUM 7
#define Y7_GPIO_NUM 10
#define Y6_GPIO_NUM 14
#define Y5_GPIO_NUM 11
#define Y4_GPIO_NUM 15
#define Y3_GPIO_NUM 13
#define Y2_GPIO_NUM 12
#define VSYNC_GPIO_NUM 6
#define HREF_GPIO_NUM 4
#define PCLK_GPIO_NUM 9
  • Password of the wifi account to be connected
const char *ssid = "waveshare";
const char *password = "12345678";
  • Start the camera server and start providing HTTP video streaming services
startCameraServer();

Serial.print("Camera Ready! Use 'http://");
Serial.print(WiFi.localIP());
Serial.println("' to connect");

【Result demonstration】


  • Open the serial port terminal after connecting to WiFi to see the IP address

ESP32-S3-Touch-LCD-2-demo-13.png

  • Use the browser (the device with hotspot enabled) to open the IP address for serial port printing
  • Click Start Stream to see the image of the camera

ESP32-S3-Touch-LCD-2-demo-14.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.

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 OIffline
  • For more information about how to install the Espressif IDF plugin, see Install Espressif IDF Plugin

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 path to openocd, 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 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

  • ESP32-S3-Touch-LCD-2 Demo
Demo Basic Description
01_sd_card_test Test TF card
02_lvgl_qmi8658 Use lvgl library to display qmi8658 data
03_lvgl_brightness Use lvgl library to control and display screen brightness
04_lvgl_battery Use lvgl library to display battery voltage
05_lvgl_camera Use lvgl library to display camera images
06_lvgl_example Display lvgl demos

01_sd_card_test

【Demo description】


This demo demonstrates how to use ESP32-S3-Touch-LCD-2 to test the read and write functions of the TF card

【Hardware connection】


  • Connect the board to the computer
  • Insert the TF card into the card slot (TF card needs to be formatted as FAT32)

【Code analysis】


  • SPI initialization
    sdmmc_host_t host = SDSPI_HOST_DEFAULT();

    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;
    }
  • TF card initialization and mounting
    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);

【Result demonstration】


  • Serial port monitor

600px-ESP32-S3-Touch-LCD-2-Demo-IDF-1-1.png

  • Insert the TF card into the computer, and you can find three more files: test.txt, FOO.TXT and NIHAO.TXT. Among them, the content of the FOO.TXT is Hello SD!, the content of the NIHAO.TXT is Hello SD!, and the content of the test.txt is empty

ESP32-S3-Touch-LCD-2-Demo-IDF-1-2.png


02_lvgl_qmi8658

【Demo description】


This demo demonstrates how to use ESP32-S3-Touch-LCD-2 to acquire QMI8658 data and display it using the lvgl library

【Hardware connection】


  • Connect the board to the computer

【Code analysis】


  • Initialize the UI and create a 100ms timer to obtain data from QMI8658
lvgl_qmi8658_ui_init(lv_scr_act());

【Result demonstration】


ESP32-S3-Touch-LCD-2-demo-15.png


03_lvgl_brightness

【Demo description】


This demo demonstrates how to use ESP32-S3-Touch-LCD-2 to display the screen brightness on the screen using the lvgl library, and the screen brightness can be controlled through the slider

【Hardware connection】


  • Connect the board to the computer

【Code analysis】


  • Initialize the UI, and create a slider value change callback, when the value of the slider changes, modify the screen brightness
lvgl_brightness_ui_init(lv_scr_act());

【Result demonstration】


ESP32-S3-Touch-LCD-2-demo-16.png



04_lvgl_battery

【Demo description】


This demo demonstrates how to use ESP32-S3-Touch-LCD-2 to display battery voltage and ADC values on the screen using the lvgl library

【Hardware connection】


  • Connect the board to the computer
  • Insert the lithium battery into the battery holder

【Code analysis】


  • Initialize the UI and create a 1000ms timer to obtain the data of the adc and convert the data into a voltage
lvgl_battery_ui_init(lv_scr_act());

【Result demonstration】


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


05_lvgl_camera

【Demo description】


This demo uses the LVGL library to display images captured from the camera on the ESP32-S3-Touch-LCD-2 screen

【Hardware connection】


  • Connect the board to the computer
  • Plug the OV5640 camera into the 24Pin socket on the board

【Code analysis】


  • Create a task specifically for acquiring camera images
xTaskCreatePinnedToCore(camera_task, "camera_task_task", 1024 * 3, NULL, 1, NULL, 0);
  • Obtain camera images and update display
    camera_fb_t *pic;
    lv_img_dsc_t img_dsc;
    img_dsc.header.always_zero = 0;
    img_dsc.header.w = 480;
    img_dsc.header.h = 320;
    img_dsc.data_size = 320 * 480 * 2;
    img_dsc.header.cf = LV_IMG_CF_TRUE_COLOR;
    img_dsc.data = NULL;
    // lv_img_set_src(img_camera, &pic);
    while (1)
    {
        pic = esp_camera_fb_get();

        if (NULL != pic)
        {
            img_dsc.data = pic->buf;
            if (lvgl_lock(-1))
            {
                lv_img_set_src(img_camera, &img_dsc);
                lvgl_unlock();
            }
        }
        esp_camera_fb_return(pic);
        vTaskDelay(pdMS_TO_TICKS(1));
    }

【Result demonstration】


400px-ESP32-S3-Touch-LCD-2-Demo-IDF-4-1.jpg


06_lvgl_example

【Demo description】


This demo demonstrates how to use ESP32-S3-Touch-LCD-2 to run the lvgl demos

【Hardware connection】


  • Connect the board to the computer

【Code analysis】


  • Initialize the demo
    lv_init();
    display_init();
    touch_init(); 
    lv_port_disp_init();
    lv_port_indev_init();
    lvgl_tick_timer_init(EXAMPLE_LVGL_TICK_PERIOD_MS);
    bsp_brightness_init();
    bsp_brightness_set_level(80);
  • Select the lvgl demos to run
        lv_demo_widgets();
        // lv_demo_benchmark();
        // lv_demo_keypad_encoder();
        // lv_demo_music();
        // lv_demo_stress();

【Result demonstration】


  • It can be operated by touch

ESP32-S3-Touch-LCD-2-demo-12.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-Touch-LCD-2-Demo\Firmware

Resources

Schematic Diagram

Demo

Project Documents

Datasheets

ESP32-S3

Software Tools

Arduino

VScode

Firmware Flashing Tool

Other Resource Links

FAQ

 Answer:
  • Long press the BOOT button, plug in the USB at the same time, 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.


 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:
  • If there is a reset button on the development board, press the reset button; if there is no reset button, please power it on again


 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.




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)