Hi there,
for the past couple of days I've tried to get a simple ILI9341 TFT to work with the gateway board (Rev E) - to no avail.
I've testes a whole bunch of other boards and worked out those pin definitions - namely a feather32, lolin32 and a D1 Mini. The code is as follows:
#include "SPI.h"
#include "Adafruit_GFX.h"
#include "Adafruit_ILI9341.h"
/*
// FEATHER
#define _dc 15 // goes to TFT DC
#define _rst 33 // goes to TFT RESET
#define _cs 32 // goes to TFT CS
#define _mosi 18 // goes to TFT MOSI
#define _sclk 5 // goes to TFT SCK/CLK
#define _miso 19 // goes to TFT MISO for debugging
*/
/*
// LOLIN32
#define _dc 13 // goes to TFT DC
#define _rst 12 // goes to TFT RESET
#define _cs 14 // goes to TFT CS
#define _mosi 18 // goes to TFT MOSI
#define _sclk 5 // goes to TFT SCK/CLK
#define _miso 19 // goes to TFT MISO for debugging
*/
/*
// D1MINI
#define _dc 5 // goes to TFT DC
#define _rst 4 // goes to TFT RESET
#define _cs 15 // goes to TFT CS
#define _mosi 13 // goes to TFT MOSI
#define _sclk 14 // goes to TFT SCK/CLK
#define _miso 12 // goes to TFT MISO for debugging
*/
// Use hardware SPI
Adafruit_ILI9341 tft = Adafruit_ILI9341(_cs, _dc, _rst);
// Fallback to software SPI
//Adafruit_ILI9341 tft = Adafruit_ILI9341(_cs, _dc, _mosi, _sclk, _rst);
void setup() {
tft.begin();
tft.fillScreen(ILI9341_BLUE);
}
void loop() {
}
However I cannot get this simple sketch to work on the Gateway. I've tried with defining the vspi reference and pin-mapping, which also did not work.
#include "SPI.h"
#include "Adafruit_GFX.h"
#include "Adafruit_ILI9341.h"
//GATEWAY
#define _dc 5 // goes to TFT DC
#define _rst 10 // goes to TFT RESET
#define _cs 16 // goes to TFT CS
#define _mosi 39 // goes to TFT MOSI
#define _sclk 36 // goes to TFT SCK/CLK
#define _miso 35 // Not connected
SPIClass * vspi = NULL;
// Use hardware SPI
Adafruit_ILI9341 tft = Adafruit_ILI9341(vspi, _cs, _dc, _rst);
void setup() {
vspi = new SPIClass(VSPI);
vspi->begin(_sclk, _miso, _mosi, _cs);
pinMode(_cs, OUTPUT);
tft.begin();
tft.fillScreen(ILI9341_BLUE);
}
void loop() {
}
Is there anyone smarter than me who can point me in the right direction - be it a working pin-out for the SPI bus on the GPIO header or a combination of pins I could try?
What's the common difference between the boards that you used successfully and ESP32-GATEWAY? It seems to me that they have no Ethernet, neither SD card. I would assume it is multiplexing issue.
Yup, no ethernet and no SD either. So, switching to a esp32-poe model without the SD card might solve my problem? Ethernet is crucial for my application but the SD card will never be used anyway.
But why might there be a multiplexing issue if they SPI busses are totally separated, like using VSPI an HSPI? The method of using those busses and the chosen GPIO pins should work or is there any crossover between those pins and internal functions of the board (nothing I can see in the schematics would hint to that).
I think SPI can be redefined to any free GPIO pin. I believe this comes at the cost of maximum SPI speed (e.g. if using default SPI pins you get max SPI speed, else only half of it) but it is worth testing if this can be solved by software means. Worth checking here: https://docs.espressif.com/projects/esp-idf/en/latest/api-reference/peripherals/spi_master.html