Skip to content

2.4-inch ESP32 Dispaly PlatformIO Tutorial

Overview


This tutorial is for 2.4-inch/2.8-inch/3.5-inch ESP32 HMI display.

Software Preparation


First download Visual Studio Code on https://code.visualstudio.com/. Choose the version that is compatible with your computer system and download it
Vscode-download.jpg

Open VSCode and click on Extension, search for Python and install.
Platformio-terminal-python.png

Search for PlatformIO and install it.
Platformio-terminal-platformio.png

Create new projects


Click on the PlatformIO icon, click the quik access "Open", then click "+New Project"
Platformio-terminal-new-project.png

Add the project name. The board select "Denky(WROOM32)", framework select Arduino
Tutorial-PlatformIO-DIS03024H.png

The main part of the program will be written in main.cpp
Platformio-terminal-main.png

Download the lvgl and TFT_eSPI library
Platformio-terminal-library.png

Platformio-terminal-library-lvgl.png

Platformio-terminal-library-lvgl-1.png

Platformio-terminal-library-lvgl-2.png

Tutorial-PlatformIO-DIS03024H-TFT.png

Tutorial-PlatformIO-DIS03024H-TFT1.png

Tutorial-PlatformIO-DIS03024H-TFT2.png

Tutorial-PlatformIO-DIS03024H-TFT3.png

We can see that the library has been added successfully!
Tutorial-PlatformIO-DIS03024H-LIBRARY-ADDED.png

Configure the libraries


TFT_eSPI

Delete the original User_Setup.h in the TFT_eSPI folder, and copy the User_Setup.h provided to the folder.
Tutorial-PlatformIO-DIS03024H-usersetup.png

LVGL

Right-click the lvgl and open in files explorer
Tutorial-PlatformIO-DIS03024H-open-lvgl.png

Move the demos and examples folder to src folder
Tutorial-PlatformIO-DIS03024H-movefolders.png

Tutorial-PlatformIO-DIS03024H-movefolders1.png

Place the lv_conf.h file under the donky32 directory
Tutorial-PlatformIO-DIS03024H-lvconf.png

UI

Put the UI files to the right folder. (The UI files are generated from the SquareLine Studio)
24-platformio-uifiles.jpg

The .c files should be in the /src folder, and the .h files should be /include folder.

Compile and upload the code


After the configuration is complete, write the code in main.cpp.
Then we can compile the program.

Tutorial-PlatformIO-DIS03024H-compile.png

Tutorial-PlatformIO-DIS03024H-createimage.png

Upload the code and press reset button, the program will run on the board!
Tutorial-PlatformIO-DIS03024H-upload.png

Resources