Graphic LCD 84x48 - Nokia 5110 (LCD-10168)

This is a placeholder topic for “Graphic LCD 84x48 - Nokia 5110” comments.



The Nokia 5110 is a basic graphic LCD screen for lots of applications. It was originally intended for as a cell phone screen. This one is mounted on an easy to solder PCB.

Read more

1 Like

Cannot get this to work with a Pi Pico, but it works nicely with Arduino UNO.

Gone through all the options with the Pico SPI interface, tried both SPI controllers and various alt pin configurations. Tried various clock speeds and delay between byte transfers. Uses similar code to the Arduino written in python, tried a Pico library I found. The display refuses to show anything. It is further complicated because the data transfer is one way only. There is no SPI out of the display.

I could build my project with the Arduino, but the Pico is a better option. Bought the display a couple of years ago and have not used it till now. Was about to give it up as bad till I tried the UNO.

Has anyone got this to work with a Pico ??
Is there something obscure about the Pico SPI I am doing wrong ??
Till now I have mainly used the Pico with the I2C interface, which works nicely.

Regards
Jim

PS I could use a PiicoDev OLED with the large font I developed some time ago but I wanted to make some use of the Nokia 5110. And not have it as a wasted purchase.

EDIT: Also tried a brand new Pico with lastest micropython, nothing on display.

1 Like

Huh. I think I have an old Nokia in a drawer somewhere… kept it for an emergency backup, but these days the phone network no longer supports it. Wonder if I could dig out the screen and put it to use…? That would be heaps cool.

1 Like

Tried a difference library and example and now it works. Nice.

Not going to try to figure out why it was not working with previous library and code.

Regards
Jim

1 Like

I am well down this rabbit hole. Currently waiting on a breadboard kit and some logic level converters…

1 Like

What I have come up with.
Simple clock display with Nokia 5110, Pico, 400mAH battery, and some Makerverse boards (RTC, Nano Timer, USB-C Lipo charger).
Every 2 hours the Pico activates to display time and date for 2 minutes.
Pressing button activates Pico immediately for 2 minutes.
I estimate the battery should last about 45 days if on for 2 minutes every 2 hours.

The Pico is a power hog at 18mA, other items consume 3mA when on.


Wiring

Python code

############################################################################
#    Clock Display
#
#  Using Makeverse RTC, Nokia 5110 Display and Pi Pico
#
#
############################################################################
import pcd8544
import framebuf
from machine import I2C, Pin, SPI
from PiicoDev_Unified import sleep_ms
from Makerverse_RV3028 import Makerverse_RV3028

############################################################################
# Pins
############################################################################
cs = Pin(22)
rst = Pin(21)
dc = Pin(20)
done = Pin(16, Pin.OUT)
############################################################################
# Variables
############################################################################
charBlank = bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
charSlash = bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x80\xf0\xfc\x7c\x0c\x00\x00\x00\x00\x00\x00\x00\x00\xc0\xf8\xff\x3f\x07\x00\x00\x00\x00\x00\x00\x00\x00\x60\x7e\x7f\x1f\x01\x00\x00\x00\x00\x00\x00\x00')
charColon = bytearray(b'\x00\x00\x00\x00\x00\x00\x70\x70\x70\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0e\x0e\x0e\x00\x00\x00\x00\x00\x00')
charError = bytearray(b'\x00\x00\x00\x38\x3c\x1c\x1c\x1c\x1c\x1c\xfc\xf8\xe0\x00\x00\x00\x00\x00\x00\x00\x00\xfc\xfc\x3e\x0e\x0f\x07\x03\x00\x00\x00\x00\x00\x00\x00\x00\x1d\x1d\x00\x00\x00\x00\x00\x00\x00')
char0 = bytearray(b'\x00\xc0\xf0\xf8\x3c\x1c\x1c\x1c\x1c\x1c\x7c\xf8\xf0\xc0\x00\x00\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\xff\xff\xff\x00\x00\x07\x1f\x3f\x78\x70\x70\x70\x70\x70\x78\x3f\x1f\x07\x00')
char1 = bytearray(b'\x00\x00\x80\xc0\xe0\xe0\xf0\xf8\xfc\xfc\xfc\x00\x00\x00\x00\x00\x00\x03\x03\x01\x01\x00\x00\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x7f\x7f\x7f\x00\x00\x00\x00')
char2 = bytearray(b'\x00\xf0\xf8\xf8\x3c\x1c\x1c\x1c\x1c\x1c\x3c\x7c\xf8\xe0\x00\x00\x00\x01\x01\x00\x00\x80\xc0\xe0\xf0\x3c\x1f\x0f\x07\x00\x00\x70\x78\x7c\x7e\x77\x73\x73\x71\x70\x70\x70\x70\x70\x00')
char3 = bytearray(b'\x00\x70\xf8\xf8\x1c\x1c\x1c\x1c\x1c\x1c\xfc\xf8\xf0\x00\x00\x00\x00\x00\x00\x00\x0c\x0c\x0e\x0e\x1e\x3f\xff\xff\xf0\x00\x00\x0e\x1f\x1f\x38\x38\x38\x38\x38\x38\x3c\x1f\x1f\x07\x00')
char4 = bytearray(b'\x00\x00\x00\x00\x00\x00\x80\xc0\xf0\x78\xfc\xfc\xfc\x00\x00\x00\xf0\xf8\xfc\x9e\x8f\x87\x81\x80\x80\xff\xff\xff\x80\x00\x00\x03\x03\x03\x03\x03\x03\x03\x03\x03\x7f\x7f\x7f\x03\x00')
char5 = bytearray(b'\x00\x00\xf0\xfc\x3c\x1c\x1c\x1c\x1c\x1c\x1c\x1c\x1c\x1c\x00\x00\x1c\x1f\x1f\x07\x07\x07\x07\x07\x07\x07\xfe\xfe\xf8\x00\x00\x0f\x1f\x1f\x38\x38\x38\x38\x38\x38\x3c\x1f\x0f\x03\x00')
char6 = bytearray(b'\x00\xc0\xe0\xf0\x78\x1c\x1c\x1c\x1c\x1c\x3c\x7c\xf8\xf0\x00\x00\xff\xff\xff\x1c\x0e\x0e\x0e\x0e\x0e\x1e\xfe\xfc\xf0\x00\x00\x03\x0f\x1f\x1c\x38\x38\x38\x38\x38\x3c\x3f\x1f\x07\x00')
char7 = bytearray(b'\x00\x1c\x1c\x1c\x1c\x1c\x1c\x1c\x9c\xdc\xfc\xfc\x7c\x3c\x00\x00\x00\x00\x00\x00\xc0\xf8\x7e\x1f\x0f\x03\x01\x00\x00\x00\x00\x00\x00\x00\x7c\x7f\x7f\x00\x00\x00\x00\x00\x00\x00\x00')
char8 = bytearray(b'\x00\x00\xf0\xf8\xfc\x1c\x1c\x1c\x1c\x1c\xfc\xf8\xe0\x00\x00\x00\xf0\xfb\xff\x3f\x1e\x1e\x1e\x1e\x1e\x3f\xff\xfb\xf0\x00\x00\x0f\x1f\x1f\x38\x38\x38\x38\x38\x38\x3c\x1f\x1f\x07\x00')
char9 = bytearray(b'\x00\xf0\xf8\xfc\x3c\x1c\x1c\x1c\x1c\x1c\x3c\xfc\xf8\xe0\x00\x00\x1f\x3f\x3f\x78\x70\x70\x70\x70\x70\x38\xff\xff\xff\x00\x00\x0e\x1e\x1e\x38\x38\x30\x30\x38\x18\x1e\x0f\x0f\x03\x00')

months = {"01":"JAN","02":"FEB","03":"MAR","04":"APR",
          "05":"MAY","06":"JUN","07":"JUL","08":"AUG",
          "09":"SEP","10":"OCT","11":"NOV","12":"DEC"}
Date = "01/01/80"
Time = "00:00"
Flash = True
Count = 0
PwrOffCount = 0
############################################################################
# Setup
############################################################################
spi = SPI(1)
spi.init(baudrate=2000000, polarity=0, phase=0)
lcd = pcd8544.PCD8544(spi, cs, dc, rst)

buffer = bytearray((pcd8544.HEIGHT // 8) * pcd8544.WIDTH)
fbuf = framebuf.FrameBuffer(buffer,pcd8544.WIDTH,pcd8544.HEIGHT,framebuf.MONO_VLSB)

i2c=I2C(0,sda=Pin(8),scl=Pin(9),freq=400000)
rtc = Makerverse_RV3028(i2c=i2c)
############################################################################
# display char at x.y
############################################################################
def Show_Digit(char, x, y):
    cbuf = framebuf.FrameBuffer(char,15,24,framebuf.MONO_VLSB)
    fbuf.blit(cbuf,x,y)
    return
############################################################################
# Get character byte array to display
############################################################################
def GetChar(s):
    if s == '0':
        c = char0
    elif s == '1':
        c = char1
    elif s == '2':
        c = char2
    elif s == '3':
        c = char3
    elif s == '4':
        c = char4
    elif s == '5':
        c = char5
    elif s == '6':
        c = char6
    elif s == '7':
        c = char7
    elif s == '8':
        c = char8
    elif s == '9':
        c = char9
    else:
        c = charError
    return c
############################################################################
# Display the time every minute
############################################################################
def DisplayTime(t):
    Show_Digit(GetChar(t[0:1]),3,2)
    Show_Digit(GetChar(t[1:2]),19,2)
    Show_Digit(charColon,35,2)
    Show_Digit(GetChar(t[3:4]),50,2)
    Show_Digit(GetChar(t[4:5]),67,2)
    lcd.data(buffer)
    return
    
############################################################################
# Read the RTC date time, updates date if changed
############################################################################
def GetDateTime():
    global Date,Months
    dt = rtc.timestamp()
    d = dt[8:10]+' '+months[dt[5:7]]+' '+dt[2:4]
    t = dt[11:13]+':'+dt[14:16]
    if d != Date:
        fbuf.text(d,5,35,1)
        lcd.data(buffer)
        Date = d
    return t
############################################################################
# Main
############################################################################
done.value(0)
fbuf.fill(0)
fbuf.rect(0,0,84,48,1)
lcd.data(buffer)
Time = GetDateTime()   # updates date if needed
DisplayTime(Time)
try:
    while True:
        Count += 1
        if Count > 60:
            Time = GetDateTime()   # updates date if needed
            DisplayTime(Time)
            PwrOffCount += 1 
            Count = 0
        if Flash: Show_Digit(charColon,35,2)
        else: Show_Digit(charBlank,35,2)
        lcd.data(buffer)
        Flash = not Flash
        if PwrOffCount > 1:
            PwrOffCount = 0
            done.value(1)
        sleep_ms(1000)
        
except Exception as e:
    print('Error occurred : {}'.format(e))
finally:
    pass
    
#############################################################################
#############################################################################
#############################################################################

Uses PiicoDev & Makerverse Libraries and Nokia Library.

Happy with end result, bought a few more Nokia 5110 displays from Ebay ($3.56 each).
Makerverse products work very well.
Cheers
Jim

EDIT: Error in wiring. Shows GPIO19 connected to Nano timer Done, code actually uses GPIPO16 and pic shows connection to GPIO16.

2 Likes

Hah! Snake!

2 Likes

@Kimmo Looking good.
Nice to see old tech get a new lease of life.

Cheers

1 Like

It was a short lease!

Had a moment of brain fade and wired a couple of the pins to the wrong side of the level shifter :face_with_diagonal_mouth:

Hey Kimmo,

It happens to the best of us! Hopefully its recoverable and if not, I guess the magic smoke decided the project path for you!

Cheers,
Blayden