Esp8266 (NodeMCU) With ST7789 1.3 Inches Module

Esp8266 (NodeMCU) With ST7789 1.3 Inches Module

In the last post, i connected ESP 8266 with ILI9341. However, the rendering speed is quite poor due to the screen being slow, so i had a look at the ST7789 since the rendering speed is faster than the ILI 9341.

The ST7789 also uses the SPI protocol to communicate with the ESP8266 so the wiring process i quite similar to the ILI 9341. However, the Pins naming convention is a bit different which is a bit confusing.

Wiring

We will use the TFT_eSPI library to control the display, so we must wire the jumper wires according to the PINs defined in the TFT_eSPI. In order to view the PIN defined in the library, we go to ~/Arduino/library/TFT_eSPI folder and open it with our favorite IDE.

The Pins should be defined in the file User_Setup.h as followed.

Since the ST7789 has BLK pin, we will uncomment the line 180 . As i mentioned earlier that the naming convention on ST7789 is a bit different than ILI 9341. Here's how we wire the PIN to the screen. For example, the MOSI is defined as PIN_D7. We will be wiring the D7 on the NodeMCU to the SDA on the screen.

SDI(MOSI) -> SDA
RST -> RES
SCLK -> SCL
BL -> BLK

2 PINS MISO and CS could be ignored.

One more thing, since the TFT_eSPI come with the default settings for ILI 9341, we didn't need to update anything in the library in the last post. However, since the screen is different we will have to update the code in the library a bit.

In the User_Setup.h we have to comment out the line

//#define ILI9341_DRIVER // Generic driver for common displays

and uncomment the line

#define ST7789_DRIVER // Full configuration option, define additional parameters below for this display

We will also have to uncomment the 2 following lines

define TFT_WIDTH 240 // ST7789 240 x 240 and 240 x 320

define TFT_HEIGHT 240 // ST7789 240 x 240

and comment out any other lines that define TFT_HEIGHT and TFT_WIDTH

The Code

The code to prints out the matrix is quite simple, i only updated the constructor for the TFT from taking 2 arguments to 0 instead.

#include <TFT_eSPI.h>
#include <DigitalRainAnimation.hpp>
#include "MatrixCodeNFI18.h"

TFT_eSPI tft = TFT_eSPI();
DigitalRainAnimation<TFT_eSPI> matrix_effect = DigitalRainAnimation<TFT_eSPI>();

void setup() {
  Serial.begin(115200);
  Serial.println("\n\n TFT_eSPI with Japanese Font");

  tft.begin();
  tft.setRotation(0);
  tft.loadFont(MatrixCodeNFI18);

  matrix_effect.init(&tft);
}

void loop() {
  matrix_effect.loop();
}

The result