Nokia 5110 LCD with Raspberry Pi

Nokia 5110 LCD with Raspberry Pi

Nokia 5110 LCD (PCD8544)

Recently I bought a couple of Nokia 5110 LCD’s which are not only very cheap but also very good for starters to get used to working with graphic displays. These displays are available in two flavours: one with blue backlight and the other with white. See figures below.

Nokia 5110 LCD (Blue)
Nokia 5110 LCD (Blue Backlight)
Nokia 5110 LCD (White)
Nokia 5110 LCD (White Backlight)

So, I decided to program it to my best possible. I found a library by André Wussow. However, this library uses bit-banging technique to send the data to the LCD. After lot of experimentation with the timings, I achieved only a frame rate as low as 4 fps. This is unacceptable for me. So, I modified the library to support hardware SPI in addition to the fall-back bit-banging method. I added some new functions, improved most of the functions, added installation scripts, etc. as we will later see that with hardware SPI frame rates are achieved up to 345 fps at a 2MHz SPI communication rate.

Hardware

Materials required
  • Raspberry Pi I Model B
  • Nokia 5110 LCD Module
  • Breadboard
  • 5v regulated power supply
  • 8 wires

For the SPI configuration, I used the following pin connections as shown in the diagram below.

Pin Connections
Pin Connections for Nokia 5110 LCD with Raspberry Pi.

Note that I have used DC pin and RST pin to the GPIO pins only as obvious. After all the necessary connections, the whole setup looked like the following figure below.

Full Circuitry
Nokia 5110 LCD connected to Raspberry Pi.

Software

Although the hardware part was easy, the software part needed a considerable portion of labour as the bit-banging tweaking was really painful with almost no benefit.

Libraries required
  • WiringPi (the GPIO library)
  • LibPCD8544 (the LCD driver-cum-API)
  • Libbff (for handling bitframe files)
  • Libdither (for dithering images and videos)
  • OpenCV (>2.3.1) (for opening images and videos) (recommended)
Movie Playing

I took 2 samples of dithered bit-frame videos (one with 882 frames and the other with 3524 frames) which were converted using OpenCV library and dithered using libdither library.

Since, I used an SPI frequency of 2 MHz, a simple calculation reveals that theoretically the frame rate can go up to 496 fps. With libPCD8544 driver and API, I was able to play the videos at least at a frame rate of 345 fps.

 

3-D Wire-frame Rendering

Next I went one step further. I installed a 3-D mesh library meshlib and used it to open 3-D models and render their wire-frames using software and displaying rotating animations of them on the LCD module. See the figures below.

3D Box Display
A 3D box (wire-frame rendered) is displayed on the Nokia 5110 LCD.
3D Car Display
A 3D car (wire-frame rendered) is displayed on the Nokia 5110 LCD.


 

References

  1. LibPCD8544
  2. PCD8544 Library for Raspberry Pi
  3. 48×84 pixels matrix LCD controller/driver – SparkFun Electronics
  4. Raspberry Pi | WiringPi Pins
  5. WiringPi

1 thought on “Nokia 5110 LCD with Raspberry Pi

  1. low level format tool serial}

    Cheers, great stuff, I like.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Copyright © 2016-2020 Electronics and Software Blog All rights reserved.