1. 📚 Requirements & Libraries
This display uses the ST7796 driver for the screen and a common Capacitive Touch Controller (often the FT series, e.g., FT6336U) for touch input.
-
Arduino IDE Setup: Ensure you have the ESP32 Core installed in your Arduino IDE (as described in the previous tutorial).
-
TFT Library: You must use the highly optimized TFT_eSPI library.
2. 🔌 Hardware Wiring (SPI Bus)
The display uses the 4-wire SPI interface. For optimal performance, connect the display to the ESP32’s dedicated VSPI pins (the most common pin mapping, check your specific ESP32 board documentation).
| LCD Module Pin |
Function |
Standard ESP32 Pin (e.g., DevKitC) |
| VCC |
Power |
5V (or 3.3V, check module specs) |
| GND |
Ground |
GND |
| SCK |
Clock |
GPIO 18 |
| SDI (MOSI) |
Data In |
GPIO 23 |
| SDO (MISO) |
Data Out |
GPIO 19 |
| LCD_CS |
Chip Select |
GPIO 5 (or any available GPIO) |
| LCD_RS (DC) |
Data/Command |
GPIO 2 (or any available GPIO) |
| LCD_RST |
Reset |
GPIO 4 (or any available GPIO) |
| T_CS |
Touch CS |
GPIO 15 (or any available GPIO) |
Note: The TFT_eSPI library allows you to define these control pins (CS, DC, RST, T_CS) to almost any available GPIO pin.
3. ⚙️ TFT_eSPI Configuration
The TFT_eSPI library requires you to define your specific display setup in a configuration file before compiling any code.
-
Locate Setup File: Navigate to the TFT_eSPI library folder (usually in your Arduino sketchbook folder).
-
Create Custom Setup:
-
Edit the File (Setup_ST7796_Custom.h):
-
Driver: Uncomment (or add) the line for the driver:
-
Resolution: Define the screen size:
-
SPI Pins: Define the pins based on your wiring (using the common pins from Step 2):
-
Touch: Since it is a Capacitive touch screen, you need to define the controller (often FT6x36):
-
Activate Setup:
4. ✍️ Example Code: Display & Touch
Upload this simple code to test the screen and verify the configuration.