Interface Nokia 5110 LCD and Raspberry Pi using Python

Today we are going to see how to interface Nokia 5110 LCD and Raspberry Pi using Python. The display is controlled using SPI (Serial Peripheral Interface) protocol and uses PCD8544 as its controller.

Nobody can forget the most sturdiest robust and reliable phone of the 90’s. Yes, I am talking about Nokia Phones :). Somehow it has got its place in history and heart of people. So, I too have one as a vintage collection. Recently I got an idea, for which I wanted an LCD display. After searching around I got a LCD display what was used in Nokia phones. LCD is called  Liquid crystal display and the difference between LCD and OLED has been explained a bit in my previous article.

Hardware required:

Raspberry Pi

Amazon US:
Amazon Germany :

Nokia LCD

Banggood: Nokia LCD
Amazon US:
Amazon Germany:

Female to Female Jumper Cable Wires 20cm

Amazon US:
Amazon Germany:

Nokia LCD Display:

The display uses PCF8544 controller which uses an SPI interface for operating it .

Pin Connections
1. RST       ———        reset.
2. CE         ————    chip selection.
3. DC         ———–     data/commands choice.
4. DIN       ———–     serial data line.
5. CLK       ————   serial Clock Speed.
6. VCC       ———-      Power, 3.3V (Positive).
7. BL           ———       backlight control terminal.
8. GND      ———–    power negatively.


Nokia 5110 LCD and Raspberry Pi:


The LCD should be connected as shown in the picture below.

The display is connected to the SPI pins of the Raspberry Pi . If you want to know more about the Raspberry Pi pinout refer to . The pin placement order is shown the same way the board is placed in the picture below.

Pin Mapping

The VCC is connected to 3.3V supply because the LCD and driver require a 3.3V power supply and 3.3V logic levels for communication.

1. RST——— reset.
2. CE————chip selection.
3. DC———–data/commands choice.
4. DIN———–serial data line.
5. CLK————serial Clock Speed.
6. VCC———-Power, 3.3V (Positive).
7. LIGHT——— backlight control terminal.
8. GND———–power negatively.

Hardware connection:

After setting up the connection the circuit looks like shown below.

SPI Device Driver:

Before you start with the programming part, you need to enable the SPI driver in your raspbian distribution. It can be done using raspi-config. You can do it as follows.

sudo raspi-config

Ensure that you see the SPI device nodes as shown below.

$ ls -l /dev/spi*
crw-rw---- 1 root spi 153, 0 Nov 25 08:32 /dev/spidev0.0
crw-rw---- 1 root spi 153, 1 Nov 25 08:32 /dev/spidev0.1

Nokia LCD python Library 

With the emergence of Pi board and the Linux distributions along with it, there are always more than one library available for each interface. Likewise for LCD display there are many libraries and many variants of libraries . For the LCD with PCD8544 , I chose this library .

This library is already available as part of python repository or as they called cheese cake factory ;).  Type the below command to install all the required dependencies for using the LCD display.

$sudo apt-get install python-dev python-pip libfreetype6-dev libjpeg-dev build-essential
$sudo -H pip install --upgrade luma.lcd

Now during the installation if you get any error like shown below

NameError: name 'platform_system' is not defined

Then type the below command and then try again to install the above packages.

sudo pip install -U pip

For the latest information about the installation always refer to

Example Code

Turning backlight on


Nokia LCD Display


from luma.core.interface.serial import SPI

Since the hardware uses SPI, I am importing the SPI handler related module from luma.core.interface.serial

from luma.core.render import canvas

Assume the canvas like a buffer which will be used to transfer the content to display controller.

from luma.lcd.device import pcd8544, st7735, uc1701x

Here I import the display hardware related module which can speak with PCD8544 controller.

from luma.lcd.aux import backlight

Importing backlight functionality from LCD auxilary library.

serial = spi(port=0, device=0, gpio_DC=23, gpio_RST=24)

We specifiy which SPI  bus and the Device number to the display controller object and get a device handler as return. port represents the /dev/spidev0.0, in case if the device is /dev/spidev2.0 then port will be 2. device represents which device for example spidev0.0 0 is the device number and spidev0.1 has 1 as device number. Additionally the Data command pin and reset pins needs to be configured seperately using the variables   gpio_DC and  gpio_RST.

light = backlight(gpio_LIGHT=channel, active_low=False)

Here the GPIO pin that is connected to the back light is defined and it is passed to the backlight auxilary function along with the logic level of the pin as active high.



device = pcd8544(serial,rotate=2)

This creates the device object of PCD8544 controller, the option rotate is to turn the orientation and it has 4 numbers 0,1,2 and 3.
with canvas(device) as draw:

Open a canvas for this device with the name draw.
draw.rectangle(device.bounding_box, outline=”white”, fill=”black”)

Draw a rectangle with device.bounding_box which outlines the border.
draw.text((10, 10), “Hello World”, fill=”red”)

Print the text Hello World and the fill has no meaning here except in generate it can be either 0 or 255.



If you want to plot a pixel then use the point method with X and Y co ordinate to plot.



draw.line((0,0 , 20 , 20 ), fill=white

Here I use the method line with start co-ordinates (X1,Y1) and end co-ordinates (X2, Y2)

Font example:



font = ImageFont.truetype(./ssd1306/fonts/Volter__28Goldfish_29.ttf,20)

Here I am loading the font to a variable called “font” using the ImageFont.truetype method. Here I am using the font Volter__28Goldfish_29.ttf , but you can use any ttf font with the complete path. The number 20 is the font size you can play around reducing and increasing to see its effect on the screen,

draw.text((00), Hello Worldfont=font, fill=255)

The font object is used as the font to display the text “Hello World”.

Install example codes:

$git clone
$cd luma.examples/examples

You can run most of the example using the following option.

python examples/ -f conf/pcd8544.conf
python examples// -f conf/pcd8544.conf
python examples/ -f conf/pcd8544.conf

Leave a Reply

Your email address will not be published. Required fields are marked *