TFT_eSPI library works on ESP32 WROOM Dev board but not on other boards like ESP32 C3 Supermini or XIAO C3 Mini

Hallo everybody
Today I am just testing some TFT Displays on different ESP32 boards and get some issues which I can't solve and need some help:
I usually make some test PCB's for general testing new HW or new sketches. on the foto you see an ESP32 WROOM 38pin Dev Board, an XIAO Esp32 C3 Mini board and a ESP32 C3 Supermini board which I allready used many times.


Now I did some tests to get a ST7735 TFT Display and a ILI9341 TFT Display working on these Dev boards. I was using the example sketches from the AdafruitI LI9341, the AdafruitST7735 and the TFT_eSPI libraries. Of course I adapted each example to my different SPI configurations, with Adafruit inside the sketch and with the TFT_eSPI in the User_Setup.h file. Look at my little table to see my results:

As you can see, every display works good on the WROOM Dev Board with any library but not on the other Mini Dev Boards. The othe issue is that the Adafruit libraries work for any display on every Dev Board but very slow. Seems like at least the ILI-Display does not get run with the hardware SPI allthough I am using the designated pins.
The used sketches are examples from the libraries just adapted to the SPI pins.
for the XIAO Board looks like this:


#include "SPI.h"
#include "Adafruit_GFX.h"
#include "Adafruit_ILI9341.h"

// For the Adafruit shield, these are the default.
#define TFT_DC 5
#define TFT_CS 20
#define TFT_MOSI 10
#define TFT_CLK 8
#define TFT_RST 3
#define TFT_MISO -1

// Use hardware SPI (on Uno, #13, #12, #11) and the above for CS/DC
//Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC); // DOES NOT WORK ON NO ESP32 BOARD
// If using the breakout, change pins as desired
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_MOSI, TFT_CLK, TFT_RST, TFT_MISO);

void setup() {
  Serial.begin(9600);
  Serial.println("ILI9341 Test!"); 
 
  tft.begin();

the User_Setup.h file:

//                            USER DEFINED SETTINGS
// User defined information reported by "Read_User_Setup" test & diagnostics example
#define USER_SETUP_INFO "User_Setup"

 #define ILI9341_DRIVER       // Generic driver for common displays
// #define ILI9341_2_DRIVER     // Alternative ILI9341 driver, see https://github.com/Bodmer/TFT_eSPI/issues/1172

// 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 23
 #define TFT_SCLK 18
 #define TFT_CS    5  // Chip select control pin
 #define TFT_DC    0  // Data Command control pin
 #define TFT_RST   2  // 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 ESP32 C3 Supermini
// The hardware SPI can be mapped to any pins

//#define TFT_MOSI  6 
//#define TFT_SCLK  4
//#define TFT_CS    7 
//#define TFT_DC    3 
//#define TFT_RST   2 

// For ESP32 XIAO C3 Supermini
// The hardware SPI can be mapped to any pins

// #define TFT_MOSI  10 
// #define TFT_SCLK  8
// #define TFT_CS    20 
// #define TFT_DC    5 
// #define TFT_RST   3

#define LOAD_GLCD   // Font 1. Original Adafruit 8 pixel font needs ~1820 bytes in FLASH
#define LOAD_FONT2  // Font 2. Small 16 pixel high font, needs ~3534 bytes in FLASH, 96 characters
#define LOAD_FONT4  // Font 4. Medium 26 pixel high font, needs ~5848 bytes in FLASH, 96 characters
#define LOAD_FONT6  // Font 6. Large 48 pixel font, needs ~2666 bytes in FLASH, only characters 1234567890:-.apm
#define LOAD_FONT7  // Font 7. 7 segment 48 pixel font, needs ~2438 bytes in FLASH, only characters 1234567890:-.
#define LOAD_FONT8  // Font 8. Large 75 pixel font needs ~3256 bytes in FLASH, only characters 1234567890:-.
//#define LOAD_FONT8N // Font 8. Alternative to Font 8 above, slightly narrower, so 3 digits fit a 160 pixel TFT
#define LOAD_GFXFF  // FreeFonts. Include access to the 48 Adafruit_GFX free fonts FF1 to FF48 and custom fonts

// Comment out the #define below to stop the SPIFFS filing system and smooth font code being loaded
// this will save ~20kbytes of FLASH
#define SMOOTH_FONT

#define SPI_FREQUENCY  27000000
#define SPI_READ_FREQUENCY  20000000
#define SPI_TOUCH_FREQUENCY  2500000

#define USE_HSPI_PORT

any ideas what is happening ???
thanks so far

Looks like your using the Adafruit_ILI9341 Library in software SPI mode, which would be slow.

yes, that's what I think too. The object tft never starts in hardware mode. If I use the ST7735 display and library I can start the tft object in hardware mode by passing only TFT_CS, TFT_MOSI and TFT_CLK and it works pretty fast. Crosschecking and defining all SPI pins results in slow motion also on the ST7735 display. This might be the problem with the TFT_eSPI library, it never initializes in HW-mode even defining the designated SPI-pins and therefore it does not work at all.

If your not passing TFT_DC, dont expect the display to work.

yes sorry of course, for HW-mode with Adafruit library I passed TFT_CS and TFT_DC, not TFT_MOSI. But what I just found is that I have to pass TFT_RST as well to start in HW mode and then it works with both displays. The Adafruit examples have this in the sketch:

Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC); // DOES NOT WORK ON NO ESP32 BOARD

the correct line must be :

Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST); 

OK, work with Adafruit libraries is fixed but what about TFT_eSPI ??? how do I force HW-mode with this library ???

Does the TFT_eSPI library support software SPI ?

In User_Setup.h I don't have any SPI pins defined just CS,DC and RST.

Start up the SPI with;

SPI.begin();

If your using the standard SPI pins for that board or;

SPI.begin(SCK, MISO, MOSI);

If your using other pins.

good morning and back again...
@srnet
everything tested with TFT_eSPI on WROOM Devboard works great, changing to XIAO ESP32 C3 doesn't work at all, I think i'll give up and switch to Adafruit library. It's a pitty I liked Bodmer's library.

Tried this? :
https://github.com/Bodmer/TFT_eSPI/blob/master/User_Setups/Setup70c_ESP32_C3_ILI9341.h

just tried, no success :slightly_frowning_face:

Hi galacticobmg,
ESP32-C3's and Xiao ESP32C3's work perfectly with sketches using Bodmer's TFT_eSPI.h library. Sprites work fantastically. Please consult http://thesolaruniverse.wordpress.com
success, Photoncatcher

@photoncatcher thanks for this useful link. Here I found the solution, I´d like to comment it:
For the SPI pin assignment in the User_Setup.h file I used the GPIO pinnumbers (10, 9, 8, 7, 3, 2) which does not work. I set a "D" in front (D10, D9, ...) and suddenly it works.
Thanks to all who tried to help, @photoncatcher won the race :wink: :slightly_smiling_face: