Source: https://mokxi.com/learn/arduino-nokia-5110

Learn

# A Nokia 5110 LCD on an Arduino

Advanced

Written by the Mokxi team

Start building free Open the editor

Or see every lesson.

- 455 parts on the bench
- 43 boards running now
- 1.00x real time, on every board

Click to open it in the editor

The Three small screens example: a Nokia 5110, a 128x32 SSD1306 and a 1.3 inch SH1106, each started by hand.

The Nokia 5110 is the little 84 by 48 pixel screen from old Nokia phones, sold today on a blue or red board with a backlight. Its PCD8544 chip takes data over five wires, it costs very little, and it draws almost no power, which made it a favorite for battery projects long before OLEDs got cheap.

The circuit above is an Uno driving three small screens by hand, with no display library: a Nokia 5110, a 128x32 SSD1306 OLED and a 1.3 inch SH1106 OLED. Each shows its name and a seconds count. The sketch talks to each chip directly, so you can see exactly what a library does for you, starting with the step that leaves most Nokia screens blank: the contrast.

## What you need

- An Arduino Uno
- A Nokia 5110 LCD board (PCD8544)
- A 128x32 SSD1306 OLED and a 1.3 inch SH1106 OLED (optional)
- A breadboard and jumper wires

## Wiring

Part and pin | Goes to | Note

Nokia RST | Pin 3 | Reset, active low

Nokia CE | Pin 4 | Chip enable, active low (CS or SCE on some boards)

Nokia DC | Pin 5 | Low for a command, high for pixels

Nokia DIN | Pin 6 | Data in

Nokia CLK | Pin 7 | Clock

Nokia LIGHT | Pin 8 | Backlight: high lights it on the blue board

Nokia VCC and GND | Power rail and GND | Use 3.3 V on a real board

SSD1306 SCL and SDA | A5 and A4 | Address 0x3C

SH1106 SCL and SDA | A3 and A2 | Also 0x3C, so on its own pins

## How the PCD8544 holds a picture

The 84 by 48 pixels are kept as six rows of 84 bytes, called banks. Each byte is a column of eight pixels stacked top to bottom, bit 0 at the top. So 6 x 84 = 504 bytes is the whole screen, and writing 504 bytes after setting the address to the top left fills it.

There is no way to read the screen back: the chip has a data in pin and no data out. A library that wants to draw a line over some text has to keep its own copy of the 504 bytes in the Uno’s RAM, change it there, then send it. That is what display() does in the Adafruit library.

## Contrast first, or you see nothing

The PCD8544 starts with its contrast voltage, called Vop, at zero. At zero the pixels do not darken at all, so a sketch can write a perfect picture to a screen that stays blank. Below about 20 nothing shows; from there the ink gets darker as the number rises.

Vop lives in the chip’s "extended" instruction set. The sketch switches to it with 0x21, sends 0x80 plus 50 for a Vop of 50, sets the temperature and bias, switches back to the basic set with 0x20, and turns the display to normal with 0x0C. With the Adafruit library the same thing is one line: display.setContrast(50).

Every panel is a little different. If yours is faint, raise the number a few steps at a time; if the whole screen goes gray, lower it. Somewhere between 40 and 70 suits most.

Starting the Nokia by hand, from the three screens sketch

## The same with the Adafruit PCD8544 library

For a real project, use the library. Adafruit_PCD8544 display(7, 6, 5, 4, 3) takes CLK, DIN, DC, CE and RST, the same pins as here, and gives you all of Adafruit GFX: text in any size, lines, circles, bitmaps.

Two calls trip people up. setContrast() has to come after begin(), or the screen stays blank. And drawing only changes the copy in the Uno’s RAM; nothing appears until display().

Hello on a Nokia 5110 with Adafruit_PCD8544

## The two OLEDs beside it

The OLEDs keep their pixels the same way, bytes of eight stacked dots in rows called pages, but each needs its own start-up. The 128x32 SSD1306 needs its charge pump switched on (0x8D 0x14) and its row count set for a 32-row strip. The SH1106 has 132 columns of memory behind 128 of glass, so every line is written from column 2, or the picture sits two pixels to the left with a stripe of junk on the right. That last one is the reason a 1.3 inch OLED looks wrong with the SSD1306 library.

Both OLEDs answer at 0x3C, so they cannot share one I2C bus. Here each has two pins of its own; on a shared bus you would move one board’s address jumper to 0x3D.

## Common mistakes

Never setting the contrast, or setting it too high. Blank, or solid gray. Start at 50.

Forgetting display() after drawing with the library. The picture is in the Uno’s RAM, not on the glass.

Running it from 5 V. The PCD8544 is a 3.3 V chip, on its supply and its signal pins. The simulation does not mind 5 V, and the circuit above takes VCC from the 5 V rail, but a real one can be damaged or act strangely. Power it from the Uno’s 3.3 V pin, and use a level shifter (or 10k resistors in series, a common shortcut) on the five signal pins.

The backlight the wrong way around. On the blue board LIGHT high turns it on; on many red boards it is LIGHT low. Pull the LIGHT wire in the circuit above and the text is still there, with the backlight off.

DC not connected. Every byte is then taken as a command or as a pixel, never the right one. Pull DC here and the glass stays empty with only the backlight on.

Skipping the reset pulse. The chip’s state at power-up is undefined on a real board, so pull RST low for a moment first, as the sketch does (the library does it in begin()).

## Questions

How do I connect a Nokia 5110 to an Arduino?

Five signal wires (RST, CE, DC, DIN and CLK) to any digital pins, here 3 to 7, plus VCC to 3.3 V, GND to GND and LIGHT to a pin or to VCC for the backlight. Then Adafruit_PCD8544 display(CLK, DIN, DC, CE, RST).

Why is my Nokia 5110 blank?

Most often the contrast was never set, or is too low or too high. Call display.setContrast() after begin() and try values from 40 to 70. Check that display() is called after drawing.

What is the resolution of the Nokia 5110?

84 by 48 pixels, black on a gray-green background, kept as six banks of 84 bytes.

Nokia 5110 or OLED?

The Nokia draws less power and reads well in sunlight with its backlight off. An SSD1306 OLED is sharper, brighter and needs only two wires on I2C. There is a page on the OLED below.

Related

## Keep going

Arduino OLED Display (SSD1306) Tutorial Arduino ST7735: 1.8 Inch Color TFT Wiring and Code SPI Explained: Clock, Data and Chip Select I2C Explained: Addresses, Acknowledges and Pull-Ups How the Nokia 5110 is modeled The Three small screens project Advanced The Arduino Uno simulator The project page, with the full sketch Advanced

## Build this for real

Open the editor, change a value and watch the number move with it. Nothing to install, and no account needed.

Start building free Open the editor
