Interfacing ESP8266 NodeMCU with ILI9341 TFT display

This tutorial shows how to interface ESP8266 NodeMCU (ESP-12E) board with ILI9341 TFT display.
The ILI9341 TFT module contains a display controller with the same name: ILI9341. It’s a color display that uses SPI interface protocol and requires 4 or 5 control pins, it’s low cost and easy to use.
The resolution of this TFT display is 240 x 320 which means it has 76800 pixels. This module works with 3.3V only and it doesn’t support 5V (not 5V tolerant).

TFT: Thin-Film Transistor.
SPI: Serial Peripheral Interface.

Project Hardware Required:

  • NodeMCU board
  • ILI9341 TFT display module (2.2″, 2.4″, 2.8″ …)
  • Micro USB cable (for programming and powering the whole circuit)
  • Breadboard
  • Jumper wires

ESP8266 NodeMCU with ILI9341 SPI color TFT

NodeMCU with ILI9341 TFT display circuit:
Project circuit schematic diagram is shown below.

The ILI9341 TFT display board which is shown in project circuit diagram has 14 pins, the first 9 pins are for the display and the other 5 pins are for the touch module.

So, the display part pins are numbered from 1 to 9 (from left to right): VCC (5V), GND (ground), CS (chip select), RST (reset), DC (or D/C: data/command), MOSI (or SDI), SCK (clock), BL (back light LED) and MISO (or SDO).
MOSI: master-out slave-in.
SDI: serial data in.
MISO: master-in slave-out.
SDO: serial data out.

ESP8266 NodeMCU ILI9341 TFT display

The ILI9341 TFT display is connected to the NodeMCU board as follows:
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 and BL are connected to pin 3V3,
GND is connected to pin GND of the NodeMCU board.

Pins D5 (GPIO14) and D7 (GPIO13) are hardware SPI module pins of the ESP8266EX microcontroller respectively for SCK (serial clock) and MOSI (master-out slave-in).

Interfacing NodeMCU with ILI9341 TFT display code:
The Arduino code below requires two libraries from Adafruit Industries:
The first library is a driver for the ILI9341 TFT display which can be installed from Arduino IDE library manager (Sketch —> Include Library —> Manage Libraries …, in the search box write “ili9341” and choose the one from Adafruit).

The second library is Adafruit graphics library which can be installed also from Arduino IDE library manager.

The previous two libraries can also be installed manually:
Download both libraries from the following two links:
Adafruit ILI9341 TFT library   —->  direct link
Adafruit graphics library        —->  direct link

Go to Arduino IDE —> Sketch —> Include Library —> Add .ZIP Library … and browse for the .zip file (previously downloaded).
The same thing for the second file.

Hints:
The previous 2 libraries are included in the main code as shown below:

The ILI9341 TFT display is connected to NodeMCU hardware SPI module pins (clock and data), the other pins which are: CS (chip select), RST (reset) and DC (data/command) are defined as shown below:

Full Arduino code:
The following Arduino code is from Adafruit ILI9341 library (graphicstest.ino) with some modifications in order to work with the above circuit diagram.

The following video shows my simple hardware circuit test:

One comment

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.