I wanted a simple LCD screen to use in some upcomming projects I have planned for the Pi. The nokia 5110 is a cheap, monochorme LCD that can fit in many cases with minor modifications, and can display more information than a 16x2 LCD screen.
There are many wiring diagrams out there, but there are a few things that are important to note
- The Nokia 5110 LCD uses 3.3V (and not 5V)
- The first 26 pins on the Raspberry Pi 1 and Raspberry Pi 2 header layouts are the same (Raspberry Pi 2 header has additional 14 pins which makes up a total of 40 pin header)
- The backlight on the Nokia 5110 LCD (labeled LED/LIGHT) needs a connection to GROUND or VCC(3.3V) depending on where you purchased the LCD. You can also connect this to a GPIO to enable you to turn the backlight on/off from your code. You'll need a series resistor of around 300 ohms (maybe less if your board already includes these as many do.
The last one is especially important, as many diagrams out there show to tie VCC (3.3V) to the LED pin, which may work for some LCDs but others require a Ground connection. You can either leave it open (for no backlight, which I did) or tie it to GROUND (or 3.3V depending on your model) or to a GPIO with a series resistor of around 300 ohms. I discuss this in further detail in an article Nokia 5110 LCD Backlight To Ground Using GPIO if you want to learn more about figuring out what resistor value is needed, and adding control for it in your python code.
Unless you are well experienced at soldering, I would recommend to use either a full female header connector or wires with female pins already attached that can easily slip over the header pins. These are available at a very low cost on eBay (search for female jumper wires).
- Raspberry Pi Pins to Nokia 5110 LCD
*See the article Nokia 5110 LCD Backlight To Ground Using GPIO if want to wire in the backlight to a GPIO.
We'll be using python to interact with our Nokia 5110 LCD. There are a few things we need to install prior to being able to interact with the LCD.
Install some prerequisites
sudo apt-get update
sudo apt-get install python-pip python-dev build-essential python-imaging git
Install RPi.GPIO to allow python programs to interact with the GPIOs
sudo pip install RPi.GPIO
Enable Hardware SPI on Raspberry Pi
SPI is the protocol we use to communicate with the LCD. On the Raspbian image, hardware SPI is disabled by default. Some distributions you may need to edit the blacklist.conf file and comment out spi-bcm2708, but with latest Raspbian image (jessie), we need to edit /boot/config.txt (this can also be done using the raspi-config interface)
sudo nano /boot/config.txt
Scroll down and uncomment (remove the #) dtparam=spi=on .
y to save and exit
You will need to reboot
after reboot, you can confirm the spi module is loaded with
lsmod | grep "spi_bcm*"
Install the Nokia 5110 LCD Library
There are a few different python libraries written for the Nokia 5110 LCD. I decided to use adafruit's library as it seems to be popular.
Clone and setup the library's git
git clone https://github.com/adafruit/Adafruit_Nokia_LCD.git
sudo python setup.py install
Testing the Nokia 5110 LCD
Goto to the Adafruit/examples directory
If you wired the LCD to the Raspberry Pi as shown above, the wiring setup in the python examples will be the same, if not, you will have to edit the example files to match your particular situation. You may need to adjust the contrast (default it is set to 60, one of my display's worked better at a value of 40 and another at 55) The lower the value, the less black the entire screen is. So if you don't see anything, try to turn up the contrast. The value is set by variable disp.begin(contrast=40)
Run the example program from inside the examples directory
sudo python shapes.py
Raspberry Pi Image: 2015-11-21-raspbian-jessie.img
cat /etc/*-release: Raspbian GNU/Linux 8 (jessie)
Python: Python 2.7.9