Wiring the touch shield
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.
The wires
Section titled “The wires”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.
Hover over, focus or tap a wire to see where it goes.
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.
| From | To | Signal |
|---|---|---|
| TFT shieldLCD_D0 (D8) | ESP32 DevKitGPIO22 | Data bit 0 / touch YM |
| TFT shieldLCD_D1 (D9) | ESP32 DevKitGPIO13 | Data bit 1 / touch XP |
| TFT shieldLCD_D2 (D2) | ESP32 DevKitGPIO26 | Data bit 2 |
| TFT shieldLCD_D3 (D3) | ESP32 DevKitGPIO25 | Data bit 3 |
| TFT shieldLCD_D4 (D4) | ESP32 DevKitGPIO17 | Data bit 4 |
| TFT shieldLCD_D5 (D5) | ESP32 DevKitGPIO16 | Data bit 5 |
| TFT shieldLCD_D6 (D6) | ESP32 DevKitGPIO27 | Data bit 6 |
| TFT shieldLCD_D7 (D7) | ESP32 DevKitGPIO14 | Data bit 7 |
| TFT shieldLCD_RD (A0) | ESP32 DevKitGPIO21 | Read strobe |
| TFT shieldLCD_WR (A1) | ESP32 DevKitGPIO4 | Write strobe |
| TFT shieldLCD_RS (A2) | ESP32 DevKitGPIO15 | Command/data select / touch YP (analog) |
| TFT shieldLCD_CS (A3) | ESP32 DevKitGPIO33 | Chip select / touch XM (analog) |
| TFT shieldLCD_RST (A4) | ESP32 DevKitGPIO32 | Reset |
| TFT shield5V | ESP32 DevKit5V / VIN | Power (5V) |
| TFT shield3V3 | ESP32 DevKit3V3 | Power (3.3V logic) |
| TFT shieldGND | ESP32 DevKitGND | Ground |
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.
Two pins that differ from the library
Section titled “Two pins that differ from the library”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_RDgoes to GPIO21, not GPIO2.LCD_D0goes 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.
Power and ground
Section titled “Power and ground”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.
Touch shares pins with the display
Section titled “Touch shares pins with the display”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 onLCD_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 onLCD_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.
Pins left unconnected
Section titled “Pins left unconnected”- The shield’s SD-card pins (
D10toD13) 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).
Before you continue
Section titled “Before you continue”- 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.