Need help connecting ILI9341 Touchscreen to my ESP32-S3-DEVKITC-1U-N8R8

Hello, I am having trouble connecting my ILI9341 Touchscreen (TFT SPI) to my ESP32-S3-DEVKITC-1U-N8R8. The tutorials I’ve found online use different pin layouts compared to my board, so I’m unsure how to connect the display correctly. Could someone please help me figure out the correct wiring? I have provided images of my ESP pin layout and the pins that are on the touchscreen. Thanks a lot in advance for the help.


I used the following connections for a ILI9341

// ESP32_S3_DevKit_1 connections
#define TFT_CS    10  
#define TFT_DC    9
#define TFT_MOSI  11
#define TFT_CLK   12
#define TFT_RST   3
#define TFT_MISO  13

if J1 is not linked power from 5V
LED from 3.3V

which graphics library are you planning to use? e.g. Adafruit_ILI9341 library, TFT_eSPI

Thank you. Where should I connect the rest?
This is what I currently have:
T_IRQ
T_OUT
T_DIN
T_CS GPIO10
T_CLK GPI012
SDO(MISO) GPIO13
LED 3V3
SCK
SDI(MOSI) GPIO11
D/C GPIO9
RESET GPIO3
CS
GND GND
VCC 5V

I plan to use the TFT_eSPI and XPT2046_Touchscreen libraries in PlatformIO.

did the connections in post 2 work?
which library did you use?

TS is for TOUCH.
This is wrong , must be CS = 10 and CLK = 12
First just try to get the screen working add the Touch later.

I only have T_CLK.
These are the connections I currently have:
T_IRQ
T_OUT
T_DIN
T_CS
T_CLK GPI012
SDO(MISO) GPIO13
LED 3V3
SCK
SDI(MOSI) GPIO11
D/C GPIO9
RESET GPIO3
CS GPIO10
GND GND
VCC 5V

The screen is just white right now. I plan to use the TFT_eSPI and XPT2046_Touchscreen libraries in PlatformIO.

T_IRQ is only needed if you want interrupts on the touch screen.

MISO is not needed for the TFT. You can power the LED with 3V3 as well, no need for the 5V.

I had to create an HSPI object to handle the touch. Default pins were not the same for the S3 as they are for the older devkit’s. At least from memory that is what I found.

Anyway, edit the user_setup.h file in the TFT_eSPI library. You don’t have to use the pins I use, pick whatever is convienent for you.

This is for the display

// ###### EDIT THE PIN NUMBERS IN THE LINES FOLLOWING TO SUIT YOUR ESP32 SETUP   ######

// For ESP32 Dev board (only tested with ILI9341 display)
// The hardware SPI can be mapped to any pins

#define TFT_MISO 19
#define TFT_MOSI 6
#define TFT_SCLK 4
#define TFT_CS   15  // Chip select control pin
#define TFT_DC   7  // Data Command control pin
#define TFT_RST   -1  // Reset pin (could connect to RST pin)
//#define TFT_RST  -1  // Set TFT_RST to -1 if display RESET is connected to ESP32 board RST

For touch define pins and create the HSPI object, TFT object, and touchscreen object. Again, use pins that are convienent for you and don’t need to do something else. I spent a good amount of time going through online resources to determine which pins I was going to use. Also the pins that are used are for easier placement on my pcb as well. Point being, use what is good for you.

// Touch Screen
#define TS_CS 36
#define TS_MOSI 37
#define TS_MISO 2
#define TS_CLK 35

// Create TFT display object
TFT_eSPI tft = TFT_eSPI();

// Create an HSPI instance for the touchscreen
SPIClass touchSPI(HSPI);

// Touchscreen object
XPT2046_Touchscreen ts(TS_CS);

In the setup start the objects. Probably wrong phrase there…

// Built in library function to start display
tft.init();
// Start HSPI with the touch pins
touchSPI.begin(TS_CLK, TS_MISO, TS_MOSI, TS_CS);
ts.begin(touchSPI);

I highly recommend Bytes N Bits Youtube video for getting started with the screen calibration and a button class to get you going if you don’t know how to do this already. They go over wiring with the older dev boards, but like I said, that had to change a bit with the S3.

post your code?
don't use PlatformIO so cannot help there - try posting on PlatformIO Community?

You can also use the same SPI bus for both the touch part and the TFT part if you want. This can simplify the wiring a bit and may be useful if you later want to move the project to a low pinout Xiao or super mini format ESP32. That is the following pairs of pins are connected together

T_CLK and SCK (you seem not to have allocated SCK)
T_OUT and SDO(MISO)
T_DIN and SDI(MOSI)

Note:
T_CS cannot be shared.
T_IRQ is not required.

RESET can simply be pulled high to 3v3 say with a 10k resistor.

I have several 2.8" versions of your screen for two projects. I use Adafruit libraries for the TFT part and a XPT2046 library for the touch part.

Does this look good?
T_IRQ
T_OUT GPIO13
T_DIN GPIO11
T_CS GPIO14
T_CLK GPI012
SDO(MISO) GPIO13
LED 3V3
SCK GPIO12
SDI(MOSI) GPIO11
D/C GPIO7
RESET GPIO6
CS GPIO10
GND GND
VCC 5V

It looks OK to me and you have avoided the ESP32 strapping pins, so it seems you will be ready to move on to the next phase of assembling a test system on a breadboard.

This is what I currently have:
T_IRQ
T_OUT
T_DIN
T_CS
T_CLK
SDO(MISO) GPIO13
LED 3V3
SCK GPI012
SDI(MOSI) GPIO11
D/C GPIO7
RESET GPIO6
CS GPIO10
GND GND
VCC 5V

This is my UserSetup.h file, I made it based on this

// Setup for the ESP32 S3 with ILI9341 display
// Note SPI DMA with ESP32 S3 is not currently supported
#define USER_SETUP_ID 70
// See SetupX_Template.h for all options available
#define ILI9341_DRIVER

                    // Typical board default pins - change to match your board
#define TFT_CS   10 //     10 or 34 (FSPI CS0) 
#define TFT_MOSI 11 //     11 or 35 (FSPI D)
#define TFT_SCLK 12 //     12 or 36 (FSPI CLK)
#define TFT_MISO 13 //     13 or 37 (FSPI Q)


// Use pins in range 0-31
#define TFT_DC    7
#define TFT_RST   6

//#define TOUCH_CS 14 // Optional for touch screen

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

#define SMOOTH_FONT

// FSPI (or VSPI) port (SPI2) used unless following defined. HSPI port is (SPI3) on S3.
//#define USE_HSPI_PORT

//#define SPI_FREQUENCY  27000000
#define SPI_FREQUENCY  40000000   // Maximum for ILI9341

#define SPI_READ_FREQUENCY  6000000 // 6 MHz is the maximum SPI read speed for the ST7789V

#define SPI_TOUCH_FREQUENCY 2500000

However, the screen is just glowing white. When I try to run any test code nothing happens and it just continues to glow white. The terminal spams:
ELF file SHA256: 18fa95fc9a937c52

Rebooting...
ESP-ROM:esp32s3-20210327
Build:Mar 27 2021
rst:0xc (RTC_SW_CPU_RST),boot:0x8 (SPI_FAST_FLASH_BOOT)
Saved PC:0x42026c42
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fce3808,len:0x4bc
load:0x403c9700,len:0xbd8
load:0x403cc700,len:0x2a0c
entry 0x403c98d0
Guru Meditation Error: Core 1 panic'ed (StoreProhibited). Exception was unhandled.

Core 1 register dump:
PC : 0x42002937 PS : 0x00060830 A0 : 0x82002a0c A1 : 0x3fcebbe0
A2 : 0x00000010 A3 : 0x00000000 A4 : 0x60004000 A5 : 0x0000000b
A6 : 0x000000ff A7 : 0x00000000 A8 : 0x08000000 A9 : 0x3fcebbb0
A10 : 0x3fc97094 A11 : 0x00000001 A12 : 0xffffffff A13 : 0x00000040
A14 : 0x00000000 A15 : 0x3fc94008 SAR : 0x00000010 EXCCAUSE: 0x0000001d
EXCVADDR: 0x00000010 LBEG : 0x4201677c LEND : 0x420167e0 LCOUNT : 0x00000003

Backtrace: 0x42002934:0x3fcebbe0 0x42002a09:0x3fcebc10 0x4200190f:0x3fcebc30 0x42004e32:0x3fcebc50

ELF file SHA256: 18fa95fc9a937c52

Rebooting...
ESP-ROM:esp32s3-20210327
Build:Mar 27 2021
rst:0xc (RTC_SW_CPU_RST),boot:0x8 (SPI_FAST_FLASH_BOOT)
Saved PC:0x42026c42
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fce3808,len:0x4bc
load:0x403c9700,len:0xbd8
load:0x403cc700,len:0x2a0c
entry 0x403c98d0
Guru Meditation Error: Core 1 panic'ed (StoreProhibited). Exception was unhandled.

Core 1 register dump:
PC : 0x42002937 PS : 0x00060830 A0 : 0x82002a0c A1 : 0x3fcebbe0
A2 : 0x00000010 A3 : 0x00000000 A4 : 0x60004000 A5 : 0x0000000b
A6 : 0x000000ff A7 : 0x00000000 A8 : 0x08000000 A9 : 0x3fcebbb0
A10 : 0x3fc97094 A11 : 0x00000001 A12 : 0xffffffff A13 : 0x00000040
A14 : 0x00000000 A15 : 0x3fc94008 SAR : 0x00000010 EXCCAUSE: 0x0000001d
EXCVADDR: 0x00000010 LBEG : 0x4201677c LEND : 0x420167e0 LCOUNT : 0x00000003

Backtrace: 0x42002934:0x3fcebbe0 0x42002a09:0x3fcebc10 0x4200190f:0x3fcebc30 0x42004e32:0x3fcebc50

Here is an example code:

#include <Arduino.h>
#include <TFT_eSPI.h>  
#include <SPI.h>

TFT_eSPI tft = TFT_eSPI();  

void setup() {
  tft.init();             
  tft.setRotation(1);      
  tft.fillScreen(TFT_BLACK);  

  tft.setTextColor(TFT_WHITE, TFT_BLACK);  
  tft.setTextSize(2);      
  tft.setCursor(50, 60);   
  tft.println("Hello World!");
  tft.setCursor(50, 100);
  tft.println("ESP32-S3 + ILI9341");
}

void loop() {
}


which version of the ESP32 core are you using?
I seem to remember there are problems with ESP32S3 and TFT_eSPI with recent versions of the ESP32 core which causes the ESP32S3 to go into a reset loop
try resetting back to Core 2.0.14?

Indeed. This, and other similar reports, do not look good for TFT_eSPI: espressif boards 3.xxx · Issue #3811 · Bodmer/TFT_eSPI · GitHub
The equivalent Adafruit libraries appear still to be well supported.

What should I use instead of TFT_esPI?

How do I check and change the ESP32 core version? What version would you recommend changing it to?

Click Tools>Board then Board Manager enter ESP32 and can see the current ESP32 core and change it, e.g. this shows 3.2.0

some time back there was an upgrade of ESP32 core from V2.x to V 3.X
caused problems with existing code and libraries not working with new core 3.x

however, TFT_eSPI has problems on some ESP32 family with any ESP32 core greater than 2.0.14

setting ESP32 core back to 2.0.14 can then cause problems if code also uses libraries which have been updated to 3.x etc etc

What was your original reason for wanting to use specifically TFT_esPI ?
If you are going to use the screen with something based on an existing project then that could be a reason to stay with that library.

I use the Adafruit libraries "Adafruit ILI9341 TFT" and "Adafruit GFX".
If you want to go that route then check out say this example: Adafruit_ILI9341/examples/graphicstest/graphicstest.ino at master · adafruit/Adafruit_ILI9341 · GitHub

That is exactly the dilemma when these experts (Bodmer, David Prentice etc.) quit the scene one way or another. Espressif (ESP) are notorious for introducing breaking changes and, even with the "UNO", every new variant has a completely different hardware platform, meaning that active maintenance is important. For less experienced users, my tendency is to suggest libraries which are well supported unless there is an overriding reason for another choice.

1 Like