Recently I bought a cheap TFT display for a project I was doing (which I'll write up in the future). I finally decided upon the 1.8" 128x160 ST7735 Display from Karen's eShop on eBay. She actually asked me to write up how I got my display working on a Raspberry Pi. Her shop is UK based and has lots of great electronics modules for Arduinos and Raspberry Pis.
On the product page, the seller has got very detailed instructions on how to get it working on an Arduino which is great because many sellers don't include any information to get it working.
This useful site might be useful for identifying where pins are on your Raspberry Pi.
|VCC||Any 5v Power|
|BL||Don't connect but does seem to make the screen brighter if connected to 5v|
I found a library for the screens using the ST7735 chip on GitHub by cskau. It is a modified version of a library Adafruit uses for some of their screens. The instructions on the GitHub page are for Python 2 and the ones I've written here are for Python 3.
Firstly, start off by downloading some things required for the library to work:
sudo apt update sudo apt install build-essential python3-dev python3-smbus python3-pip python3-imaging python3-numpy git
Next you'll need to install the Raspberry Pi GPIO and Adafruit GPIO libraries for Python:
sudo python3 -m pip install RPi.GPIO sudo python3 -m pip install Adafruit_GPIO
Afterwards you can clone the repository and install the library:
git clone https://github.com/cskau/Python_ST7735 cd Python_ST7735 sudo python3 setup.py install
Then you can try out some of the examples in the
Python_ST7735/examples folder, but the screen I had was smaller than what was on the examples so there were multi-coloured pixels around the edge of the screen which I guess is noise?
Here's what code I had to write which sets the screen size correctly for the screen I bought:
from PIL import Image from PIL import ImageDraw from PIL import ImageFont import ST7735 as TFT import Adafruit_GPIO.SPI as SPI # Make the following 2 numbers bigger if you have multi-coloured pixels around the edge of the screen. WIDTH = 128 # I used 130 HEIGHT = 160 # I used 161 SPEED_HZ = 4000000 # The pins of where we wired the DC and RES pins. DC = 24 RST = 25 SPI_PORT = 0 SPI_DEVICE = 0 # Create a TFT screen object. disp = TFT.ST7735( DC, rst=RST, spi=SPI.SpiDev( SPI_PORT, SPI_DEVICE, max_speed_hz=SPEED_HZ), width=WIDTH, height=HEIGHT) # Start up the display. disp.begin() disp.clear() # Create a new PIL image to draw to. image = Image.new("RGB", (WIDTH, HEIGHT)) draw = ImageDraw.Draw(image) width, height = image.size # Add PIL drawing commands here # . . . disp.display(image)
For some reason the screen size in the code is bigger than the actual screen size which is in the eBay listing. I had to edit these quite a bit for the multi-coloured pixels to disappear so you might have to as well.