I was looking for small TFT screen for my ESP8266, I’ve stopped on a ST7735S. Unfortunately, I haven’t found enough information about wiring it to ESP8266 and programming ESP8266 to control this screen. That’s why in this post I’d like to show how to connect it to ESP8266 and make it work. 

Components

  • ESP8266 (I am using Lolin v3)
  • ST7735S TFT screen 
  • Micro USB cable

Wiring 


TFT screen wiring

TFT screen   ESP8266
CS      ->       GPIO5
RESET   ->   GPIO16
A0       ->     GPIO2
SDA     ->    GPIO4
SCK      ->    GPIO0

SD wiring (if you are going to use SD card)

TFT screen        ESP8266
SD_CS        ->    GPIO15
SD_MOSI   ->   GPIO13
SD_MISO   ->   GPIO12
SD_SCK     ->    GPIO14

In case you have a bit different names for the pins on your screen’s PCB, I would like to mention that A0 is totally the same as DC and SDA is the same like MOSI!

And don’t forget to connect GND to G and VCC to 3V!

Programming 

Now is the most interesting part. Instead of writing code by myself, I decided to show it to you on Adafruit’s code example called “Graphics test”.

For start open your Arduino IDE (if you don’t have it, you can download it here).

Downloading libraries

First of all we will need to install those two libraries: Adafruit ST7735 Library and Adafruit GFX Library. To do that go to Sketch -> Include library -> Manage Libraries. And type one by one those names.

Uploading code example

How you could guess, if it would be so easy, I wouldn’t write that. So, that’s why we would need to open File -> Examples -> Adafruit ST7735 Library -> graphicstest, and now we would need to change some data on the top. We need exactly this part (I won’t write all the code):

#define TFT_CS     10
#define TFT_RST    9  // you can also connect this to the Arduino reset
                      // in which case, set this #define pin to 0!
#define TFT_DC     8

// Option 1 (recommended): must use the hardware SPI pins
// (for UNO thats sclk = 13 and sid = 11) and pin 10 must be
// an output. This is much faster - also required if you want
// to use the microSD card (see the image drawing example)
Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS,  TFT_DC, TFT_RST);

// Option 2: use any pins but a little slower!
#define TFT_SCLK 13   // set these to be whatever pins you like!
#define TFT_MOSI 11   // set these to be whatever pins you like!
//Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_MOSI, TFT_SCLK, TFT_RST);

As you can see, the pinouts are defined in here. First we will need to change TFT_CS to 5, TFT_RS to 16, TFT_DC to 2, TFT_SCLK to 0 and TFT_MOSI to 4. After that we will need to comment this line of code Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST); and uncomment this line Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_MOSI, TFT_SCLK, TFT_RST); . Now I will explain why so. If you know a bit of microcontrollers, you would know that for SPI connection you can use or hardware pinout, or your own, by defining it in your code. In this case I decided to use custom pinouts, because I would like to connect SD card to the hardware one (because it is faster). So in the end you will get code like this:

#define TFT_CS     5
#define TFT_RST    16// you can also connect this to the Arduino reset
                      // in which case, set this #define pin to 0!
#define TFT_DC     2

// Option 1 (recommended): must use the hardware SPI pins
// (for UNO thats sclk = 13 and sid = 11) and pin 10 must be
// an output. This is much faster - also required if you want
// to use the microSD card (see the image drawing example)
//Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS,  TFT_DC, TFT_RST);

// Option 2: use any pins but a little slower!
#define TFT_SCLK 0 // set these to be whatever pins you like!
#define TFT_MOSI 4 // set these to be whatever pins you like!
Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_MOSI, TFT_SCLK, TFT_RST);

Then upload your code on ESP8266 and enjoy! You will see some text examples, animation and etc. So, it will look like on this video!

Did you enjoy this article?
Signup today and receive free updates straight in your inbox. We will never share or sell your email address.
I agree to have my personal information transfered to MailChimp ( more information )