Drive ILI9341 SPI TFT with Touch function on ESP32-S3 using TFT_eSPI library

Last post show how to Drive 320x240 ILI9341 SPI TFT using ESP32-S3 (NodeMCU ESP-S3-12K-Kit) using TFT_eSPI library, in Arduino Framework. Here show how to modify user setup file to include Touch function, and how to run calibration.


Connection between NodeMCU ESP-S3-12K-Kit and ILI9341 SPI TFT
with touch function

Both TFT and Touch share the same SPI pins, but difference CS.

Pins			NodeMCU ESP-S3-12K-Kit
1 	VCC		3V3
2 	GND		GND
3 	CS		34
4 	RESET		15
5 	DC/RS		16
6 	SDI(MOSI)	35
7 	SCK		36
8 	LED		3V3
9 	SDO(MISO)	37
10 	T_CLK		36
11 	T_CS		19
12 	T_DIN		35
13 	T_DO		37
14 	T_IRQ		No connection


Modify mySetup70b_ESP32_S3_ILI9341.h from last post to include touch function.
// 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   34 //     10 or 34 (FSPI CS0) 
#define TFT_MOSI 35 //     11 or 35 (FSPI D)
#define TFT_SCLK 36 //     12 or 36 (FSPI CLK)
#define TFT_MISO 37 //     13 or 37 (FSPI Q)

/*
 * in NodeMCU ESP-S3-12K-Kit, GPIO 6 and 7 are connected to LEDs,
 * so re-allocate to GPIO 15 and 16.
 */
// Use pins in range 0-31
#define TFT_DC    16     //7
#define TFT_RST   15     //6

#define TOUCH_CS  19     //16 // 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 port (SPI2) used unless following defined. HSPI port (SPI3) NOT TESTED YET
//#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


Make sure the User_Setup_Select.h file point to the custom setup file, refer last post.

Open Examples > TFT_eSPI > 320x240 > Keypad_240x320

If it's the first time you run it, or after screen rotation, or you want to run calibration, edit to set REPEAT_CAL to true, then it wll run calibration and save the calibration data in SPIFFS.


Then re-load with REPEAT_CAL set false, it will skip calibration and load the calibration data from SPIFFS.


Related:
Drive ST7796 SPI TFT with XPT2046 Touch on ESP32-C3-DevKitM-1 (arduino-esp32), using TFT_eSPI.




Comments

Popular posts from this blog

480x320 TFT/ILI9488 SPI wih EP32C3 (arduino-esp32) using Arduino_GFX Library

MicroPython/ESP32-C3 + 1.8" 128x160 TFT ST7735 SPI, using boochow/MicroPython-ST7735 library.