This repository contains MicroPython drivers for the 2.4 inch TFT Arduino Touch Display with ESP32. It includes drivers for a parallel interface TFT display.
Connect your 2.4 inch TFT Arduino Parallel Interface Display to the ESP32 as follows:
| TFT Display Pin | ESP32 Pin | Description |
|---|---|---|
| LCD_RST | D4 | Reset |
| LCD_CS | D15 | Chip Select |
| LCD_RS (LCD_DC) | D2 | Data/Command |
| LCD_WR | D23 | Write |
| LCD_RD | D19 | Read |
| LCD_D0 | D18 | Data bit 0 |
| LCD_D1 | D21 | Data bit 1 |
| LCD_D2 | D22 | Data bit 2 |
| LCD_D3 | D5 | Data bit 3 |
| LCD_D4 | D13 | Data bit 4 |
| LCD_D5 | D12 | Data bit 5 |
| LCD_D6 | D14 | Data bit 6 |
| LCD_D7 | D27 | Data bit 7 |
| GND | GND | Ground |
| 5V | 5V | Power supply (5V) |
| 3V3 | 3.3V | Power supply (3.3V) |
| SD Card Pin | ESP32 Pin | Description |
|---|---|---|
| SD_SS | D5 | SD Card CS |
| SD_DI | D23 | SD Card MOSI |
| SD_DO | D19 | SD Card MISO |
| SD_SCK | D18 | SD Card Clock |
┌──────────────────┐ ┌──────────────────┐
│ │ │ │
│ ESP32 │ │ 2.4" TFT │
│ │ │ Display Shield │
│ │ │ │
│ D2 ────────────┼───────────────┼──► LCD_RS │
│ D4 ────────────┼───────────────┼──► LCD_RST │
│ D15 ────────────┼───────────────┼──► LCD_CS │
│ D19 ────────────┼───────────────┼──► LCD_RD │
│ D23 ────────────┼───────────────┼──► LCD_WR │
│ D18 ────────────┼───────────────┼──► LCD_D0 │
│ D21 ────────────┼───────────────┼──► LCD_D1 │
│ D22 ────────────┼───────────────┼──► LCD_D2 │
│ D5 ────────────┼───────────────┼──► LCD_D3 │
│ D13 ────────────┼───────────────┼──► LCD_D4 │
│ D12 ────────────┼───────────────┼──► LCD_D5 │
│ D14 ────────────┼───────────────┼──► LCD_D6 │
│ D27 ────────────┼───────────────┼──► LCD_D7 │
│ │ │ │
│ 5V ────────────┼───────────────┼──► 5V │
│ 3.3V ───────────┼───────────────┼──► 3V3 │
│ GND ───────────┼───────────────┼──► GND │
│ │ │ │
└──────────────────┘ └──────────────────┘
- This display uses a parallel interface (8-bit data bus) rather than SPI.
- You'll need 13 GPIO pins on your ESP32 to drive this display.
- Some ESP32 pins have special functions during boot. Avoid using D0-D3 (GPIO 0, 1, 2, 3) for data lines if possible.
- The 8-bit data bus requires more GPIO pins but can offer faster refresh rates than SPI.
- Connect your ESP32 to your computer and ensure MicroPython is installed.
- Upload the driver files to your ESP32.
import machine
import time
from ili9341_parallel import ILI9341
# Initialize display with parallel interface
display = ILI9341(
d0=machine.Pin(18, machine.Pin.OUT),
d1=machine.Pin(21, machine.Pin.OUT),
d2=machine.Pin(22, machine.Pin.OUT),
d3=machine.Pin(5, machine.Pin.OUT),
d4=machine.Pin(13, machine.Pin.OUT),
d5=machine.Pin(12, machine.Pin.OUT),
d6=machine.Pin(14, machine.Pin.OUT),
d7=machine.Pin(27, machine.Pin.OUT),
cs=machine.Pin(15, machine.Pin.OUT),
dc=machine.Pin(2, machine.Pin.OUT),
rst=machine.Pin(4, machine.Pin.OUT),
wr=machine.Pin(23, machine.Pin.OUT),
rd=machine.Pin(19, machine.Pin.OUT)
)
# Basic usage
display.fill(0x0000) # Black
display.fill_rect(10, 10, 100, 50, 0xF800) # Red rectangle
display.text("Hello World", 40, 40, 0xFFFF) # White text- Display shows nothing: Check all connections and ensure proper power supply.
- Garbled display: Verify all data pins are correctly connected.
- Slow refresh: Parallel interface should be fast; if slow, check your code for inefficient drawing methods.
- Boot failures: Some ESP32 GPIO pins have special boot functions. If having trouble booting, try changing the pin assignments.
This project is open source and available under the MIT License.