Third party cookies may be stored when visiting this site. Please see the cookie information.

Home Family Days Out Raspberry Pi & Electronics Blog

Stewart's Blog

Stewart Watkiss website to the world ...

(Children, computing, first aid and other ramblings ...)

World Book Day – Raspberry Pi and Pimoroni InkyPHat Badge

Today is World Book Day. For the last few years I’ve been supporting my local school by helping run their book sale. Last year I dressed up as The Wizard of Oz complete with Wearable Electronic flashing bow tie. This year I am a little more subtle as I won’t be wearing a full costume, but still keeping with the wearable electronics I’ve gone for a Raspberry Pi powered electronic badge.

InkyPHat wearable Raspberry Pi badge for World Book Day

The badge is based around a Raspberry Pi Zero W, mounted in a Pimoroni PiBow case and a InkyPHat display. The display is based around ePaper / eInk technology (similar to how the original Kindle works). This means it uses very little power and will continue to display the output even after the power is switched off. It does have a bit of a flicker when it refreshes the screen (which takes a few cycles to update), but that only draws attention to the badge. Unlike most other ePaper displays this one can display more than one colour. It can display images in Red, Black and White (although one of these is likely to be the background colour).

You can see the badge in action on the short video below:

I’ve also included the source code of the program, for this you will also need a png file which needs to be created using a 3 colour palette (more details of how to create an Inky Phat compatible image are provided here).

Source code for Raspberry Pi InkyPHat World Book Day badge

#!/usr/bin/env python

import inkyphat
import time
from PIL import ImageFont, Image

font = ImageFont.truetype(inkyphat.fonts.FredokaOne, 32)

message = ""
w, h = font.getsize(message)
x = (inkyphat.WIDTH / 2) - (w / 2)
y = (inkyphat.HEIGHT / 2) - (h / 2)

font2 = ImageFont.truetype(inkyphat.fonts.FredokaOne, 28)
message2 = "Books are\nFun!"

w2,h2 = font.getsize(message)
x2 = (inkyphat.WIDTH / 2) - (w2 / 2)
y2 = (inkyphat.HEIGHT / 2) - (h2)

while 1:
inkyphat.clear()
inkyphat.text((x, y), message, inkyphat.RED, font)
inkyphat.show()
time.sleep(10)

inkyphat.clear()
inkyphat.set_image(Image.open("/home/pi/wbookday01.png"))
inkyphat.show()
time.sleep(10)

inkyphat.clear()
inkyphat.text((x2, y2), message2, inkyphat.BLACK, font)
inkyphat.show()
time.sleep(10)

The image file is below:

World book day InkyPHat image

Please leave comments using the facebook comments below.


UK days out, children and holiday information is also available on the Days Out Diary web site
Linux, LPI and the Quiz / Test Program posts are also available on the Penguin Tutor website
First Aid Information, first aid games and first aid practice test / quiz entries are also available on the First Aid Quiz Web site