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.