Skip to content

Wiring the touch shield

Time
45 min
Difficulty
Medium

What you'll learn

  • How an Arduino Uno shield is wired to an ESP32 with jumper wires
  • Why two pins differ from the library's original pin map
  • Which pins the touch panel shares with the display

The touch shield was made to plug into an Arduino Uno. Here it is connected to the ESP32 DevKit with 16 jumper wires instead: 13 for signals and 3 for power and ground. This wiring is built and working.

Hover over, focus or tap a wire in the diagram to see where it goes. The table lists the same wires and works without JavaScript.

Wiring diagram (schematic). The table below lists every wire.TFT shieldESP32 DevKitLCD_D0 (D8)GPIO22LCD_D1 (D9)GPIO13LCD_D2 (D2)GPIO26LCD_D3 (D3)GPIO25LCD_D4 (D4)GPIO17LCD_D5 (D5)GPIO16LCD_D6 (D6)GPIO27LCD_D7 (D7)GPIO14LCD_RD (A0)GPIO21LCD_WR (A1)GPIO4LCD_RS (A2)GPIO15LCD_CS (A3)GPIO33LCD_RST (A4)GPIO325V5V / VIN3V33V3GNDGND

Schematic only: each board shows just the pins in use, not in their physical order. Always match the labels printed on your board. Dashed wires are not yet tested.

Touch shield to ESP32 DevKit: 16 wires
FromToSignal
TFT shieldLCD_D0 (D8)ESP32 DevKitGPIO22Data bit 0 / touch YM
TFT shieldLCD_D1 (D9)ESP32 DevKitGPIO13Data bit 1 / touch XP
TFT shieldLCD_D2 (D2)ESP32 DevKitGPIO26Data bit 2
TFT shieldLCD_D3 (D3)ESP32 DevKitGPIO25Data bit 3
TFT shieldLCD_D4 (D4)ESP32 DevKitGPIO17Data bit 4
TFT shieldLCD_D5 (D5)ESP32 DevKitGPIO16Data bit 5
TFT shieldLCD_D6 (D6)ESP32 DevKitGPIO27Data bit 6
TFT shieldLCD_D7 (D7)ESP32 DevKitGPIO14Data bit 7
TFT shieldLCD_RD (A0)ESP32 DevKitGPIO21Read strobe
TFT shieldLCD_WR (A1)ESP32 DevKitGPIO4Write strobe
TFT shieldLCD_RS (A2)ESP32 DevKitGPIO15Command/data select / touch YP (analog)
TFT shieldLCD_CS (A3)ESP32 DevKitGPIO33Chip select / touch XM (analog)
TFT shieldLCD_RST (A4)ESP32 DevKitGPIO32Reset
TFT shield5VESP32 DevKit5V / VINPower (5V)
TFT shield3V3ESP32 DevKit3V3Power (3.3V logic)
TFT shieldGNDESP32 DevKitGNDGround

The shield’s pins are labelled with their Uno names, such as LCD_D0 and D8. The DevKit’s pins are labelled with their GPIO numbers. Pin positions differ between DevKit makers, so always go by the printed labels, not by position.

The display library, MCUFRIEND_kbv, originally uses GPIO12 for LCD_D0 and GPIO2 for LCD_RD. This build moves them, to match library patches 2 and 3:

  • LCD_RD goes to GPIO21, not GPIO2.
  • LCD_D0 goes to GPIO22, not GPIO12.

GPIO2 and GPIO12 are strapping pins: the ESP32 reads them at the moment it starts, to decide how to boot. With the shield attached, GPIO2 blocked uploads, and GPIO12 sometimes made the chip run its flash memory at the wrong voltage, so it failed to boot.

The shield needs both 5V and 3.3V: its regulator and backlight run on 5V, and its logic on 3.3V. Connect the shield’s 5V to the DevKit’s 5V (sometimes labelled VIN), its 3V3 to 3V3, and GND to GND.

The touch panel has no pins of its own. It shares four of the display’s lines, and the firmware switches them between drawing and reading touch:

  • YP is on LCD_RS (GPIO15) and XM is on LCD_CS (GPIO33). Touch reads these as analog voltages, so they must be on analog-capable pins, which 15 and 33 are.
  • YM is on LCD_D0 (GPIO22) and XP is on LCD_D1 (GPIO13).

GPIO15 is on the ESP32’s second analog unit (ADC2), which can’t be used while Wi-Fi is on. That’s no problem here: the firmware never starts Wi-Fi.

  • The shield’s SD-card pins (D10 to D13) are not connected. The SD card isn’t used.
  • After this step and the camera link, these DevKit pins are still free: GPIO18, 19 and 23 (input and output), and GPIO35, 36 and 39 (input only).
  • All 16 wires match the table, one by one.
  • Nothing is connected to GPIO2 or GPIO12.
  • The DevKit is still unplugged.

You’ll see the display work for the first time when you flash the DevKit in a later step.