# My touchscreen does not work with ESP32 DEVKIT V2 and ili9341

**URL:** <https://forum.arduino.cc/t/my-touchscreen-does-not-work-with-esp32-devkit-v2-and-ili9341/1345120>\
**Category:** Displays\
**Created:** [January 21, 2025, 10:15am UTC](https://forum.arduino.cc/t/my-touchscreen-does-not-work-with-esp32-devkit-v2-and-ili9341/1345120 "2025-01-21T10:15:09Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![eziogi](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/eziogi/32/933222_2.png) [@eziogi](https://forum.arduino.cc/u/eziogi)\
**Post date:** [January 21, 2025, 10:15am UTC](https://forum.arduino.cc/t/my-touchscreen-does-not-work-with-esp32-devkit-v2-and-ili9341/1345120/1 "2025-01-21T10:15:09Z")

</div>

Hi,  
I am using the ILI9341 LCD with the sketch taken from the XPT2046\_touchscreen examples but it does not feel the finger touch on the video. Only x and y coordinates equal to 0 appear on the serial monitor.  
The LCD is this, taken on eBay = 1PCS NEW 2.8 inch SPI LCD module 240\*320 TFT with touch ILI9341 #YT | eBay. The graphics work excellently. T  
he sketch has been adapted to the DOIT ESP32 DEVKIT V2, updating the pins. The modified sketch is as follows:

```arduino
#include <XPT2046_Touchscreen.h>
  #include <SPI.h>
  
  #define CS_PIN 21
  // MOSI=17, MISO=14, SCK=16
  
  //XPT2046_Touchscreen ts(CS_PIN);
  #define TIRQ_PIN 25
  //XPT2046_Touchscreen ts(CS_PIN); // Param 2 - NULL - No interrupts
  //XPT2046_Touchscreen ts(CS_PIN, 255); // Param 2 - 255 - No interrupts
  XPT2046_Touchscreen ts(CS_PIN, TIRQ_PIN); // Param 2 - Touch IRQ Pin - interrupt enabled polling

  void setup() {
    Serial.begin(38400);
    ts.begin();
    // ts.begin(SPI1); // use alternate SPI port
    ts.setRotation(1);
    while (!Serial && (millis() <= 1000));
  }
  
  void loop() {
    if (ts.touched()) {
      TS_Point p = ts.getPoint();
      Serial.print("Pressure = ");
      Serial.print(p.z);
      Serial.print(", x = ");
      Serial.print(p.x);
      Serial.print(", y = ");
      Serial.print(p.y);
      delay(500);
      Serial.println();
    }
  }

```

---

<div class="post-metadata">

**Author:** ![sonofcy](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/sonofcy/32/1283617_2.png) [@sonofcy](https://forum.arduino.cc/u/sonofcy)\
**Post date:** [January 21, 2025, 2:03pm UTC](https://forum.arduino.cc/t/my-touchscreen-does-not-work-with-esp32-devkit-v2-and-ili9341/1345120/2 "2025-01-21T14:03:08Z")

</div>

That issue has shown up a lot. You need to check your soldering VERY carefully.

---

<div class="post-metadata">

**Author:** ![eziogi](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/eziogi/32/933222_2.png) [@eziogi](https://forum.arduino.cc/u/eziogi)\
**Post date:** [January 21, 2025, 3:11pm UTC](https://forum.arduino.cc/t/my-touchscreen-does-not-work-with-esp32-devkit-v2-and-ili9341/1345120/3 "2025-01-21T15:11:49Z")

</div>

Okay.  
I'll recheck the connections and soldering

---

<div class="post-metadata">

**Author:** ![sonofcy](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/sonofcy/32/1283617_2.png) [@sonofcy](https://forum.arduino.cc/u/sonofcy)\
**Post date:** [January 21, 2025, 3:25pm UTC](https://forum.arduino.cc/t/my-touchscreen-does-not-work-with-esp32-devkit-v2-and-ili9341/1345120/4 "2025-01-21T15:25:15Z")

</div>

If you used braided wire, use a lighted magnifying glass since it only takes one strand connecting to the next pin to cause a problem.

---

<div class="post-metadata">

**Author:** ![eziogi](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/eziogi/32/933222_2.png) [@eziogi](https://forum.arduino.cc/u/eziogi)\
**Post date:** [January 22, 2025, 8:25am UTC](https://forum.arduino.cc/t/my-touchscreen-does-not-work-with-esp32-devkit-v2-and-ili9341/1345120/5 "2025-01-22T08:25:21Z")

</div>

Hi,  
I checked the connections as advised and they are fine.

---

<div class="post-metadata">

**Author:** ![sonofcy](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/sonofcy/32/1283617_2.png) [@sonofcy](https://forum.arduino.cc/u/sonofcy)\
**Post date:** [January 22, 2025, 1:08pm UTC](https://forum.arduino.cc/t/my-touchscreen-does-not-work-with-esp32-devkit-v2-and-ili9341/1345120/6 "2025-01-22T13:08:38Z")

</div>

The next logical step is to try one of the most simple sample sketches. If it works, you have an error in your sketch, if it doesn't work you have a wiring error.

---

<div class="post-metadata">

**Author:** ![6v6gt](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/6v6gt/32/225488_2.png) [@6v6gt](https://forum.arduino.cc/u/6v6gt)\
**Post date:** [January 22, 2025, 1:43pm UTC](https://forum.arduino.cc/t/my-touchscreen-does-not-work-with-esp32-devkit-v2-and-ili9341/1345120/7 "2025-01-22T13:43:41Z")

</div>

If the screen look like this on the rear, then you have to connect the touch screen pins as well.  
You've mentioned CS\_PIN and this is exclusively for the touch screen.  
Other pins, are shared SPI pins and are shared between the TFT driver and the XPT2046 touch controller, however, these are not internally connected and you must connect them explicitly.

The T\_IRQ pin can probably be ignored with the correct choice of constructor for `XPT2046_Touchscreen`.

Anyway, show a wiring diagram of how you have connected the screen pins to the microcontroller.

 ![image](https://europe1.discourse-cdn.com/arduino/original/4X/3/5/1/3512c9743f98041a5acdba38de2d41ee5552ab4c.jpeg)

 ![image](https://europe1.discourse-cdn.com/arduino/original/4X/6/c/9/6c9b16a2d50a6bc16a5c97d2ace2d3bed3a0033e.jpeg)

---

<div class="post-metadata">

**Author:** ![van\_der\_decken](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/van_der_decken/32/1006976_2.png) [@van\_der\_decken](https://forum.arduino.cc/u/van_der_decken)\
**Post date:** [January 22, 2025, 5:05pm UTC](https://forum.arduino.cc/t/my-touchscreen-does-not-work-with-esp32-devkit-v2-and-ili9341/1345120/8 "2025-01-22T17:05:16Z")

</div>

Try lifting the MISO line to the display. It's all too common for these displays not to tristate that output when the display is not selected, which prevents the touchscreen (and any other SPI devices as well) from being read.

If that turns out to be the case, and you don't need to read data from the display, you're done. If you do need to read from the display, you'll have to add something like a 74AHC125 tristate buffer controlled by the CS line.

---

<div class="post-metadata">

**Author:** ![eziogi](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/eziogi/32/933222_2.png) [@eziogi](https://forum.arduino.cc/u/eziogi)\
**Post date:** [January 22, 2025, 5:27pm UTC](https://forum.arduino.cc/t/my-touchscreen-does-not-work-with-esp32-devkit-v2-and-ili9341/1345120/9 "2025-01-22T17:27:33Z")

</div>

The electrical connection is as follows:  
[ESP32\_pin\_ILI.pdf](https://forum.arduino.cc/uploads/short-url/u1OadqVuiNpC0kkxqid3Vtpj1n6.pdf) (16,1 KB)  
The image is identical to that of “6v6gt”.

---

<div class="post-metadata">

**Author:** ![van\_der\_decken](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/van_der_decken/32/1006976_2.png) [@van\_der\_decken](https://forum.arduino.cc/u/van_der_decken)\
**Post date:** [January 22, 2025, 5:30pm UTC](https://forum.arduino.cc/t/my-touchscreen-does-not-work-with-esp32-devkit-v2-and-ili9341/1345120/10 "2025-01-22T17:30:09Z")

</div>

Most people won't click on random PDFs these days. If you have a diagram you wish to share, please upload it as an image.

Ah: I see you've edited your reply. Never mind.

---

<div class="post-metadata">

**Author:** ![eziogi](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/eziogi/32/933222_2.png) [@eziogi](https://forum.arduino.cc/u/eziogi)\
**Post date:** [January 22, 2025, 5:35pm UTC](https://forum.arduino.cc/t/my-touchscreen-does-not-work-with-esp32-devkit-v2-and-ili9341/1345120/11 "2025-01-22T17:35:26Z")

</div>

I wrote this PDF to simplify the connections, in fact I also added color to the various wires used.  
I will take a picture and attach it.

---

<div class="post-metadata">

**Author:** ![6v6gt](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/6v6gt/32/225488_2.png) [@6v6gt](https://forum.arduino.cc/u/6v6gt)\
**Post date:** [January 22, 2025, 7:49pm UTC](https://forum.arduino.cc/t/my-touchscreen-does-not-work-with-esp32-devkit-v2-and-ili9341/1345120/12 "2025-01-22T19:49:13Z")

</div>

I think I see a problem already. The SPI bus is shared. That is you must connect the following display pins together:  
T\_CLK( display pin 10) and SCK (display pin 7)  
T\_DIN( display pin 12) and SDI(MOSI) (display pin 6)  
T\_DO( display pin 13) and SDO(MISO) (display pin 9)

The CS ( chip select pins ) are NOT shared. These are used to select the SPI peripheral which the SPI bus is currently talking to. That is T\_CS and TFT\_CS must use different pins (as you correctly have).

This is your current connection diagram:

 ![image](https://europe1.discourse-cdn.com/arduino/original/4X/3/9/7/397837e1bd62a318496b82963a5848012d16e2dc.png)

It should look more like this as fas as I can see:

 ![image](https://europe1.discourse-cdn.com/arduino/original/4X/9/0/4/904e5c440314f9e957944bf2ef0ba7ff155dd88b.png)

---

<div class="post-metadata">

**Author:** ![horace](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/horace/32/1014299_2.png) [@horace](https://forum.arduino.cc/u/horace)\
**Post date:** [January 23, 2025, 8:31am UTC](https://forum.arduino.cc/t/my-touchscreen-does-not-work-with-esp32-devkit-v2-and-ili9341/1345120/13 "2025-01-23T08:31:02Z")

</div>

using the XPT2046\_Touchscreen library with the 2.8\_ SPI TFT LCD Display Touch Panel ILI9341 I used the following code  
Touch\_Test.ino file

```cpp
// TFT_eSPI touch test 240X320 Resolution 2.8_ SPI TFT LCD Display Touch Panel ILI9341

/* Rui Santos & Sara Santos - Random Nerd Tutorials
    THIS EXAMPLE WAS TESTED WITH THE FOLLOWING HARDWARE:
    1) ESP32-2432S028R 2.8 inch 240×320 also known as the Cheap Yellow Display (CYD): https://makeradvisor.com/tools/cyd-cheap-yellow-display-esp32-2432s028r/
      SET UP INSTRUCTIONS: https://RandomNerdTutorials.com/cyd/
    2) REGULAR ESP32 Dev Board + 2.8 inch 240x320 TFT Display: https://makeradvisor.com/tools/2-8-inch-ili9341-tft-240x320/ and https://makeradvisor.com/tools/esp32-dev-board-wi-fi-bluetooth/
      SET UP INSTRUCTIONS: https://RandomNerdTutorials.com/esp32-tft/
    Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files.
    The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*/

#include <SPI.h>

/* Install the "TFT_eSPI" library by Bodmer to interface with the TFT Display - https://github.com/Bodmer/TFT_eSPI
    ***IMPORTANT: User_Setup.h available on the internet will probably NOT work with the examples available at Random Nerd Tutorials***
    ***YOU MUST USE THE User_Setup.h FILE PROVIDED IN THE LINK BELOW IN ORDER TO USE THE EXAMPLES FROM RANDOM NERD TUTORIALS***
    FULL INSTRUCTIONS AVAILABLE ON HOW CONFIGURE THE LIBRARY: https://RandomNerdTutorials.com/cyd/ or https://RandomNerdTutorials.com/esp32-tft/ */
#include <TFT_eSPI.h>

// Install the "XPT2046_Touchscreen" library by Paul Stoffregen to use the Touchscreen - https://github.com/PaulStoffregen/XPT2046_Touchscreen
// Note: this library doesn't require further configuration
#include <XPT2046_Touchscreen.h>

TFT_eSPI tft = TFT_eSPI();

// Touchscreen pins
#define XPT2046_IRQ 34 // T_IRQ
#define XPT2046_MOSI MOSI // GPIO23 // T_DIN
#define XPT2046_MISO MISO // GPIO19 // T_OUT
#define XPT2046_CLK SCK // GPIO18 // T_CLK
#define XPT2046_CS 5 // T_CS

SPIClass touchscreenSPI = SPIClass(VSPI);
XPT2046_Touchscreen touchscreen(XPT2046_CS, XPT2046_IRQ);

#define SCREEN_WIDTH 320
#define SCREEN_HEIGHT 240
#define FONT_SIZE 2

// Touchscreen coordinates: (x, y) and pressure (z)
int x, y, z;

// Print Touchscreen info about X, Y and Pressure (Z) on the Serial Monitor
void printTouchToSerial(int touchX, int touchY, int touchZ) {
  Serial.print("X = ");
  Serial.print(touchX);
  Serial.print(" | Y = ");
  Serial.print(touchY);
  Serial.print(" | Pressure = ");
  Serial.print(touchZ);
  Serial.println();
}

// Print Touchscreen info about X, Y and Pressure (Z) on the TFT Display
void printTouchToDisplay(int touchX, int touchY, int touchZ) {
  // Clear TFT screen
  tft.fillScreen(TFT_WHITE);
  tft.setTextColor(TFT_BLACK, TFT_WHITE);

  int centerX = SCREEN_WIDTH / 2;
  int textY = 80;
 
  String tempText = "X = " + String(touchX);
  tft.drawCentreString(tempText, centerX, textY, FONT_SIZE);

  textY += 20;
  tempText = "Y = " + String(touchY);
  tft.drawCentreString(tempText, centerX, textY, FONT_SIZE);

  textY += 20;
  tempText = "Pressure = " + String(touchZ);
  tft.drawCentreString(tempText, centerX, textY, FONT_SIZE);
}

void setup() {
  Serial.begin(115200);

  // Start the SPI for the touchscreen and init the touchscreen
  touchscreenSPI.begin(XPT2046_CLK, XPT2046_MISO, XPT2046_MOSI, XPT2046_CS);
  touchscreen.begin(touchscreenSPI);
  // Set the Touchscreen rotation in landscape mode
  // Note: in some displays, the touchscreen might be upside down, so you might need to set the rotation to 3: touchscreen.setRotation(3);
  touchscreen.setRotation(1);

  // Start the tft display
  tft.init();
  // Set the TFT display rotation in landscape mode
  tft.setRotation(1);

  // Clear the screen before writing to it
  tft.fillScreen(TFT_WHITE);
  tft.setTextColor(TFT_BLACK, TFT_WHITE);
  
  // Set X and Y coordinates for center of display
  int centerX = SCREEN_WIDTH / 2;
  int centerY = SCREEN_HEIGHT / 2;

  tft.drawCentreString("Hello, world!", centerX, 30, FONT_SIZE);
  tft.drawCentreString("Touch screen to test", centerX, centerY, FONT_SIZE);
}

void loop() {
  // Checks if Touchscreen was touched, and prints X, Y and Pressure (Z) info on the TFT display and Serial Monitor
  if (touchscreen.tirqTouched() && touchscreen.touched()) {
    // Get Touchscreen points
    TS_Point p = touchscreen.getPoint();
    // Calibrate Touchscreen points with map function to the correct width and height
    x = map(p.x, 200, 3700, 1, SCREEN_WIDTH);
    y = map(p.y, 240, 3800, 1, SCREEN_HEIGHT);
    z = p.z;

    printTouchToSerial(x, y, z);
    printTouchToDisplay(x, y, z);

    delay(100);
  }
}

```

User\_Setup.h file (place in same directory as above .ino file)

```cpp
// TFT_eSPI User_Setup.h file 240X320 Resolution 2.8_ SPI TFT LCD Display Touch Panel ILI9341

#define USER_SETUP_INFO "User_Setup"

#define ILI9341_DRIVER

// For ST7735, ST7789 and ILI9341 ONLY, define the colour order IF the blue and red are swapped on your display
// Try ONE option at a time to find the correct colour order for your display
// #define TFT_RGB_ORDER TFT_RGB // Colour order Red-Green-Blue
// #define TFT_RGB_ORDER TFT_BGR // Colour order Blue-Green-Red

// For ST7789, ST7735, ILI9163 and GC9A01 ONLY, define the pixel width and height in portrait orientation
#define TFT_WIDTH 240 // ST7789 240 x 240 and 240 x 320
#define TFT_HEIGHT 320 // ST7789 240 x 320

// If colours are inverted (white shows as black) then uncomment one of the next
// 2 lines try both options, one of the options should correct the inversion.

// #define TFT_INVERSION_ON
// #define TFT_INVERSION_OFF

#define TFT_CS 15 
#define TFT_MOSI MOSI 
#define TFT_SCLK SCK 
#define TFT_MISO MISO 

#define TFT_DC 2
#define TFT_RST 4

#define LOAD_GLCD
#define LOAD_FONT2
#define LOAD_FONT4
#define LOAD_FONT6
#define LOAD_FONT7
#define LOAD_FONT8
#define LOAD_GFXFF

#define SMOOTH_FONT

#define SPI_FREQUENCY 10000000

#define SPI_TOUCH_FREQUENCY 2500000

```

serial monitor output

```arduino
X = 301 | Y = 43 | Pressure = 403
X = 242 | Y = 25 | Pressure = 674
X = 67 | Y = 39 | Pressure = 977
X = 212 | Y = 59 | Pressure = 683
X = 76 | Y = 36 | Pressure = 1782
X = 64 | Y = 56 | Pressure = 1814
X = 44 | Y = 83 | Pressure = 1846
X = 34 | Y = 114 | Pressure = 2026
X = 45 | Y = 151 | Pressure = 2083
X = 48 | Y = 178 | Pressure = 2119
X = 74 | Y = 207 | Pressure = 2088
X = 136 | Y = 206 | Pressure = 1556
X = 191 | Y = 205 | Pressure = 1935
X = 227 | Y = 211 | Pressure = 1782
X = 279 | Y = 225 | Pressure = 1673
X = 301 | Y = 218 | Pressure = 1632
X = 302 | Y = 205 | Pressure = 1540
X = 303 | Y = 188 | Pressure = 1511
X = 307 | Y = 169 | Pressure = 1435
X = 272 | Y = 148 | Pressure = 1531
X = 203 | Y = 131 | Pressure = 1583
X = 165 | Y = 131 | Pressure = 1872
X = 136 | Y = 114 | Pressure = 2017
X = 111 | Y = 104 | Pressure = 2013
X = 106 | Y = 85 | Pressure = 2002
X = 154 | Y = 114 | Pressure = 1977
X = 199 | Y = 136 | Pressure = 1853
X = 231 | Y = 173 | Pressure = 1727
X = 268 | Y = 155 | Pressure = 1655
X = 290 | Y = 153 | Pressure = 1483

```

as the pen is moved around the panel the display values are updated

 ![image](https://europe1.discourse-cdn.com/arduino/original/4X/e/6/5/e65e027c0f035fe7d3f1434000f8b2bd784b0fd0.jpeg)

---

<div class="post-metadata">

**Author:** ![eziogi](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/eziogi/32/933222_2.png) [@eziogi](https://forum.arduino.cc/u/eziogi)\
**Post date:** [January 23, 2025, 8:25pm UTC](https://forum.arduino.cc/t/my-touchscreen-does-not-work-with-esp32-devkit-v2-and-ili9341/1345120/14 "2025-01-23T20:25:31Z")

</div>

Thanks for the advice.  
Next week I will make the changes to the connections and then try the sketch you recommended.  
I will let you know the results.

---

<div class="post-metadata">

**Author:** ![eziogi](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/eziogi/32/933222_2.png) [@eziogi](https://forum.arduino.cc/u/eziogi)\
**Post date:** [January 27, 2025, 1:39pm UTC](https://forum.arduino.cc/t/my-touchscreen-does-not-work-with-esp32-devkit-v2-and-ili9341/1345120/15 "2025-01-27T13:39:14Z")

</div>

HI,  
Do these connections go to the GPIOs described alongside?

```arduino
#define XPT2046_MOSI MOSI // GPIO23 // T_DIN
#define XPT2046_MISO MISO // GPIO19 // T_OUT
#define XPT2046_CLK SCK // GPIO18 // T_CLK

```

Thank you

---

<div class="post-metadata">

**Author:** ![horace](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/horace/32/1014299_2.png) [@horace](https://forum.arduino.cc/u/horace)\
**Post date:** [January 27, 2025, 2:18pm UTC](https://forum.arduino.cc/t/my-touchscreen-does-not-work-with-esp32-devkit-v2-and-ili9341/1345120/16 "2025-01-27T14:18:35Z")

</div>

> [@eziogi](#):
>
> Do these connections go to the GPIOs described alongside?
> 
> ```arduino
> #define XPT2046_MOSI MOSI // GPIO23 // T_DIN
> #define XPT2046_MISO MISO // GPIO19 // T_OUT
> #define XPT2046_CLK SCK // GPIO18 // T_CLK
> 
> ```

both the touch SPI and TFT SPI are connected to same pins

```arduino
#define TFT_MOSI MOSI 
#define TFT_SCLK SCK 
#define TFT_MISO MISO 

```

the chip selects must be different pins, e.g.

```arduino
#define XPT2046_CS 5 // T_CS
#define TFT_CS 15 

```

with Tools\>Board select _ESP32 Dev Module_ and the following are defined

```arduino
MOSI: 23
MISO: 19
SCK: 18

```

or you can use the GPIO pins explicitly

```arduino
#define XPT2046_MOSI 23 // T_DIN
#define XPT2046_MISO 19 // T_OUT
#define XPT2046_CLK 18 // T_CLK

#define TFT_MOSI 23 
#define TFT_SCLK 18 
#define TFT_MISO 19 

```

---

<div class="post-metadata">

**Author:** ![eziogi](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/eziogi/32/933222_2.png) [@eziogi](https://forum.arduino.cc/u/eziogi)\
**Post date:** [January 28, 2025, 10:33am UTC](https://forum.arduino.cc/t/my-touchscreen-does-not-work-with-esp32-devkit-v2-and-ili9341/1345120/17 "2025-01-28T10:33:08Z")

</div>

I downloaded and created the two sketches as recommended by “horace”.  
Installed on the ESP32 it works, I see on the serial monitor the 3 values when I press with the coop,,, but I don't see on the display the writings with the values as seen in the picture attached in post# 13.  
I figured out how the pins are connected.  
I checked the connections and they are correct.  
Did I maybe forget some verification?

---

<div class="post-metadata">

**Author:** ![6v6gt](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/6v6gt/32/225488_2.png) [@6v6gt](https://forum.arduino.cc/u/6v6gt)\
**Post date:** [January 28, 2025, 10:58am UTC](https://forum.arduino.cc/t/my-touchscreen-does-not-work-with-esp32-devkit-v2-and-ili9341/1345120/18 "2025-01-28T10:58:56Z")

</div>

To what ESP32 pin is the screen's CS pin connected ?  
Your code used TFT\_CS = 21. Horace's uses TFT\_CS = 15.

---

<div class="post-metadata">

**Author:** ![eziogi](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/eziogi/32/933222_2.png) [@eziogi](https://forum.arduino.cc/u/eziogi)\
**Post date:** [January 28, 2025, 1:24pm UTC](https://forum.arduino.cc/t/my-touchscreen-does-not-work-with-esp32-devkit-v2-and-ili9341/1345120/19 "2025-01-28T13:24:43Z")

</div>

I downloaded and used the sketch from “Horace”.  
The TFT\_Cs pin is 15.  
Should the TFT\_MISO pin be connected with the XPT2046\_MISO ? (19)  
Should the TFT\_MOSI pin be connected with the XPT2046\_MOSI ? (23)  
Should the TFT\_CLK pin be connected with the XPT2046\_CLK ? (18)  
I have not connected them together, should I do so ?

---

<div class="post-metadata">

**Author:** ![6v6gt](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/6v6gt/32/225488_2.png) [@6v6gt](https://forum.arduino.cc/u/6v6gt)\
**Post date:** [January 28, 2025, 1:39pm UTC](https://forum.arduino.cc/t/my-touchscreen-does-not-work-with-esp32-devkit-v2-and-ili9341/1345120/20 "2025-01-28T13:39:48Z")

</div>

> [@eziogi](#):
>
> Should the TFT\_MISO pin be connected with the XPT2046\_MISO ? (19)  
> Should the TFT\_MOSI pin be connected with the XPT2046\_MOSI ? (23)  
> Should the TFT\_CLK pin be connected with the XPT2046\_CLK ? (18)  
> I have not connected them together, should I do so ?

Yes.  
You've said the touch screen works so the above three SPI bus pins are clearly correct.

That means, for example that the same ESP32 pin (19) must be connected to both XPT2046\_MISO (marked TDO on the display module)  
and TFT\_MISO ( marked SDO(MISO) on the display module).

That is just as implied here:

> [@horace](#):
>
> or you can use the GPIO pins explicitly
> 
> ```arduino
> #define XPT2046_MOSI 23 // T_DIN
> #define XPT2046_MISO 19 // T_OUT
> #define XPT2046_CLK 18 // T_CLK
> 
> #define TFT_MOSI 23 
> #define TFT_SCLK 18 
> #define TFT_MISO 19 
> 
> ```

[Next page](https://forum.arduino.cc/t/my-touchscreen-does-not-work-with-esp32-devkit-v2-and-ili9341/1345120.md?page=2)
