esp8266 + ili9341 tft + touchscreen Wiring

HI I’m trying to connect all the pins from an Esp8266 to a ili9341 tft + touchscreen. I followed this: 2.8″ Touch LCD SPI for esp8266 (nodemcu) – NailBuster Software Inc.

But it didn’t work.

“didn’t work” contains no information. Try again.

For…Sake. this link:2.8″ Touch LCD SPI for esp8266 (nodemcu) – NailBuster Software Inc. . has this image:

And this code:

#include <Arduino.h>
#include <SPI.h>

#include <Adafruit_ILI9341esp.h>
#include <Adafruit_GFX.h>
#include <XPT2046.h>

// Modify the following two lines to match your hardware
// Also, update calibration parameters below, as necessary

// For the esp shield, these are the default.
#define TFT_DC D4
#define TFT_CS D8

Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);
XPT2046 touch(/*cs=*/ D2, /*irq=*/ D1);

Adafruit_GFX_Button button;

void setup() {

  touch.begin(tft.width(), tft.height());  // Must be done before setting rotation
  Serial.print("tftx ="); Serial.print(tft.width()); Serial.print(" tfty ="); Serial.println(tft.height());
  // Replace these for your screen module
  touch.setCalibration(209, 1759, 1775, 273);
  button.initButton(&tft, 100, 100, 70, 40, ILI9341_DARKCYAN, ILI9341_BLUE, ILI9341_GREENYELLOW, "Clear", 2);

static uint16_t prev_x = 0xffff, prev_y = 0xffff;

void loop() {
	uint16_t x, y;
  if (touch.isTouching()) {
    touch.getPosition(x, y);
//	Serial.print("x ="); Serial.print(x); Serial.print(" y ="); Serial.println(y);
    if (prev_x == 0xffff) {
      tft.drawPixel(x, y,ILI9341_BLUE);
    } else {
      tft.drawLine(prev_x, prev_y, x, y,ILI9341_BLUE);
    prev_x = x;
    prev_y = y;
  } else {
    prev_x = prev_y = 0xffff;
  }, y)); // tell the button it is pressed

// now we can ask the buttons if their state has changed
	if (button.justReleased()) {
		button.drawButton(); // draw normal

	if (button.justPressed()) {
		button.drawButton(true); // draw invert!


after fixing the code to correspond to the pins on the diagram. The touchscreen is unresponsive the image does show up though. So i have no clue what’s up with this. Frankly I’m losing patience with the esp8266. is this worthwhile or do I move on to the esp32?

1 Like

Why do you assume the problem is with ESP8266? Do you know your LCD has a touchscreen and the required controller? There are many sold without touch. Just sayin.

Got a DMM or an oscilloscope? You can only do so much with just your eyeballs.