TFT screen problem with ESP8266

Hello,
I have an ILI9341 TFT screen from Adafruit. It works fine with an Arduino Uno, but does not work on my NodeMCU ESP8266. I paid attention to the pinout:
CS pin is connected to D2 (ESP8266EX GPIO4),
RST pin is connected to D3 (ESP8266EX GPIO0),
D/C pin is connected to D4 (ESP8266EX GPIO2),
MOSI pin is connected to D7 (ESP8266EX GPIO13),
SCK pin is connected to D5 (ESP8266EX GPIO14),
VCC is connected to pin 3V3,
GND is connected to pin GND of the NodeMCU board.
I use the libraries Adafruit_GFX and Adafruit_ILI9341

Does anyone have any ideas? The screen lights up well, but nothing appears.
Thank you in advance.

I use D1 R1 boards which maps the ESP8266 GPIOn pins to the Arduino Dn headers:

static const uint8_t D0   = 3;
static const uint8_t D1   = 1;
static const uint8_t D2   = 16;
static const uint8_t D3   = 5;
static const uint8_t D4   = 4;
static const uint8_t D5   = 14;
static const uint8_t D6   = 12;
static const uint8_t D7   = 13;
static const uint8_t D8   = 0;
static const uint8_t D9   = 2;
static const uint8_t D10  = 15;
static const uint8_t D11  = 13;
static const uint8_t D12  = 12;
static const uint8_t D13  = 14;
static const uint8_t D14  = 4;
static const uint8_t D15  = 5;

My displays use D10 for TFT_CS (GPIO15) and D4 for SD_CS (GPIO4) and work fine.
All my other pins are the same as yours.

What "Board" have you selected in the IDE?
What constructor have you used in the Adafruit examples?

Note that Adafruit always try to crash non-Adafruit displays by omitting the TFT_RST argument in the constructor.
However your display was made by Adafruit. So it will have a pullup on the pcb and be ok with the cut-down constructor.

I strongly advise you to use the full-fat constructor. This will ensure that GPIO0 is under program control.

David.

Hello David,

Thank you for your answer.
I use a "NodeMCU 1.0 ESP-12E" board.

My constructor is the following:

#include <Adafruit_GFX.h>
#include <Adafruit_ILI9341.h>
#define TFT_CS D8 // TFT CS pin is connected to NodeMCU pin D8
#define TFT_RST D3 // TFT RST pin is connected to NodeMCU pin D3
#define TFT_DC D4 // TFT DC pin is connected to NodeMCU pin D4
// initialize ILI9341 TFT library with hardware SPI module
// SCK (CLK) ---> NodeMCU pin D5 (GPIO14)
// MOSI(DIN) ---> NodeMCU pin D7 (GPIO13)
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST);

I moved the Chip-Select from D2 to D8, but it does not make a difference.
I don't use the CS card.

C:\Users\David Prentice\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\variants\nodemcu\pins_arduino.h

static const uint8_t D0   = 16;
static const uint8_t D1   = 5;
static const uint8_t D2   = 4;
static const uint8_t D3   = 0;
static const uint8_t D4   = 2;
static const uint8_t D5   = 14;
static const uint8_t D6   = 12;
static const uint8_t D7   = 13;
static const uint8_t D8   = 15;
static const uint8_t D9   = 3;
static const uint8_t D10  = 1;

You either use the Dn numbers or the GPIOn numbers. Only you know what board you actually have.


There are several other NodeMcu boards that might have different wiring e.g. GPIOn to Dn

I am happy with using Dn numbers on my D1 R1 board because it has regular Arduino headers.
For random boards with random pinouts it is wiser to use the GPIOn numbers because they are Silicon numbers.

David.

Hello David,
I checked the match between GPIOn and Dm from your pins_arduino.h simply using a pinMode(n) and a digitalWrite(n, HIGH) with a LED between Dm and GND.
It confirms that I have a nodeMCU ESP-12E. This is not the problem.
I also tested the SPI link with the following example NodeMCU SPI with Arduino IDE | NodeMCU (relying on Dn not GPIOs). It works.

Is it possible that the Adafruit TFT screen is not compatible with my ESP8266?

Please post a link to the actual board that you have bought.
Adafruit make several displays.

Adafruit normally have excellent schematics and pcb.
I would expect Adafruit designs to provide the correct level shifting i.e. to your 3.3V ESP8266

So I suspect that it is "your wiring" that is at fault.
Please post a photo of your real-life wires.

I can assure you that my Chinese "Red SPI ILI9341" displays work with 3.3V Seeeduino/Open-Smart Uno clones, Zero, Due, Nucleo, ESP8266, ESP32, Teensy3.2, Teensy4.0.

Note that I always use 3.3V GPIO boards.

David.

Sorry for this stupid question. You were right

Hello,

I put the full-fat constructor, including MISO (which is not used):

#define TFT_CS    D2     // TFT CS  pin is connected to NodeMCU pin D2 (I choose D2)
#define TFT_RST   D3     // TFT RST pin is connected to NodeMCU pin D3
#define TFT_DC    D4     // TFT DC  pin is connected to NodeMCU pin D4
// initialize ILI9341 TFT library with hardware SPI module
// SCK (CLK) ---> NodeMCU pin D5 (GPIO14)
// MOSI(DIN) ---> NodeMCU pin D7 (GPIO13)
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, D7, D5, TFT_RST, D6);

AND it works!
Almost, I still have a display problem in the loop

void loop(void) {
  for(uint8_t rotation=0; rotation<4; rotation++) {
    tft.setRotation(rotation);
    testText();
    delay(1000);
  }
}

with

unsigned long testText() {
  tft.fillScreen(ILI9341_BLACK);
  unsigned long start = micros();
  tft.setCursor(0, 0);
  tft.setTextColor(ILI9341_WHITE);  tft.setTextSize(1);
  tft.println("Hello World!");
  tft.setTextColor(ILI9341_YELLOW); tft.setTextSize(2);
  tft.println(1234.56);
  tft.setTextColor(ILI9341_RED);    tft.setTextSize(3);
  tft.println(0xDEADBEEF, HEX);
  tft.println();
  tft.setTextColor(ILI9341_GREEN);
  tft.setTextSize(5);
  tft.println("Groop");
  tft.setTextSize(2);
  tft.println("I implore thee,");
  tft.setTextSize(1);
  tft.println("my foonting turlingdromes.");
  tft.println("And hooptiously drangle me");
  tft.println("with crinkly bindlewurdles,");
  tft.println("Or I will rend thee");
  tft.println("in the gobberwarts");
  tft.println("with my blurglecruncheon,");
  tft.println("see if I don't!");
  return micros() - start;
}

the screen displays the text and then becomes all white.

I meant the question about the Adafruit product is. My ESP is not a cheap one, I bought it there Module NodeMCU ESP8266 - WiFi | GO TRONIC

I put the full-fat constructor, including MISO (which is not used):

...

Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, D7, D5, TFT_RST, D6);
...




AND it works!
Almost, I still have a display problem in the loop

So the display is working with your wiring. now !!!

The crash is to be expected on an ESP8266. You must call yield() frequently. The Adafruit examples do not call yield()

If you use the hardware constructor() you will possibly avoid some crashes.
But the sensible solution is strategic use of yield(), delay(), Serial.print() which effectively provide a yield()

I still suggest that you post a link to the actual Adafruit display that you have bought.

I recommend that you use Bodmer's TFT_eSPI library. It is designed for ESP8266, ESP32, STM32.
It implements most GFX methods natively but does not inherit from Adafruit_GFX.
It has plenty of examples. And lots of ESP users.

David.

Hello David,
The link to my TFT display: Ecran LCD TFT 3,2" tactile avec microSD - ILI934141 - Boutique Semageek (in French).
I will test the TFT_eSPI library tomorrow
Thank you for your help!