Data Monitor With TFT Screen ILI9341 2.4" With LVGL and ESP32
by jcherreradev in Circuits > Microcontrollers
23 Views, 0 Favorites, 0 Comments
Data Monitor With TFT Screen ILI9341 2.4" With LVGL and ESP32



Data monitoring with an ESP32 and 2.4" SPI TFT touch screen with ILI9341 driver and LVGL graphical library. The system displays weather data, cryptocurrency prices and system metrics in an interactive graphical interface. In addition, it includes a Python script to send data from the host system to the ESP32 via serial communication.
🌐 This project is based on and inspired by the work of Uteh Str and DustinWatts.
Features
- Weather Data: Gets weather information from the OpenWeatherMap.
- Cryptocurrency prices: Query real-time prices from the CoinMarketCap. API.
- Graphical interface: Uses LVGL to create an interactive graphical interface.
- Touch screen: Support for touch interaction with custom calibration.
- WiFi connection: Configure and connect to WiFi networks.
- Data persistence: Saves configurations in memory.
Supplies

Hardware
- Board: ESP32
- Touchscreen: TFT ILI9341 2.4 SPI"
Software
- IDE: Arduino IDE v1.8.x or 2.3.x
- Framework: Arduino ESP32 v2.0.17
- Board: ESP32 Dev Module
- Partition: HUGO APP (3MB No OTA/1MB SPIFFS)
- Configuration files:
- User_Setup.h file copy to TFT_eSPI library directory
- lv_conf.h file copy to arduino libraries directory (outside lvgl library directory)
- Linux:
- Python: v3.10
Libraries
- LVGL: v9.2.0
- TFT_eSPI: v2.5.43
- Arduino_JSON: v0.2.0
- XPT2046_Touchscreen: v1.4.0
EZZ-studio Configuration
If you are going to make modifications to the images or layout in the Design_Monitor_SystemWeather_ESP32TFT.eez-project file you will need ezz-studio
- EEZ Studio: v0.20.0 --> https://github.com/eez-open/studio/releases/tag/v0.20. 0
- Python: v3.10.2
- Python Packages/Modules:
- pypng: v0.20220715.0 --> python3 -m pip install pypng==0.20220715.0
- lz4: v4.3.3 --> python3 -m pip install lz4
ezz-studio configuration: Make sure you have the following settings.
Modify in Setting/General:
- Display width: 320
- Display height: 240
Modify in Setting/build:
- LVGL include: lvgl.h
⚠️ Once the design and build are complete, copy the files generated in the ui directory to the code directory. Alternatively, you can use the integrate_design_to_code.py script to automate this process.
Script Python (linux_host_UART.py)
The linux_host_UART.py script collects host system metrics, such as CPU/GPU temperature, RAM usage, fan speed, among others, and sends them to the ESP32 through a serial port every 10 seconds.
- Automatic reconnection: Automatically detects and reconnects the serial port if the connection is lost in case you are working with another development board.
Software requirements for the script:
- Python3
- Python packages:
- psutil -> Install: pip3 install psutil
- pyserial -> Install: pip3 install pyserial Sometimes requires reboot or logout.
- System tools:
- smartmontools -> Install: sudo apt install smartmontools. Requires superuser permissions to use smartctl to get disk temperature. Or add permissions to the smartctl executable with:sudo chmod +s /usr/sbin/smartctl, if you do not require this information on screen you can make it ignore that function.
- lm-sensors -> sudo apt install lm-sensors. Run sudo sensors-detect once.
- nvidia-smi (for NVIDIA GPU temperature, already included in proprietary drivers).
⚠️ These requirements are based on a common configuration of Linux systems such as Debian, Ubuntu or derivatives, and may not work identically on all distributions, versions or hardware configurations. Some script functions, such as disk temperature reading, fan speed or GPU temperature, depend on the available hardware and how the system exposes that information. You may need to adapt or customize the script functions according to your environment.
Usage
- The script will send the serial data to the ESP32 every 10 seconds (configurable with the WAIT variable).
- Replace the value of serialEsp32 in the linux_host_UART.py script with the serial number of your ESP32. You can get this number by running the id_ESP32.py script.
- Example script output: b'40.0,21.7,2905.45,62.8,50,34,24.5,40.0,n/a,285#'
- If you have port permissions error, give your user permission to access serial ports:
- Run: python3 linux_host_UART.py
Screen Calibration

Replaces the values obtained from the serial monitor during the calibration performed with Calibrate_Screen.ino in the main code.
⚠️ Check the calibration on the serial monitor if the touch keys do not work correctly. If necessary, you can manually adjust the calibration values in the main code to improve the accuracy of the touch screen.
Data Configuration

