I am using a XIAO ESP32 Seeeduino with an ILI9341 TFT display that is working great. The touch screen is also working well.
The problem is that I have to disconnect the MISO connection ( TFT_MISO to GPIO9 ) every time I power on the ESP32. When I power on the ESP32 the display is blank, but when I disconnect MISO and power back on the ESP32 I do get the image. Then I connect back MISO and it works as it should (the touch doesn't work leaving MISO disconnected). I don't know if it is a hardware or software issue.
I tried connecting MISO to GND with a 10k ohm resistor and setting pinMode(TFT_MISO, INPUT_PULLUP)
, but none worked.
Pin connections:
VCC -> 5 V
GND -> GND
CS -> GPIO3
RST -> GPIO4
DC -> GPIO5
MOSI -> GPIO10
SCK -> GPIO8
LED -> 5 V
MISO -> GPIO9
T_CLK -> TFT_SCK
T_CS -> GPIO21
T_DIN -> TFT_MOSI
T_DO -> TFT_MISO
Arduino setup:
#include <Adafruit_ILI9341.h>
#include <XPT2046_Touchscreen.h>
#include <SPI.h>
#define CS_PIN 21
#define TFT_CS 3 // TFT CS pin is connected to esp pin 3
#define TFT_RST 4 // TFT RST pin is connected to esp pin 4
#define TFT_DC 5 // TFT DC pin is connected to esp pin 5
#define TFT_MISO 9
XPT2046_Touchscreen ts(CS_PIN);
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST);
void setup() {
pinMode(TFT_MISO, INPUT_PULLUP);
Serial.begin(38400);
pinMode(TFT_CS, OUTPUT);
pinMode(CS_PIN, OUTPUT);
digitalWrite(TFT_CS, HIGH);
digitalWrite(CS_PIN, HIGH);
esp_sleep_enable_timer_wakeup(1000000);
tft.begin();
tft.setRotation(1);
ts.begin();
ts.setRotation(1);
tft.fillScreen(ILI9341_BLACK);
tft.fillCircle(160, 120, 120, ILI9341_RED);
tft.setTextColor(ILI9341_WHITE);
tft.setTextSize(3);
tft.setCursor(20, 110);
tft.fillScreen(ILI9341_BLACK);
tft.fillCircle(160, 120, 120, ILI9341_GREEN);
tft.setTextColor(ILI9341_BLACK);
tft.setTextSize(4);
tft.setCursor(100, 110);
tft.print("Start");
}