User Tools

Site Tools


arduino:displays_for_classic_arduinos:nokia_5110_displays_and_classic_arduinos

This is an old revision of the document!


Nokia 5110 Displays and the Arduino Uno

Summary opinions

There are a few reasons you might want to use a Nokia 5110 LCD display in an Arduino project and a couple that mean you probably shouldn't. First the good reasons:

  • They're cheap. Like less than a coffee at your school cafeteria cheap if you source them from an Asian vendor off eBay.
  • Their platry 84×48 monochrome resolution means they can be used without putting too huge a load on a puny Uno/Nano/Pro Mini.
  • There are a number of libraries available for interfacing to them.
  • They can be updated fast enough for use with dynamic text.

And now the bad reasons:

  • The displays are sourced either as surplus or have been harvested from old phones. You can't be certain what you'll get, but whatever you get will probably not be pristine.
  • The main electrical contact between the display and the PCB is through a compressible foam material that was once pretty cool s***. The main issue this presents is that small shifts in pressure on the display housing seem to muck up the connections — at least they did on my sample. The contrast control in particular seems to be sensitive to housing pressure. Nokia obviously figured out how to work with this interface, but board suppliers might be missing some important know how here.
  • The LCD contrast is set in software. At first this seems like something totally cool, but if you're going to build more than one of whatever you're building, it means you'll have to tweak the code for each one you build or write software that allows the contrast to set at runtime. (And don't forget you'll need to save that to persistent memory.)

One of the best sources of information on these displays is SparkFun's Graphic LCD Hookup Guide. Note that the order of the pins will vary from supplier to supplier of these.

Libraries

These are libraries I know about that let you interface to a Nokia 5110 display. My tests were conducted with a 3.3V 8MHz Arduino Pro Mini equivalent and a display I bought off eBay from a vendor in China.

U8g2

Oli Kraus' U8g2 is intended to be a common platform for interfacing to a whole bunch of different monochrome displays. It supports the Nokia 5110 display's PCD8544 controller chip out of the box.

My test case is below. Notes regarding resource consumption are embedded in the code as comments.

display_nokia_5110_u8g2.ino
#include <U8x8lib.h>
#include <U8g2lib.h>
 
/*
 * Notes:
 * Program storage space and dynamic memory are the same whether you use HW or SW SPI.
 * With u8g_font_profont11, it uses 29% of program storage space and 24% of dynamic memory.
 * With u8g2_font_profont11_tr, it uses 25% of program storage space and 24% of dynamic memory.
 * With u8g2_font_fur30_tr, it uses 35% of program storage space and 24% of dynamic memory.
 */
 
/*
 * Pin assignments:
 * RST: 8
 * CE/CS/SCE: 10
 * DC/"D/C": 9
 * DIN/DN/MOSI/DATA: 11
 * CLK/SCLK/SCK: 13
 * VCC: 3.3V
 * LIGHT/LED: ground through 330 ohm resistor
 * GND: ground
 */
 
const unsigned int CLOCK_PIN = 13,
                   DATA_PIN = 11,
                   CS_PIN = 10,
                   DC_PIN = 9,
                   RESET_PIN = 8;
 
//U8G2_PCD8544_84X48_1_4W_SW_SPI u8g2 = U8G2_PCD8544_84X48_1_4W_SW_SPI(U8G2_R0, CLOCK_PIN, DATA_PIN, CS_PIN, DC_PIN, RESET_PIN);  // SW SPI
U8G2_PCD8544_84X48_1_4W_HW_SPI u8g2 = U8G2_PCD8544_84X48_1_4W_HW_SPI(U8G2_R0, CS_PIN, DC_PIN, RESET_PIN);                       // HW SPI
 
void setup() {
  u8g2.begin();
  u8g2.setContrast(135);
}
 
void loop() {
  u8g2.firstPage();
  do {
    // u8g2.setFont(u8g_font_profont11);  // set a font
    u8g2.setFont(u8g2_font_profont11_tr);
    // u8g2.setFont(u8g2_font_fur30_tr);
    u8g2.drawStr(0, 15, "Nokia 5110");  // write a string at position X, Y
    u8g2.drawStr(0, 35, "Hello World!");
  } while ( u8g2.nextPage() );
}

U8glib

Before there was U8g2, there was U8glib. While this version of the library is no longer maintained, it doesn't mean it doesn't have value. It's code interface is a little less bewildering than U8g2 and so may be better suited to beginners. It also seems to be a bit lighter in resource consumption, as you can see from the comments in my test case below. (Compare these to the results for U8g2 above.)

display_nokia_5110_u8glib.ino
// Henry's Bench
// Arduino Nokia 5110 U8Glib Tutorial
// From http://henrysbench.capnfatz.com/henrys-bench/arduino-displays/arduino-nokia-5110-with-u8glib-tutorial/
// Modified by mfk.
 
#include "U8glib.h"
 
/*
 * Notes:
 * With u8g_font_profont11, uses 23% of program storage space and 11% of dynamic memory.
 * With u8g_font_fur30r, uses 38% of program storage space and 11% of dynamic memory.
 */
 
/* Pin assignments:
 * RST: 8
 * CE/CS/SCE: 10
 * DC/"D/C": 9
 * DIN/DN/MOSI/DATA: 11
 * CLK/SCLK/SCK: 13
 * VCC: 3.3V
 * LIGHT/LED: ground through 330 ohm resistor
 * GND: ground
 */
 
const unsigned int CLOCK_PIN = 13,
                   DATA_PIN = 11,
                   CS_PIN = 10,
                   DC_PIN = 9,
                   RESET_PIN = 8;
 
// Declare the display and assign the pins
U8GLIB_PCD8544 u8g(CLOCK_PIN, DATA_PIN, CS_PIN, DC_PIN, RESET_PIN);  // CLK=8, DIN=4, CE=7, DC=5, RST=6
 
void draw() {
 
  u8g.setFont(u8g_font_profont11);  // select font
  // u8g.setFont(u8g_font_fur30r);
  u8g.drawStr(0, 15, "Nokia 5110");  // write a string at position X, Y
  u8g.drawStr(0, 35, "Hello world!");
}
 
void setup() {
  u8g.setContrast(138);  
}
 
void loop() { 
 u8g.firstPage(); 
  do {
    draw();
  } while( u8g.nextPage() );  
}

SparkFun

You can download code for the Nolia 5110 from the SparkFun information page that isn't actually a library but rather a comprehensive sketch that exercises a lot of the things you might want to do with the display. To get a rough idea of its resource use, I stripped out all the graphics stuff and had it only write two lines of text. Don't be misled by the simplicity of the code below. The stuff provided in the download is able to do just about everything you might want to do with the display. Once again, notes about resource use embedded as comments.

display_nokia_5110_sparkfun_minimal.ino
/* Nokia 5100 LCD Example Code
   Graphics driver and PCD8544 interface code for SparkFun's
   84x48 Graphic LCD.
   https://www.sparkfun.com/products/10168
 
  by: Jim Lindblom
    adapted from code by Nathan Seidle and mish-mashed with
    code from the ColorLCDShield.
  date: October 10, 2013
  license: Officially, the MIT License. Review the included License.md file
  Unofficially, Beerware. Feel free to use, reuse, and modify this
  code as you see fit. If you find it useful, and we meet someday,
  you can buy me a beer.
*/
 
/*
 * Modified by mfk: minimal test, different pins used, different contrast.
 * 
 * Notes:
 * This minimal version uses 6% of program storage space and 26% of dynamic memory.
 * Different fonts can be experimented with
 */
 
/* mfk pin assignments (set in LCD_Functions.h:
 * RST: 8
 * CE/CS/SCE: 10
 * DC/"D/C": 9
 * DIN/DN/MOSI/DATA: 11
 * CLK/SCLK/SCK: 13
 * VCC: 3.3V
 * LIGHT/LED: ground through 330 ohm.
 * GND: ground
 */
 
#include <SPI.h>
#include "LCD_Functions.h"
 
void setup()
{
  lcdBegin(); // This will setup our pins, and initialize the LCD
  setContrast(55); // Good values range from 40-60
 
  setStr("Nokia 5110", 0, 12, BLACK);
  setStr("Hello World!", 0, 28, BLACK);
  updateDisplay();
}
 
// Loop does nothing!
void loop()
{
}

Rinky-Dink Electronics

Rinky-Dink Electronics has a number of libraries for working with the Nokia 5110: a basic version that let you write text and render bitmaps, a version that ads graphics capabilities, and and add-on that lets you load images from an SPI flash chip.

I have not yet tested any of these, but I like the two-tiered and modular approach to functionality.

Adafruit

Adafruit has a dedicated library. Untested.

nitins11

Nitin Sharma has a dedicated library. Untested.

baghayi

Hossein Baghayi has a dedicated library. Untested.

arduino/displays_for_classic_arduinos/nokia_5110_displays_and_classic_arduinos.1517091556.txt.gz · Last modified: 2018/01/27 22:19 by mithat

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki