ESP32 & ST7789 TFT Display – 240x240px – 1.3 Inch

How to interface a 1.3inch TFT display with ST7789 driver and 240×240 pixels with an ESP32. If you want to use this display with an Arduino then click here.

All info offered in good faith, all credit to the original authors of the external links, I have no affiliation to the ebay links and make no commission.

Blah blah blah, whatever small text is required to exonerate myself from persecution as a result of other’s stupidity.

You will need:

ESP32 DEV board – ebay link

240×240 TFT display – ebay link

Hook up wires, USB cable, computer with Arduino IDE or other code editor, the usual bollocks… etc

See code for hook up guide – NOTE THAT THIS IS SPI INTERFACE (despite markings)

Test image on display – You might recognise it…

Prior Prep Work:

Install drivers as per these youtube instructions – note specifics on screen pixel size and driver. If you struggle when testing then check driver definition in the .h file with a fine tooth comb. (Ask me how I know…)

Prepare your image to the correct size (240×240) and correct format (.png, .jpg or .gif) – animated gifs not supported.

Import it to this converter

Change file type from .c to .h and save the resulting code the same folder as the main sketch.

Code:

/* 
 *  ESP32 test for 240x240 TFT colour screen with ST7789 driver
 *  
 *  Connections:
 *  
 *   ESP32       SCREEN
 *  ======================
 *    18  ------  SCL    
 *    23  ------  SDA
 *     4  ------  RES
 *     2  ------  DC
 *    NC          BLK   < Pull to ground to turn display off
 *  
 */

#include <TFT_eSPI.h>
#include <SPI.h>

#include "testPNG.h"    //image file - note " ", not < >

TFT_eSPI tft = TFT_eSPI();


//***************************************
void setup() {

tft.init();
tft.fillScreen(TFT_BLACK);  //clear screen
tft.setSwapBytes(true);     //required for displaying images

tft.pushImage(0,0,240,240,testPNG);   //x,y,width,height,imageFile

}
//***************************************
void loop() {

}
//*****************************************

Last updated 18/09/2022