While I was looking for a TFT display for a project with Arduino, I found on several webstores some displays based on the ST7735 chip by Sitronix (datasheet).
Based on its datasheet, the ST7735 chip has a SPI (Serial Peripheral Interface) interface, but the pin names on the silk screen of my display “seem” to suggest an I2C interface (SDA, SCL…):
It’s only a misleading naming; the real meaning of the pins is as follows:
- SDA -> MOSI (Master Out Slave In signal of the SPI bus)
- SCL -> SCK (clock signal of the SPI bus)
- CS -> SS (Slave Select signal)
- RST -> reset
- DC -> Data/Command (pin used to distinguish between sending data or commands to the display)
- BLK -> Backlight (if high, enables the backlight)
Once you know the meaning of the different pins, connecting the display to Arduino is simple.
First identify – based on your Arduino board – which pins correspond to the different signals of the SPI bus. For the others, you can freely choose between the remaining pins.
For example, with Arduino Uno I made the following connections:
(as you see, I connected the BLK pin directly to Vcc to have the backlight always on. You can also connect it to an Arduino digital pin to be able to control the backlight via software, for example if you need to save power).
To drive the display, you need a specific library. My preference goes to those developed by Adafruit, in particular:
- Adafruit-GFX-Library to display graphical elements (text, shapes, images)
- Adafruit-ST7735-Library to drive the specific chip of our display
The two libraries – which can be installed via the Arduino IDE Library Manager – work together to allow you to make the most of the display.
Adafruit wrote a fantastic tutorial to explain how to use them, here I only want to show you how to setup the display for the connections I made earler:
#define TFT_CS 10 #define TFT_RST 2 #define TFT_DC 3 Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST); |
Here’s the “graphictest” example, shipped with the library, running on my setup: