Google Chat: zj734465502@gmail.com
+86-0755-88291180
sales@spotpear.com
dragon_manager@163.com
tech-support@spotpear.com
zhoujie@spotpear.com
WhatsApp:13246739196
ESP32-C3-LCD-0.71 is a microcontroller development board that supports 2.4GHz WiFi and BLE 5. It is equipped with a 0.71-inch LCD screen, capable of smoothly running GUI interface programs such as LVGL; combined with various peripheral interfaces, it enables rapid development of low-power AI simulation eyes, watches, and other HMI applications based on the ESP32-C3
MCU | ESP32-C3FH4 | Display size | 0.71 inch |
---|---|---|---|
Operating voltage | 3.3V | Resolution | 160 × 160 |
Backlight current | 20mA | Display panel | IPS |
Display Interface | 4-wire SPI | Driver IC | GC9D01 |
Dimensions | 20.12×22.3×1.81 (H×V×D) (mm) | Brightness | 350 cd/㎡ (typical) |
1. RESET button 2. BOOT button 3. ESP32-C3FH4 processor 4. 2.4G ceramic antenna | 5. ME6217C33M5G 6. PL4054 7. USB Type-C interface |
TFT_MOSI | GPIO7 |
---|---|
TFT_SCLK | GPIO6 |
TFT_CS | GPIO5 |
TFT_DC | GPIO4 |
TFT_RST | GPIO8 |
ESP32-C3-LCD-0.71 currently provides Arduino-IDF development tools and frameworks, providing flexible development options, you can choose the right development tool according to your project needs and personal habits.
Arduino IDEArduino 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 |
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
Board name | Board installation requirement | Version number requirement |
---|---|---|
esp32 by Espressif Systems | "Install Offline" / "Install Online" | 2.0.13 |
Library Name | Description | Library Installation Requirements |
---|---|---|
TFT_eSPI | LCD driver library | "Install Offline" |
LVGL | LVGL library | "Install Offline" |
lv_conf.h | LVGL configuration file | "Install Offline" |
File
-> New Sketch
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);
}
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
①. 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.
①. Compile the program; ②. Compile and download the program; ③. Download successful.
Demo | Description | Dependency Library |
---|---|---|
01_Text_and_Number_Display | Text and nymber display | TFT_eSPI |
02_Shapes_on_Circular_Display | Drawing | TFT_eSPI |
03_Animated_Eye1 | Simulated eye style1 | TFT_eSPI |
04_Animated_Eye2 | Simulated eye style2 | TFT_eSPI |
05_Animated_Eye12 | Simulated eye styles1 and 2, displayed alternately | TFT_eSPI |
06_Image_Display | Display image | TFT_eSPI and LVGL |
07_Clock | Clock | TFT_eSPI and LVGL |
【Demo description】
【Hardware connection】
【Code analysis】
setup
function executes once when the program starts, primarily responsible for initializing the TFT display and performing some initial settingstft.init();
initializes the TFT display, preparing for subsequent display operationstft.fillScreen()
and delay()
, demonstrating the color filling capabilities of the TFT display, enhancing the visual appeal during program startuptft.fillScreen(0x04FF);
sets a specific background color, tft.setTextColor(TFT_WHITE, 0x04FF);
sets the text color, ensuring the text is clearly visible against the backgroundtft.drawString("Hello, Waveshare!", 30, 40, 2);
displays a welcome message, enhancing the user experienceloop
function continuously loops during the running process of the program, realizing the core functionality of displaying numbersnumber
to a string displayNumber
, and add a leading zero when the number is a single digit, ensuring that single-digit numbers are displayed as two-digit numberstft.drawString(displayNumber, 55, 80, 6);
displays formatted numbers at a specific font size at a specific location on the displaynumber++
realizes self-increment of numbers, and resets to 0 when number
exceeds 99, ensuring that the number cycles between 00 and 99delay(1000)
controls the speed at which the numbers are updated, allowing users to clearly see the changes in the numbers【Demo flashing】
【Result demonstration】
【Demo description】
【Hardware connection】
【Code analysis】
uint16_t squareColor = tft.color565(random(0, 255), random(0, 255), random(0, 255));
generates a random RGB565 color, ensuring that the square is different in color each time it is drawntft.fillRect(squareTopLeftX, squareTopLeftY, squareSize, squareSize, squareColor);
fills the square with a random colortriangleX
and triangleY
arraystft.fillTriangle(triangleX[0], triangleY[0], triangleX[1], triangleY[1], triangleX[2], triangleY[2], triangleColor);
fills the triangle with a random colortft.fillCircle(centerX, centerY, 30, circleColor);
draws a circle with the screen center coordinates and a fixed radius, filling it with a random color【Demo flashing】
【Result demonstration】
【Demo description】
【Hardware connection】
【Code analysis】
LIGHT_PIN
is definedint16_t v = analogRead(LIGHT_PIN);
LIGHT_PIN_FLIP
(#ifdef LIGHT_PIN_FLIP
section)if (v < LIGHT_MIN) v = LIGHT_MIN; else if (v > LIGHT_MAX) v = LIGHT_MAX;
), ensuring that the light sensitivity value is within a reasonable range.v = map(v, 0, (LIGHT_MAX - LIGHT_MIN), IRIS_MAX, IRIS_MIN);
)LIGHT_CURVE
is defined (#ifdef LIGHT_CURVE
section)IRIS_SMOOTH
is defined, choose the smoothing treatment (filtering method gradually adjusts the iris size) or directly set the iris sizenewIris = random(IRIS_MIN, IRIS_MAX);
split(oldIris, newIris, micros(), 10000000L, IRIS_MAX - IRIS_MIN);
function to achieve a gradual change in iris size from the old value to the new value through a recursive method, and update oldIris
with the new valuedigitalWrite(device_A_CS, LOW);
to set the chip select pin of device A to low to select the corresponding device or displaytft.pushImage(0, 0, 160, 160, gImage_Ax);
to send specific images (such as gImage_A1
to gImage_A12
) to the display area. The parameter (0, 0, 160, 160)
here might have specified the starting coordinates and size of the image on the displaydigitalWrite(device_A_CS, HIGH);
to set the chip select pin to high to deselect the current device or displaydelay(frameTime);
to control the display time of each image, so as to achieve a coherent effect of animation【Demo flashing】
【Result demonstration】
【Demo description】
【Hardware connection】
【Code analysis】
tft.startWrite();
: Start writing data to the TFT displaytft.setAddrWindow(area->x1, area->y1, area->x2 - area->x1 + 1, area->y2 - area->y1 + 1);
: Sets the write address window of the TFT display according to the incoming display area parameter (area
) to specify the range of the screen area to which data will be writtentft.pushColors(&color_p->full, (area->x2 - area->x1 + 1) * (area->y2 - area->y1 + 1), true);
: Pushes the color data (color_p
) provided by LVGL to the TFT display according to the specified area size (the number of pixels obtained by calculating the product of the width and height of the area), where true
means that the color pointer is automatically incremented after the data is pushed, so that the next push starts from the next pixel positiontft.endWrite();
: Ends the write operation of the TFT display and completes the data transmissionlv_disp_flush_ready(disp);
: Notifies LVGL that the current refresh operation has been completed, and LVGL can continue to perform subsequent graphics processing operations, such as preparing the next frame of dataprintf("LVGL_disp_flush\n");
: Printouts debugging informationlv_init();
and tft.begin();
: Initializes the LVGL library, initializes the TFT displaylv_disp_draw_buf_init(&draw_buf, buf, NULL, screenHeight * screenWidth / 15);
: Initialize the display buffer of LVGL, where buf is an array of buffers used to store display data, NULL means that double buffers are not used (here you can adjust them as needed), screenHeight * screenWidth / 15
calculates the size of the buffer, and reasonable buffer settings help to improve the display performancelv_disp_drv_init(&disp_drv);
: Initializes the display driver structure disp_drv
of the LVGLdisp_drv.flush_cb = my_disp_flush;
: Sets the previously defined my_disp_flush
function as a display-driven refresh callback function, so that LVGL can call it to update the screen content when it needs to refresh the displaydisp_drv.draw_buf = &draw_buf;
: Associates the previously initialized display buffer draw_buf
with the display driver ensures that the graphics data is properly stored and transmitted to the displaylv_disp_drv_register(&disp_drv);
: Registers the display driver, which enables LVGL to use the configured display driver for graphic display operations, and the connection and configuration of LVGL to the TFT display is complete【Demo flashing】
【Result demonstration】
【Demo description】
【Hardware connection】
【Code analysis】
a == 1
, then fill the screen with black first (tft.fillScreen(BLACK);
), then call the Demo_1
function, and finally delay 2 seconds with delay(2000);
a == 2
, then use an inner loop to execute the Demo_2
function multiple times, where the number of times the loop runs is controlled by the variable i
, with the loop running 7 times The Demo_2
function will sequentially display a series of images to achieve an animation effect. In this way, the two different animation sequences can be continuously executed in a loop during the operation of the program【Demo flashing】
【Result demonstration】
【Demo description】
【Hardware connection】
【Code analysis】
w
and the height h
of the area to be refreshed, ensuring accurate determination of the data rangetft.setAddrWindow
, specifying the correct position for data writingtft.pushColors
to push the color data to the display, this step determines the color and content of the displayed graphicsSerial.begin(115200)
prepares the serial port communication for possible debugginglv_init()
starts the core components of the LVGL libraryLV_USE_LOG
is not 0, register the serial print function for debugging: lv_log_register_print_cb(my_print)
tft.begin()
: Initializes the TFT hardwaretft.setRotation(0)
: Sets the display orientation to landscapelv_disp_draw_buf_init(&draw_buf, buf, NULL, screenWidth * screenHeight / 10)
, preparing for storing graphic datalv_disp_drv_init(&disp_drv)
initializes the display driver structureLV_IMG_DECLARE(A3)
, then creates an image object logo_img and sets its source to a declared image, and finally sets the position of the image object on the screen through lv_obj_center
and lv_obj_align
【Demo flashing】
【Result demonstration】
【Demo description】
【Hardware connection】
【Code analysis】
LV_USE_LOG
is not 0, register the serial port print function to view the LVGL log informationui_init
to initialize user interface elements【Demo flashing】
【Result demonstration】
..\ESP32-C3-LCD-0.71-Demo\Firmware
①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.
①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.
Monday-Friday (9:30-6:30) Saturday (9:30-5:30)
Email: services01@spotpear.com