TFT_eSPI: Dark screen, I must be missing something [SOLVED]

Hi all,

I have a Waveshare ESP32-S3-Nano and a 1.69" 240x280 TFT IPS Display. When using the <Adafruit_GFX> and <Adafruit_ST7789> libraries, the display works fine, like running the "graphicstest" example. The wiring is as follows:

Disp - ESP32
GND - GND
VDD - 3V3
SCL - D13
SDA - D11
RES - RST
DC - D2
CS - D3
BLK - 3V3

D11, D12 and D13 are the hardware SPI pins according to the manufacturer. In the sketch I defined TFT_CS 3, TFT_RST -1 and TFT_DC 2 according to my wiring. As said, works like a charm.

Now, I'd like to run my display using @bodmer 's TFT_eSPI library. And here after hours of experimenting I still just get a dark display. Wiring is identical to the above. Steps I ve done are as follows:

  • Using Ardunio IDE 2.3.2
  • Installed TFT_eSPI 2.5.43 via the library manager
  • In the file "User_Setup_Select.h":
    • commented the default setup (//#include <User_Setup.h>)
    • uncommented the to the best of my knowledge matching setup file (#include <User_Setups/Setup203_ST7789.h> // Setup file for ESP32/ESP8266 based ST7789 240X280 1.69inch TFT )
  • In the file "Setup203_ST7789.h":
    • uncommented "#define TFT_INVERSION_ON" - not that it would be relevant to my problem I assume
    • under "Generic ESP32 setup" I uncommented and changed pin assignments as follows:
#define TFT_MISO 12
#define TFT_MOSI 11
#define TFT_SCLK 13
#define TFT_CS    3
#define TFT_DC    2
#define TFT_RST   -1 

What beats me, in the original file it says chip select should not be connected?

//#define TFT_CS -1 // Not connected

Why would that be?

To finish my edits, under the next section "For NodeMCU" there are three uncommented lines for TFT_CS, TFT_DC and TFT_RST which I have commented out in order to avoid conflict with my definitions.

Then trying the example "TFT_eSPI" -> "Generic" -> "Gradient_Fill" I get nothing after upload, just a dark screen. Running the diagnostics "Read_User_Setup" sketch I get:

TFT_eSPI ver = 2.5.43
Processor    = ESP32
Frequency    = 240MHz
Transactions = Yes
Interface    = SPI
Display driver = 9341
Display width  = 240
Display height = 320

MOSI    = GPIO 11
MISO    = GPIO 12
SCK     = GPIO 13
TFT_CS   = GPIO 3
TFT_DC   = GPIO 2

Font GLCD   loaded
Font 2      loaded
Font 4      loaded
Font 6      loaded
Font 7      loaded
Font 8      loaded
Smooth font enabled

Display SPI frequency = 40.00

The pins match my setup so it must be reading my edited setup file correctly. But why is the display driver "9341"?

Thinking maybe me hooking up Chip Select in contrary to what was written in the setup file could be an issue: I went back, removed the CS wire phyiscally and in the setup file and moved the display RST wire to pin 3 on the ESP32. User setup readout now gives:

TFT_eSPI ver = 2.5.43
Processor    = ESP32
Frequency    = 240MHz
Transactions = Yes
Interface    = SPI
Display driver = 9341
Display width  = 240
Display height = 320

MOSI    = GPIO 11
MISO    = GPIO 12
SCK     = GPIO 13
TFT_DC   = GPIO 2
TFT_RST  = GPIO 3

Font GLCD   loaded
Font 2      loaded
Font 4      loaded
Font 6      loaded
Font 7      loaded
Font 8      loaded
Smooth font enabled

Display SPI frequency = 40.00

Uploading the "Gradient_Fill" sketch still gives a dark display.

There is one additional thing I've noticed, the diagnostic refers to the pins as "GPIO" whereas in the manufacturer pinout diagram I am using the numbers after "D", e.g. I am using 13 in my pin definitions for the SPI CLK, not D13 or even GPIO48. But I couldn't get it to work as well using the GPIO numbers from the manufacturer pinout diagram.

I am lost...

Both need CS lines.
I recommend setting all SPI device CS lines as either INPUT_PULLUP or OUTPUT and HIGH before initializing any device on the SPI bus.

Both

void setup(void) {
  pinMode(D3, OUTPUT);
  digitalWrite(D3, HIGH);
  tft.init();

or

void setup(void) {
  pinMode(D3, INPUT_PULLUP);
  tft.init();

didn't help. I assume this should be covered in the library anyway?

Why not use the hardware SPI?

The libraries for the SPI devices handle the CS lines once the device is initialized, but before that the lines float if not set HIGH.

I'm not fully familiar with the terms but to the best of my knowledge I am using the hardware SPI pins. What I've read the tft_eSPI library examples should be working out of the box (also stated on his Github) without adding an pinModes to the example sketches?

Why did you give up on this library? I use it.

Because for my project I need the higher speed, the gauges and the soft fonts.

Post your code.

SOLUTION: The Waveshare ESP32-S3-Nano is Arduino Nano ESP32 compatible. For (at least some) third-party libraries the pin numbers printed on the board do not work. One needs to switch to GPIO numbering in Arduino IDE and then use the GPIO numbers of the pins (NOT the printed numbers on the board). Using this approach the display works flawlessly.

Detailed info here:
https://docs.arduino.cc/tutorials/nano-esp32/pin-setup/

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.