Skip to main content

Working with Arduino

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.

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. Installing and Configuring the Arduino IDE​

Please refer to the tutorial Install and Configure Arduino IDE to download and install the Arduino IDE and add ESP32 support.

2. Additional Tips​

  1. In the Board Manager, select the "ESP32H2 Dev Module" model for development.

    Select Model

  2. The ESP32-H2-Zero uses the ESP32-H2 native USB port instead of UART to USB. For serial communication:

    • 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.

Example​

The Arduino examples are located in the Arduino directory of the example package.

ExampleBasic DescriptionDependency Library
01_BLEThe ESP32 device can be discovered and connected by a Bluetooth debug assistant-
02_BlinkRGBRGB LED breathing effect with color cycling-
03_UARTSerial printing via native USB port; USB CDC On Boot must be enabled-
04_ZigbeeZigbee communication test-
05_GetChipIDRead the chip ID-
06_lvgl8.4.0_demoText display via the 1.83inch LCD Modulelvgl8.4.0
07_lvgl9.2.2_demoText display via the 1.83inch LCD Modulelvgl9.2.2
08_1.83inchConnects to the 1.83inch LCD Module for color cycle test, touch function test, and image swipe switchingLovyanGFX 1.2.26

01_BLE​

This example demonstrates BLE advertising. The ESP32-H2-Zero device can be discovered by a Bluetooth debug assistant. After connection, messages can be sent from the assistant to the board. USB CDC On Boot must be enabled.

tip

Boards Manager esp32 by Espressif Systems version 3.3.10

Expected Behavior​

02_BlinkRGB​

This example demonstrates the onboard RGB LED breathing effect, with the LED blinking and cycling through colors.

Expected Behavior​

03_UART​

This example outputs serial information via the native USB port. If using Serial.println() for output, "USB CDC On Boot" must be enabled in Arduino IDE.

Expected Behavior​

04_Zigbee​

This example demonstrates Zigbee communication testing.

Parameter Configuration​

Configure the board to be flashed with the light example as Zigbee ED (End Device).

Configure the board to be flashed with the switch example as Zigbee ZCZR (Zigbee Coordinator/Zigbee Router).

Expected Behavior​

Pressing the BOOT button on the switch board controls the RGB LED on the light board.

05_GetChipID​

This example reads and prints the chip ID.

Expected Behavior​

06_lvgl8.4.0_demo​

This example uses LVGL 8.4.0, GFX_Library_for_Arduino, and SensorLib for text display. To view serial output, enable "USB CDC On Boot".

Hardware Connection​

1.83inch Touch LCD ModuleESP32-H2-Zero
VCC3V3
GNDGND
LCD_DINGPIO2
LCD_CLKGPIO1
LCD_CSGPIO5
LCD_DCGPIO3
LCD_RSTGPIO4
LCD_BLGPIO24

Expected Behavior​

The serial monitor baud rate must be 115200 to print the following strings.

07_lvgl9.2.2_demo​

This example uses LVGL 9.2.2, GFX_Library_for_Arduino, and SensorLib for text display. To view serial output, enable "USB CDC On Boot".

Hardware Connection​

1.83inch Touch LCD ModuleESP32-H2-Zero
VCC3V3
GNDGND
LCD_DINGPIO2
LCD_CLKGPIO1
LCD_CSGPIO5
LCD_DCGPIO3
LCD_RSTGPIO4
LCD_BLGPIO24

Expected Behavior​

The serial monitor baud rate must be 115200 to print the following strings.

08_1.83inch​

This example demonstrates how to drive the 1.83inch Touch LCD Module based on the ESP32-H2 board and Arduino framework, implementing a color cycle test, CST816S touch function test, and using LovyanGFX to display images directly, with support for left/right swipe gestures for image switching.

Hardware Connection​

1.83inch Touch LCD ModuleESP32-H2-Zero
VCC3V3
GNDGND
LCD_DINGPIO2
LCD_CLKGPIO1
LCD_CSGPIO5
LCD_DCGPIO3
LCD_RSTGPIO4
LCD_BLGPIO24
TP_SDAGPIO25
TP_SCLGPIO22
TP_RSTGPIO10
TP_INTGPIO11

Expected Behavior​

Modify the DEMO_IMAGE_ALBUM macro in the project arduino.ino to switch between two example modes:

  • When #define DEMO_IMAGE_ALBUM 0:

    • LCD Color Cycle Test:

      LCD Color Test 1LCD Color Test 2LCD Color Test 3LCD Color Test 4
    • LCD Touch Test:

  • When #define DEMO_IMAGE_ALBUM 1:

    • LVGL Image Switching Test:

      LVGL Image Switching Test 1LVGL Image Switching Test 2LVGL Image Switching Test 3

Documentation Feedback​

If you encounter any issues during use, feel free to leave a comment.