Simple world clock with eInk display and Raspberry Pi Zero

post, Jun 26, 2021, on Mitja Felicijan's blog

Our team is spread across the world, from the USA all the way to Australia, so having some sort of world clock makes sense.

Currently, I am using an extension for Gnome called Timezone extension, and it serves the purpose quite well.

But I also have a bunch of electronics that I bought through the time, and I am not using any of them, and it's time to stop hording this stuff and use it in a project.

A while ago I bought a small eInk display Inky pHAT and I have a bunch of Raspberry Pi's Zero lying around that I really need to use.

Inky pHAT, Raspberry Pi Zero

Since the Inky Inky pHAT is essentially a HAT, it can easily be added on top of the Raspberry Pi Zero.

First, I installed the necessary software on Raspberry Pi with pip3 install inky.

And then I created a file in home directory /home/pi.

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
import os
from import auto
from PIL import Image, ImageFont, ImageDraw
from font_fredoka_one import FredokaOne

clocks = [

board = auto()
board.rotation = 90

img ='P', (board.WIDTH, board.HEIGHT))
draw = ImageDraw.Draw(img)

big_font = ImageFont.truetype(FredokaOne, 18)
small_font = ImageFont.truetype(FredokaOne, 13)

x = board.WIDTH / 3
y = board.HEIGHT / 3

idx = 1
for clock in clocks:
  ctime = os.popen('TZ="{}" date +"%a,%H:%M"'.format(clock))
  ctime =',')
  city = clock.split('/')[1].replace('_', ' ')

  draw.text((15, (idx*y)-y+10), city, fill=board.BLACK, font=small_font)
  draw.text((110, (idx*y)-y+7), str(ctime[0]), fill=board.BLACK, font=big_font)
  draw.text((155, (idx*y)-y+7), str(ctime[1]), fill=board.BLACK, font=big_font)

  idx += 1


And because eInk displays are rather slow to refresh and the clock requires refreshing only once a minute, this can be done through cronjob.

Before we add this job to cron we need to make executable with chmod +x

Then we add a cronjob with crontab -e.

* * * * * /home/pi/

So, we end up with a result like this.

World Clock

You can download my STL file for the enclosure here, but make sure that dimensions make sense and also opening for USB port should be added or just use a drill and some hot glue to make it stick in the enclosure.

Other posts