I'm moving a project using UNO and parallel TFT Touch to ESP32 because there are too few pins for additional peripherals. I've purchased two new devices.
The ESP32 is this one (38 pin):
ESP32-WROOM-32
The SPI Touch display is this one (2.8", 240x320):
SPI 2.8" TFT Touch Display
I'm using the ETFT_eSPI library and examples developed and maintained by Bodmer.
Here's how the two boards are connected:
Also this:
I've selected ESP-WROOM-DA-MODULE for the board, being nearest to the ESP-WROOM-32 bought.
User Setup:
Here are the changes made to User_Setup.h:
#define TFT_WIDTH 240 // ST7789 240 x 240 and 240 x 320
#define TFT_HEIGHT 320 // ST7789 240 x 320
#define ST7735_GREENTAB
#define TFT_MISO 19
#define TFT_MOSI 23
#define TFT_SCLK 18
#define TFT_CS 15 // Chip select control pin
#define TFT_DC 2 // Data Command control pin
#define TFT_RST 4 // 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 (pin 2)
// Added from a post Apr 2023 with David Prentice by ricm:
#define TOUCH_CLK 18 // yellow
#define TOUCH_CS 21 // cyan (Chip select pin (T_CS) of touch screen)
#define TOUCH_DIN 23 // blue
#define TOUCH_DO 19 // white
#define SUPPORT_TRANSACTIONS
Testing
Here's the output from User_Setup Test sketch:
TFT_eSPI ver = 2.5.0
Processor = ESP32
Frequency = 240MHz
Transactions = Yes
Interface = SPI
Display driver = 9341
Display width = 240
Display height = 320
MOSI = GPIO 23
MISO = GPIO 19
SCK = GPIO 18
TFT_CS = GPIO 15
TFT_DC = GPIO 2
TFT_RST = GPIO 4
TOUCH_CS = GPIO 21
Font GLCD loaded
Font 2 loaded
Font 4 loaded
Font 6 loaded
Font 7 loaded
Font 8 loaded
Smooth font enabled
Display SPI frequency = 27.00
Touch SPI frequency = 2.50
I've tried quite a few graphics examples and all display correctly. (Much faster than the UNO!). I'm taking that to imply the TFT connections and User_Setup are correctly aligned and working.
Problem:
The Touchscreen has some response, but nothing like expected, i.e., Raw values are way out for x, y, and z. x & y are either all nor nothing and there's no smooth change in values as the stylus is moved to different parts of the screen. z values are also 0 or full.
Here's typical output from the test script when there are no presses:
x: 0 y: 2431 z: 4109
x: 0 y: 2361 z: 4109
x: 0 y: 2411 z: 4108
x: 0 y: 2360 z: 4109
x: 0 y: 2008 z: 4108
x: 0 y: 2384 z: 4109
x: 0 y: 2351 z: 4108
x: 0 y: 2017 z: 4108
x: 0 y: 2019 z: 4108
x: 0 y: 2084 z: 4108
x: 0 y: 2472 z: 4108
Here's typical output when the stylus presses centre-screen (expected x:mid-range, y:mid-range):
x: 1034 y: 0 z: 0
x: 1224 y: 0 z: 4097
x: 1015 y: 0 z: 0
x: 1175 y: 2 z: 0
x: 1153 y: 0 z: 0
x: 1108 y: 0 z: 0
x: 988 y: 0 z: 4122
x: 1009 y: 0 z: 0
x: 1024 y: 0 z: 4098
x: 1036 y: 0 z: 0
x: 1070 y: 0 z: 0
x: 1164 y: 10 z: 0
...and here's typical output when the screen is touched top-centre (expected y:0 and x:mid-range)
x: 872 y: 0 z: 3982
x: 1011 y: 0 z: 0
x: 1135 y: 0 z: 0
x: 1092 y: 2 z: 0
x: 1175 y: 0 z: 0
x: 868 y: 0 z: 0
x: 952 y: 0 z: 4087
x: 853 y: 0 z: 0
x: 812 y: 0 z: 4096
In fact the output is almost the same irrespective of where the screen is touched.
Remedies:
- Double-checked the wiring against my Fritzing (but that Fritzing could still be wrong)
- Checked User_Setup matches physical wiring
- Replaced wires in case broken
- Moved SPI-TFT to different part of breadboard in case tracks are damaged
- Changed _CS from GPIO 15 to GPIO 5 (default VSPI pin) and moved the jumper.
- Changed the board to ESP-32_DEV temporarily
None of these have changed the Touchscreen response. TFT display remains healthy.
Of course the TFT Touchscreen could be faulty but I suspect nearly all are shipped working. So I'm still pursuing the notion that the configuration is somehow wrong.
I'm thinking the SPI isn't accessing the touch connections properly? Whilst TFT and Touch share the same VSPI, they have separate _CS. Any suggestions where next?
Thanks,
Ric