Go Down

Topic: Graphics library for NodeMCU (ESP8266), ESP32 and serial+parallel TFT displays (Read 70426 times) previous topic - next topic


Most of those displays with 34 pins have multiple connections.
Most of them can be connected through spi as well as parallel so it should work. But ymmv.
(According to Google that is, my similar display was killed during transport, cannot confirm personally)

Are you sure about the ILI9486 driver?


Hi all -

I'm trying to get my ST7735R display to work with my NodeMCU ESP8266 development board.
  Display: https://www.adafruit.com/product/2088
  NodeMCU: https://www.amazon.com/HiLetgo-Version-NodeMCU-Internet-Development/dp/B010O1G1ES
I've looked at scores of sites and tried multiple approaches - nothing has worked. The support I've seen on this thread seems promising, so I'm hoping someone can help a noob out here.

What I've done:
1. Firmware -  https://nodemcu-build.com/
   I have updated it from master branch, using modules: bit, file, gpio, net, node, spi, tmr, uart, ucg, wifi
   Following th update, I can communicates with the chip from ESPlorer
   Once I upload code from Arduino editor, ESPlorer no longer communicates (see below)

2. Ardurino editor - ...you probably know the site since it hosts this forum! :)
   In preferences, I have identified http://arduino.esp8266.com/stable/package_esp8266com_index.json as the source of additional boards. From this, I am able to select "NodeMCU 1.0 (ESP-12E Module)" as the board
      Details: CPU Frequency: 80 Mhz, Flash Size: 4M (3M SPIFFS), Upload Speed: 115200, Port: COM 5
      Board Info: BN: Unknown board, VID: 10C4, PID: EA60, SN: Upload any sketch to obtain it
      Programmer: AVRISP mkll

   My .ino Code:
   #include <TFT_eSPI.h> // Hardware-specific library
   #include <SPI.h>

   TFT_eSPI tft = TFT_eSPI();  // Invoke library, pins defined in User_Setup.h

   void setup(void) {

   void loop() {

3. TFT_eSPI library
  User_Setup.h //(I am only showing active code)
   #define ST7735_DRIVER
   #define TFT_WIDTH  128
   #define TFT_HEIGHT 128
   #define ST7735_GREENTAB128 // For 128 x 128 display
   #define TFT_CS  PIN_D8 // NOTE: I have also tried: 15
   #define TFT_DC  PIN_D3 // NOTE: I have also tried: 0, PIN_D2, 4, PIN_D4, 2, and 1 // Data Command control pin
   #define TFT_RST  -1  // Set TFT_RST to -1 if the display RESET is connected to NodeMCU RST or 3.3V
   #define TFT_MOSI PIN_D7 //  NOTE: I have also tried: 13, and leaving undefined
   #define TFT_SCLK PIN_D5 //  NOTE: I have also tried: 14, and leaving undefined
   #define LOAD_GLCD   // Font 1. Original Adafruit 8 pixel font needs ~1820 bytes in FLASH
   #define LOAD_FONT2  // Font 2. Small 16 pixel high font, needs ~3534 bytes in FLASH, 96 characters
   #define LOAD_FONT4  // Font 4. Medium 26 pixel high font, needs ~5848 bytes in FLASH, 96 characters
   #define LOAD_FONT6  // Font 6. Large 48 pixel font, needs ~2666 bytes in FLASH, only characters 1234567890:-.apm
   #define LOAD_FONT7  // Font 7. 7 segment 48 pixel font, needs ~2438 bytes in FLASH, only characters 1234567890:.
   #define LOAD_FONT8  // Font 8. Large 75 pixel font needs ~3256 bytes in FLASH, only characters 1234567890:-.
   #define LOAD_GFXFF  // FreeFonts. Include access to the 48 Adafruit_GFX free fonts FF1 to FF48 and custom fonts
   #define SPI_FREQUENCY  27000000 // Actually sets it to 26.67MHz = 80/3
  LINE 7:
     #define TFT_HEIGHT 128 // NOTE: I have also tried the default: 160
4. Physical Connections:
   Display      NodeMCU
   Vin         3.3V // (one by flash button in corner, same side as all other connections except RST)
               // NOTE: I have also tried leaving this disconnected and just using LITE
   3V3         Not connected // This is identified as an "output" in documentation... I have tried it - doesn't work
   Gnd         GND // Right next to 3.3V listed 2 lines above
   SCK         D5
   MISO      Not connected // Don't need to "read" screen
   MOSI      D7
   TFT_CS      D8
   RESET      RST // (other side of board, 3rd pin from RST button).
               // NOTE: I have also tried D4 (changing User_Setup.h to PIN_D4 and 2))
   D/C         D3 // NOTE: I have also tried D2, D4, and TX
   CARD_CS      Not connected
   LITE      3.3V // NOTE: I have also tried leaving this disconnected and just using Vin

Thanks in advance for your help. ...I really have put lots of work into this trying to avoid bothering you with this, but I'm stuck and would appreciate it if you could help a brother out.



Hi i have error :

Code: [Select]
C:\Program Files (x86)\Arduino\libraries\TFT_ILI9341_ESP-master/Fonts/glcdfont.c:6:22: fatal error: pgmspace.h: No such file or directory

This pgmspace.h is my trouble

After add pgmspace.h from

Code: [Select]

Code: [Select]

i have alot errors.Please help.


identify lcd :

3.5 inch RPi LCD V3.0 HVGA 480X320. There is a XPT2046, 74HC04D, 74HC4040D, and 2 74HC4094D chips on the back

WaveShare SpotPear 3.5" ili9341


Photo add in attachment

From GIT hub i must add this library to my arduino 1.8.2 software:


Code: [Select]


Code: [Select]


Code: [Select]

Arduino software do alot errors.Cant upload to arduino nano :/


Thank you for all answers.



So many questions... so many problems!

The latest library is the TFT_eSPI.

It is not clear whether you are using an ESP8266 and ESP32 Board. Make sure the board support packages for the boards used are loaded and seen by the IDE.  Try and compile and uploadsome simple examples first for the ESP8266 or EP32 (blink etc). Once that is working error free then move on to use the TFT library.

#include <pgmspace.h>

Should be accepted by the compiler.

If the correct board is selected, eg. Nano etc, then the IDE examples should compile without error.

If you select the ESP32 or ESP8266 boards in the IDE then the TFT_eSPI examples should compile OK. Once this has been achieved with no error configure the library for your TFT by editing the User_Setup.h file inside the library folder.



I see no obvious mistake. Try a different driver by using:

#define ST7735_BLACKTAB

instead of:

#define ST7735_GREENTAB128

If that does not work then try each of the other drivers.

If that does not work use an Adafruit website tutorial and library to make sure the display is working OK.


The XPT2046 touch screen controller is supported. The SPI bus for the touch controller is shared with the TFT and only an additional chip select line is needed.

Example is included for 480x320 RPi display "Touch_Controller_Demo", the screen calibration data is stored in the SPIFFS.


Library update:

I have added the Button display and handling class from Adafruit_GFX. This is enhanced in that any font can be used for the button labels.

The touch screen functions built into the TFT_eSPI library (XPT2046 supported) have also been updated to improve touch detection reliability.

A simple on/off switch example has been added that tests the touch screen, this does not use the Button class.

A keypad example a for 240x320 TFT has also been added which demonstrates use of the Button class:

The touch screen handler saves the screen x,y calibration data in a SPIFFS file, so at the moment the touch screen only works with the ESP8266. Although SPIFFS support has recently been added to the ESP32 board package I have not tried it yet.

Report any issues here or raise an issue for the TFT_eSPI library on Github.


The touch and button class work fine with the RPi "Waveshare" style 320x480 display. The connection image in the library tools folder has been updated to show the MISO pin (to read the XPT2046 touch controller) and the chip select line connections.

Note: the library expects the touch controller and the TFT to share the same SPI lines. Different chip select lines are used and defined in the User_Setup.h file.


More updates:

1. A new sketch has been added purely for touch screen calibration and test. This one does not need SPIFFS, the calibration code is posted to the Serial Monitor for easy cutting and pasting into a sketch.

2. The touch screen detection handling functions in the library have been updated to improve the touch detection reliability and positional accuracy.


The most exciting update for a while.. ?

If you hate the screen flicker when updating graphics on the screen then the latest edition of TFT_eSPI may be of interest.

I have added a "Sprite" class, this allows images to be created using graphics functions (drawLine() etc etc) from the sketch, the sprite (aka bitmap image) can then be pushed to anywhere on the screen very quickly.

The good news is very smooth flicker free screen updates are possible, the bad news is that large sprites consume a lot of RAM, this means that for the ESP8266 you are limited to a sprite of about 160x128 pixels which consumes 40Kbytes of RAM. I may make 8 bit pixels an option next to halve the RAM need.

Drawing graphics into a RAM based sprite (effectively a mini RAM screen) is very fast, the complete Adafruit graphicstest runs in less than 27 milliseconds in a 160x128 sprite.

Here is a quick demo where a 240x30 pixel sprite is generated, graphics drawn into it + text, and then pushed onto the TFT. By moving the text 1 pixel at a time for each push to screen the text scrolls across smoothly.

In the demo large "Adafruit GFX" style font digits are  also drawn into a sprite with some background graphics, then pushed to screen. This eliminates flicker and allows complex graphics backgrounds (shading etc) behind changing numbers.

Sprites can be created. pasted to screen then deleted to recover RAM. This means sprites can be created at will with different sizes to update particular areas of the screen.

At the moment I have created 4 examples to show how to use sprites.

Report any bugs here or on Github.


I have added support for sprites with 8 bit colour depth (3 bits red, 3 bits green, 2 bits blue), this halves the RAM required compared to a 16 bit colour sprite but reduces the colours available for graphics operations within the sprite.

Here are screen shots using 16 bit colours (65536 different colours):

8 bit colours in comparison have only 256 as follows:

A new example has been added to demonstrate.

By default sprites are 16 bits. The colour depth can be specified before creating a sprite byt the function:

Code: [Select]


Where the depth can be 8 or 16 bits. The sprite must be deleted and created again if the colour depth is to be changed after creation.


I face a strange problem.
Two months ago I compiled the examples in 480x320 pixels for ESP 32 and it worked perfectly but now when I complicate again I get the following errors:

C:\Users\Lienard Vivien\Documents\Arduino\libraries\TFT_eSPI-master\TFT_eSPI.cpp:1334:83: error: array subscript has type 'char' [-Werror=char-subscripts]
         GFXglyph *glyph  = &(((GFXglyph *)pgm_read_dword(&gfxFont->glyph))[uniCode]);

C:\Users\Lienard Vivien\Documents\Arduino\libraries\TFT_eSPI-master\TFT_eSPI.cpp:4421:20: error: 'yo16' may be used uninitialized in this function [-Werror=maybe-uninitialized]
     int16_t  xo16, yo16;
C:\Users\Lienard Vivien\Documents\Arduino\libraries\TFT_eSPI-master\TFT_eSPI.cpp:4421:14: error: 'xo16' may be used uninitialized in this function [-Werror=maybe-uninitialized]
     int16_t  xo16, yo16;
C:\Users\Lienard Vivien\Documents\Arduino\libraries\TFT_eSPI-master\TFT_eSPI.cpp:1512:20: error: 'yo16' may be used uninitialized in this function [-Werror=maybe-uninitialized]
     int16_t  xo16, yo16;
C:\Users\Lienard Vivien\Documents\Arduino\libraries\TFT_eSPI-master\TFT_eSPI.cpp:1512:14: error: 'xo16' may be used uninitialized in this function [-Werror=maybe-uninitialized]
     int16_t  xo16, yo16;

I can not understand why, Help would be welcome
Thanks in advance.



The ERC32 compile process imposes stricter rules on the source code, so maybe the compiler options have been updated?

I have fixed this in the library on Github, so download and use the latest TFT_eSPI and the warning should go away.

I see this has also been corrected in the Adafruit_GFX library where this snippet of code came from, so all should be good now.

Thanks for reporting this.


A few updates have been made to the library:

1. Sprites can now be scrolled, there is a new demo example showing a smoothly scrolling graph and text
2. fillSprite() & sprite fillRect() performance improvement using memcpy() function

The "fill" performance boost means the entire Adafruit graphicstest runs within a 160x128 sprite in 15ms for 8 bit colours, or 18ms for 16 bit colours (was 28ms).  This indicates how fast graphics rendering can be inside a sprite.

Please report any issues on Github, or as a post on this forum.

Go Up