Interfacing ESP8266 NodeMCU with ST7789 TFT Display

This tutorial shows how to interface ESP8266 NodeMCU (ESP-12E) board with ST7789 TFT display.
The ST7789 TFT module contains a display controller with the same name: ST7789. It’s a color display that uses SPI interface protocol and requires 3, 4 or 5 control pins, it’s low cost and easy to use.
This display is an IPS display, it comes in different sizes (1.3″, 1.54″ …) but all of them should have the same resolution of 240×240 pixel, this means it has 57600 pixels. This module works with 3.3V only and it doesn’t support 5V.

TFT: Thin-Film Transistor.
SPI: Serial Peripheral Interface.
IPS: In-Plane Switching.

The following image shows a ST7789 display module provided by Adafruit Industries:

Adafruit ST7789 TFT display module
Adafruit ST7789 TFT display module

Another version of the ST7789 display module is shown below. This one has no CS (chip select) pin, its internally attached to GND:

ST7789 TFT display without CS pin
ST7789 TFT display without CS pin

Project Hardware Required:

  • NodeMCU board
  • ST7789 TFT display module (1.3″, 1.54″ …)
  • Micro USB cable (for programming and powering the whole circuit)
  • Breadboard
  • Jumper wires

NodeMCU WiFi board with ST7789 TFT display

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

The ST7789 display module shown in project circuit diagram has 7 pins: (from right to left): GND (ground), VCC, SCL (serial clock), SDA (serial data), RES (reset), DC (or D/C: data/command) and BLK (back light).
Connecting the BLK pin is optional. The back light turns off when the BLK pin connected to the ground (GND).

ESP8266 NodeMCU ST7789 SPI TFT circuit

The ST7789 TFT display module is connected to the NodeMCU board as follows:
GND is connected to pin GND of the NodeMCU board,
VCC and BL are connected to pin 3V3,
SCL pin is connected to D5 (ESP8266EX GPIO14),
SDA pin is connected to D7 (ESP8266EX GPIO13),
RES pin is connected to D2 (ESP8266EX GPIO4),
DC pin is connected to D1 (ESP8266EX GPIO5).

If the display module has a CS pin (Chip Select) then it should be connected to NodeMCU pin D8 (GPIO15).

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).

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

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

Both libraries can be installed manually, first download them from the following 2 links:
Adafruit ST7789 TFT library    —->  direct link
Adafruit graphics library        —->  direct link

After the download, go to Arduino IDE —> Sketch —> Include Library —> Add .ZIP Library … and browse for the .zip file (previously downloaded).
The same thing for the other library file.

Hints:
The 2 library files are included in the main code as shown below.

The ST7789 TFT module pins (CS, RST and DC) connections are defined as shown below:

The other display pins (SDA and SCL) are connected to NodeMCU hardware SPI pins (respectively D7 and D5).

The Adafruit ST7789 library is initialized with this line:

And the TFT display is initialized using the following command:

The display may not work if it has a CS pin, try with SPI_MODE0 which is the default mode of the library or just use: tft.init(240, 240);

Rest of code is described through comments.

Full Arduino code:

The video below shows my simple hardware circuit test:

2 comments

  1. thanks for your post, it’s helps me a lot to make my ESP8266 work . all is working fine 🙂

    have you an example to show a picture or a libraty that i can use to show a sprite or a .jpg for example

  2. In my project, I’m using a nodemcu with MPU6050 using the I2C interface which uses the D1 and D2 pins respectively
    .I want to use a LCD display such that it will have a small size which can be used on a device which is to be wore on the wrist. And to use less number of wires I was thinking of SPI interfacing for it .

    I just want to display the time constantly and reminders for some tasks at the set intervals.

    Which display would you like to suggest me for this application?

    And if i’m using the D1 and D2 pins with MPU sensor, which pins can I use for the SPI interfacing of the LCD where you have used D1 and D2 in the above code.
    Please suggest.
    Thank you!

Leave a Reply

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