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 examples. It aims to help users master the development board and facilitate secondary development. This chapter includes the following sections. Please read as needed:
Arduino Getting Started
New to Arduino ESP32 development and looking for a quick start? We have prepared a comprehensive Getting Started Tutorial for you.
- Section 0: Getting to Know ESP32
- Section 1: Installing and Configuring Arduino IDE
- Section 2: Arduino Basics
- Section 3: Digital Output/Input
- Section 4: Analog Input
- Section 5: Pulse Width Modulation (PWM)
- Section 6: Serial Communication (UART)
- Section 7: I2C Communication
- Section 8: SPI Communication
- Section 9: Wi-Fi Basics
- Section 10: Web Server
- Section 11: Bluetooth
- Section 12: LVGL GUI Development
- Section 13: Comprehensive Project
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.
Setting Up the Development Environment
1. Install and Configure the Arduino IDE
Please refer to the tutorial Install and Configure Arduino IDE to download and install the Arduino IDE and add ESP32 support.
Required Board Installation Instructions for ESP32-S3-LCD-1.69
| Board Name | Board Installation Requirement | Version Requirement |
|---|---|---|
| esp32 by Espressif Systems | "Offline installation" / "Online installation" | ≥3.0.5 |
2. Installing Libraries
- When installing Arduino libraries, there are typically two options: Online Installation and Offline Installation. If the library installation requires offline installation, you must use the provided library files.
For most libraries, users can easily search and install them via the Arduino software's built-in Library Manager. However, some open-source or custom libraries are not synchronized to the Arduino Library Manager, so they cannot be found through online search. In this case, you can only install these libraries manually offline. - For library installation instructions, refer to: Arduino Library Management Tutorial.
- The ESP32-S3-LCD-1.69 library files are stored in the example program. Click here to go to: ESP32-S3-LCD-1.69 Example.
Library installation instructions for ESP32-S3-LCD-1.69
| Library Name | Description | Version | Library Installation Requirement |
|---|---|---|---|
| GFX_Library_for_Arduino | GFX graphics library for ST7789 | v1.4.9 | Online or offline installation |
| lvgl | LVGL graphics library | v8.4.0 | After online installation, copy the demos folder to src; offline installation is recommended |
| Mylibrary | Development board pin macro definitions | - | Offline installation |
| SensorLib | PCF85063, QMI8658 sensor driver library | v0.2.1 | Online or offline installation |
| lv_conf.h | LVGL configuration file | - | Offline installation |
Example
ESP32-S3-LCD-1.69 Example Programs
| Example | Basic Description | Dependency Library |
|---|---|---|
| 01_HelloWorld | Demonstrates basic graphics library functions; can also be used to test basic display performance and random text display effects | GFX_Library_for_Arduino |
| 02_GFX_AsciiTable | Prints ASCII characters row by row and column by column on the display based on screen size | GFX_Library_for_Arduino |
| 03_GFX_PCF85063_simpleTime | Displays the current time | SensorLib, GFX_Library_for_Arduino |
| 04_GFX_ESPWiFiAnalyzer | Draws Wi-Fi band signal strength on the ST7789 display | GFX_Library_for_Arduino |
| 05_GFX_Clock | A simple ST7789 clock example, implementing a clock with simple hands and time management | GFX_Library_for_Arduino |
| 06_LVGL_Measuring_voltage | The board reserves a voltage divider for voltage measurement; uses GPIO1 to read the analog value and calculate the battery voltage through the voltage divider formula | LVGL |
| 07_LVGL_PCF85063_simpleTime | Uses the PCF85063 RTC module under LVGL to display the current time on the ST7789 display | LVGL, SensorLib |
| 08_LVGL_QMI8658_ui | Uses LVGL for graphical display and communicates with the QMI8658 IMU to obtain accelerometer and gyroscope data | LVGL, SensorLib |
| 09_LVGL_Keys_Bee | Multi-function button usage | LVGL |
| 10_LVGL_Arduino | LVGL demonstration | LVGL |
- ESP32-S3-LCD-1.69 supports direct model selection

01_HelloWorld
Hardware Connection
- Connect the board to the computer using a USB cable.

- Connect the board to the computer using a USB cable.
Code Analysis
-
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!");
Expected Behavior
![]() | ![]() |
|---|
02_GFX_AsciiTable
Hardware Connection
- Connect the board to the computer using a USB cable.
Code Analysis
-
Initialize the display:
if (!gfx->begin()) {USBSerial.println("gfx->begin() failed!");} -
Calculate rows and columns and label them with numbers: Here, the number of columns and rows that can be displayed is calculated based on the display size. Then, using two loops with different text colors, it prints row and column numbers on the display, making it easy to determine character positions when drawing the ASCII table later.
int numCols = LCD_WIDTH / 8;int numRows = LCD_HEIGHT / 10;// Label the line numbergfx->setTextColor(GREEN);for (int x = 0; x < numRows; x++) {gfx->setCursor(10 + x * 8, 2);gfx->print(x, 16);}// Label the column numbergfx->setTextColor(BLUE);for (int y = 0; y < numCols; y++) {gfx->setCursor(2, 12 + y * 10);gfx->print(y, 16);} -
Draw the ASCII character table:
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);}}
Expected Behavior

03_GFX_PCF85063_simpleTime
Hardware Connection
- Connect the board to the computer using a USB cable.
Code Analysis
-
loop(): -
First, get the current time. If the current time is different from the previously displayed time, do the following:
- Clear the area where the previous time was displayed by filling a rectangle, so that overlapping does not occur when updating the time.
- Set the text color to black and the text size to 3.
- Call the getCenteredX function to calculate the X coordinate for centering the current time string on the screen.
- Set the cursor position and print the current time string, updating the time display.
- Copy the current time string to previousTimeString so that the next comparison can determine whether the time has changed.
Expected Behavior

04_GFX_ESPWiFiAnalyzer
Hardware Connection
- Connect the board to the computer using a USB cable.
Code Analysis
setup():
Initializes serial communication;
Sets Wi-Fi to station mode and disconnects;
Initializes the display, gets screen dimensions and calculates various drawing parameters;
Sets the screen background to black and draws the title bar.
loop():
Scans Wi-Fi networks and retrieves network information, including channel, RSSI, BSSID, and SSID;
Counts the number of networks per channel, noise levels, and peak signal strengths;
Clears the old graph and draws a new one based on the scan results, including signal strength ellipses and network information text;
Prints the number of networks found and the channels with the least noise;
Draws the graph baseline and channel numbers;
Enters low‑power mode based on conditions.
Expected Behavior
- Draws Wi-Fi band signal strength on the ST7789 display, implementing a Wi-Fi analyzer function. As shown in the figure below:

05_GFX_Clock
Hardware Connection
- Connect the board to the computer using a USB cable.
Code Analysis
-
Draw hour, minute, and second hands:
void redraw_hands_cached_draw_and_erase() {gfx->startWrite();draw_and_erase_cached_line(center, center, nsx, nsy, SECOND_COLOR, cached_points, sHandLen + 1, false, false);draw_and_erase_cached_line(center, center, nhx, nhy, HOUR_COLOR, cached_points + ((sHandLen + 1) * 2), hHandLen + 1, true, false);draw_and_erase_cached_line(center, center, nmx, nmy, MINUTE_COLOR, cached_points + ((sHandLen + 1 + hHandLen + 1) * 2), mHandLen + 1, true, true);gfx->endWrite();}
Expected Behavior

06_LVGL_Measuring_voltage
Hardware Connection
- Connect the board to the computer using a USB cable.
Code Analysis
my_print(): Used for LVGL log output. If LVGL logging is enabled, this function prints log information to the serial port.my_disp_flush(): Responsible for flushing the contents of the LVGL drawing buffer to the display.example_increase_lvgl_tick(): Timer callback function used to notify LVGL of the passage of time.example_increase_reboot(): Another timer callback function used for counting; after reaching a certain count, it may trigger a system restart.
Expected Behavior
- The board reserves a voltage divider for voltage measurement; uses GPIO1 to read the analog value and calculate the battery voltage through the voltage divider formula.

07_LVGL_PCF85063_simpleTime
Hardware Connection
- Connect the board to the computer using a USB cable.
Code Analysis
setup():
Initializes serial communication at 115200 baud for possible serial debugging;
Attempts to connect to the PCF85063 real-time clock chip; if it fails, enters an infinite loop;
Sets the initial RTC time to 2024-09-24 11:09:41;
Initializes the display and sets screen brightness;
Initializes LVGL and registers a log output function (if logging is enabled);
Configures the LVGL display driver and drawing buffer, and initializes the input device driver (although it is a virtual pointer input device driver);
Creates a timer to periodically trigger LVGL tick updates;
Creates a label and set the initial text to "Initializing..."
loop():
Calls lv_timer_handler to let LVGL handle graphical interface tasks;
Checks the time for updates every second. If it has been updated, obtain the current time of the real-time clock, output it through the serial port, format the time into a specific format, update the text content of the label, and set the label's font to lv_font_montserrat_40.
Expected Behavior

08_LVGL_QMI8658_ui
Hardware Connection
- Connect the board to the computer using a USB cable.
Code Analysis
my_disp_flush():
This function is the refresh function of the LVGL display driver. It is responsible for refreshing the LVGL drawing buffer content to the display screen;
Based on different color formats, call the corresponding functions of the gfx object to draw the bitmap to a specific area;
Finally, LVGL is notified that the refresh of the display has been completed.
loop():
Calls lv_timer_handler to let LVGL handle graphical interface tasks;
Checks if new data is ready for the QMI (QMI8658 sensor object). If so, attempts to retrieve accelerometer data and gyroscope data and outputs them via serial;
Simultaneously, updates the LVGL chart with the accelerometer data to display real‑time changes in acceleration on the three axes;
Increase the frequency of data polling with delay(20) to ensure that sensor data is captured in a timely manner and the display is updated.
Expected Behavior
- Uses LVGL for graphical display and communicates with the QMI8658 IMU to obtain accelerometer and gyroscope data.

09_LVGL_Keys_Bee
Hardware Connection
- Connect the board to the computer using a USB cable.
Comparison of old and new versions
- This function button was designed to address the issue of fewer functions on external device buttons. In version V2, we made some adjustments:

ESP32-S3-LCD-1.69 comparison between old and new versions
| Peripheral | Old Version | New Version |
|---|---|---|
| Buzzer (Buzz) | GPIO33 | GPIO42 |
| RTC interrupt (RTC_INT) | GPIO41 | GPIO39 |
| Power control (SYS_EN) | GPIO35 | GPIO41 |
| Power output (SYS_OUT) | GPIO36 | GPIO40 |
The principle is as follows:
Pressing PWR can enable battery power, at which point the system starts. The system should define SYS_EN to continuously output a high level to maintain the power-on state. At this point, releasing PWR will not cause a power failure. The function of PWR at this time is to lower SYS_OUT. The system detects actions such as pressing, double pressing, and long pressing on SYS_OUT, enabling customizable power-off control operations. For instance, in a long press mode, setting SYS_EN to a low level to disconnect the battery power completes the use of the multi-purpose buttons.
Code Analysis
loop():
Calls lv_timer_handler to let LVGL handle graphical interface tasks;
Reads the state of the input pin and performs debouncing;
Based on the button's state (pressed or released) and the time interval, determine whether the event is a single click, double click, or long press, and update the label text on the display to show the corresponding event information;
At the same time, for the long press event, the buzzer will be triggered, and when released, the buzzer will be stopped and the specific output pin will be set to a low level.
Expected Behavior
- The display shows
Single Click,Double Click,Long Press, orLong Press Releasedaccording to the button event.
10_LVGL_Arduino
Hardware Connection
- Connect the board to the computer using a USB cable.
Expected Behavior
![]() | ![]() | ![]() | ![]() |
|---|
Use of LVGL components
When developing with the LVGL framework, you can refer to the component documentation provided by the official LVGL docs to use components: LVGL8.3 Documents
Below is a case study of LVGL actual components in the Arduino IDE
![]() | ![]() | ![]() |
|---|








