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

animation.gif
img0.png
img.png

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

  1. Weather Data: Gets weather information from the OpenWeatherMap.
  2. Cryptocurrency prices: Query real-time prices from the CoinMarketCap. API.
  3. Graphical interface: Uses LVGL to create an interactive graphical interface.
  4. Touch screen: Support for touch interaction with custom calibration.
  5. WiFi connection: Configure and connect to WiFi networks.
  6. Data persistence: Saves configurations in memory.

Supplies

connecting.jpg

Hardware

  1. Board: ESP32
  2. Touchscreen: TFT ILI9341 2.4 SPI"

Software

  1. IDE: Arduino IDE v1.8.x or 2.3.x
  2. Framework: Arduino ESP32 v2.0.17
  3. Board: ESP32 Dev Module
  4. Partition: HUGO APP (3MB No OTA/1MB SPIFFS)
  5. Configuration files:
  6. User_Setup.h file copy to TFT_eSPI library directory
  7. lv_conf.h file copy to arduino libraries directory (outside lvgl library directory)
  8. Linux:
  9. Python: v3.10

Libraries

  1. LVGL: v9.2.0
  2. TFT_eSPI: v2.5.43
  3. Arduino_JSON: v0.2.0
  4. 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

  1. EEZ Studio: v0.20.0 --> https://github.com/eez-open/studio/releases/tag/v0.20. 0
  2. Python: v3.10.2
  3. Python Packages/Modules:
  4. pypng: v0.20220715.0 --> python3 -m pip install pypng==0.20220715.0
  5. lz4: v4.3.3 --> python3 -m pip install lz4

ezz-studio configuration: Make sure you have the following settings.

Modify in Setting/General:

  1. Display width: 320
  2. Display height: 240

Modify in Setting/build:

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

  1. 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:

  1. Python3
  2. Python packages:
  3. psutil -> Install: pip3 install psutil
  4. pyserial -> Install: pip3 install pyserial Sometimes requires reboot or logout.
  5. System tools:
  6. 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.
  7. lm-sensors -> sudo apt install lm-sensors. Run sudo sensors-detect once.
  8. 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

  1. The script will send the serial data to the ESP32 every 10 seconds (configurable with the WAIT variable).
  2. 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.
  3. alt text
  4. Example script output: b'40.0,21.7,2905.45,62.8,50,34,24.5,40.0,n/a,285#'
  5. If you have port permissions error, give your user permission to access serial ports:
sudo usermod -a -G dialout $USER
  1. Run: python3 linux_host_UART.py

Screen Calibration

calibracion.png

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

img1.png
img2.png

Code