Using a 2.2″ 176×200 ILI995 SPI LCD screen with Raspberry Pi

I want to use a very small LCD for a specific project and though the 2.2″ SPI LCD would be a good start. Ultimately I would like to have a touch screen, but couldn’t find one locally at the time.

So I purchased the following 2.2″ TFT LCD Screen for my Raspberry Pi 3 Model B. This LCD has a 176×200 resolution and connects to the Raspberry Pi, and Arduino’s via the SPI bus.  Serial Peripheral Interface (SPI) is used to communicate with various devices like LCD screens, SD Card readers, and some sensors over a serial bus.

 This tutorial will show you how to connect the  2.2″ SPI LCD to a Raspberry Pi 3 Model B. It should work on other Raspberry Pi models as well, though you might have to change the wiring layout a bit.

Right, let’s get started.

As you can see from the photo above, the LCD screen has a SD Card slot which can also be used, but you would need to solder some header pins to the PCB first.  For this tutorial I’m only going to connect to the LCD and send some data to it.

 

The header PINS are as follows:

VCC >> Connect to the Raspberry 3.3V (pin 1)
GND >> Connect to the Raspberry Ground (pin 9)
GND >> Leave Open
NC >> Leave Open
NC >> Leave Open
LED >> Connect to the Raspberry 3.3V (pin 6)
CLK >> Connect to the Raspberry SPI0 CLOCK (pin 23)
SDI >> Connect to the Raspberry SPI0 MOSI (pin 19)
RS >> Connect to the Raspberry GPIO 24 (pin 18)
RST >> Connect to the Raspberry GPIO 25 (pin 22)
CS >> Connect to the Raspberry SPI0 CSO / CE0 (pin 24)

I used the following reference image for the Raspberry Pi 3 Model B’s GPIO pins:

Original source

Once connected, download and install the libraries as per this github project

I’m going to give you slightly modified instructions, which will work with the wiring layout given above.

If you use the latest version of Rasbian Stretch ( I used the 2018-04-18 version), most of the libraries will be installed already.

I use Python 3 as a standard, but the github page has instructions for Python 2 as well.

First, let’s install the necessary Python libraries, if needed:

sudo apt-get update
sudo apt-get install build-essential python3-dev python3-smbus python3-pip python3-imaging python3-numpy

Then install the RPi GPIO library:

sudo pip3 install RPi.GPIO

Once you have installed the Python libraries above, download the Python library from github  and save it to your Raspberry Pi. I saved it to my /home/pi folder for easy or access.

Now run the following command:

sudo python setup.py install

Once installed you can start playing with the example code.  Open the example.py script and change the following values, to match our wiring diagram:

# Raspberry Pi configuration.
RS = 24
RST = 25
SPI_PORT = 0
SPI_DEVICE = 0

Now save the file and execute it by running:

python image.py

Leave a Reply