← All articles
Experiments8 min read

InkPi: what I learned building an e-paper status board

A Raspberry Pi Zero 2 W, a 2.13-inch e-paper screen and a small pet that worries when my backups are late. Notes on what turned out to be harder, and more interesting, than expected.

Raspberry PiE-PaperPythonsystemdSide Project

I wanted something on my desk that answers one question at a glance: does anything need me right now? Not a dashboard I have to open, not a notification I'll swipe away. Just a small screen that's quiet when everything is fine and loud when it isn't.

That turned into InkPi: a Raspberry Pi Zero 2 W with a Waveshare 2.13" e-paper HAT. It shows the time, the weather and anything that needs attention, and my scripts put things on it through a small HTTP API.

InkPi held in front of a laptop, showing the date, the weather, the time, the dog and a note
Here's the actual Pi. I was messing around sending a lyric from “Apartment” by Modern Baseball, since the dog is the band's mascot.

What it does

  • Clock, date and weather (from Open-Meteo: free, no API key).
  • Checks. A backup script calls POST /checks/backup when it runs. If it reports a failure, or simply stops calling in, the bottom of the screen turns black and says which one and for how long.
  • Notes. POST /notes with "Call the dentist" puts it on the screen, optionally for a few hours.
  • Where I am. My phone tells the Pi when I leave and arrive, and the screen shows "You're home" or how far away I am.
  • A pet. A small character next to the clock whose mood follows the board.

Here's the whole thing reacting to a day's worth of events in about 40 seconds:

The InkPi screen with the dog: a note arrives, a check-in, a backup goes late, a disk fails, everything recovers, rain, the network drops
A note arrives, a check-in, a backup goes late, a disk fails, everything recovers, it starts raining, the Wi-Fi drops and comes back.

The rest of this post is the stuff I didn't know before I started.

E-paper is not a screen you "refresh"

On a normal display you redraw 60 times a second and never think about it. E-paper is different:

  • A full refresh flashes. The whole panel goes black, white, black and then shows the image. It takes a couple of seconds and it's very visible.
  • A partial refresh is fast and quiet, but it leaves faint traces of the previous image behind. This is called ghosting: after a few hours of partial updates you can see the ghost of old digits under the clock.
  • It keeps the image with no power. That's the nice part, and also a trap (more on that below).

So InkPi does a partial refresh once a minute for the clock, and a full one every 60 partials (about once an hour) to wipe the ghosts. It also compares the new image with what's already on the panel, byte by byte, and doesn't touch the panel at all if nothing changed. Most minutes, the only thing that changes is the clock.

A frozen screen looks perfectly healthy

Because e-paper holds its image, a crashed Pi leaves a clock on the screen that looks completely normal. It just says 14:32 forever. That's worse than a blank screen, because you believe it.

Two things fix it:

  1. When the service stops cleanly, it draws a big "stopped, since Sun 19:52" screen before it exits, so the last image is an honest one.
  2. The drawing loop reports to a systemd watchdog. If the loop hangs, systemd restarts the service. If the whole Pi freezes, a hardware watchdog reboots it.

The interesting signal is the one that doesn't arrive

My first idea for checks was "scripts report failures". But the failures that hurt are the silent ones: the backup that didn't run at all because the PC was asleep, the cron job with a typo, the other Pi that lost power.

So every check can be a dead man's switch. A script checks in with "every": 1440 (once a day), and if it hasn't called in for 24 hours plus a grace period (25%, at least 2 minutes), the check turns late on its own:

# end of the nightly backup
if ./backup.sh; then
  curl -fsS -X POST -H "Authorization: Bearer $T" -d '{"every":1440}' $PI/checks/backup
else
  curl -fsS -X POST -H "Authorization: Bearer $T" -d '{"status":"fail","msg":"backup.sh failed"}' $PI/checks/backup
fi

Nothing has to be "monitored". The board just notices the silence.

250 × 122 pixels forces you to decide what matters

The panel is 250 by 122 pixels, black and white. There's no room for "a bit of everything", so the bottom panel shows exactly one thing, in this order:

  1. Checks that are late or failing (with the whole panel inverted, so it's visible from across the room)
  2. The newest note
  3. "All 4 checks OK"
  4. "Nothing needs you."

Choosing that order was more useful than any of the drawing code. The screen isn't trying to show everything, just the most important thing.

A pet is a surprisingly good status indicator

This started as a joke and became my favourite part. A small character sits next to the clock and its mood follows the board: content when everything's fine, reading when there's a note, worried when a check is late, sad when one fails, asleep at night, holding an umbrella when it rains.

Inkling, the ink-drop pet, reacting to the same events as the dog
Inkling, the original pet: an ink drop drawn in code. Same events, same moods.

The trick is that you read a face faster than you read text. From the other side of the room I can't read "LATE backup, silent 2h", but I can see that the little guy looks worried.

The constraint is the panel again: every animation frame is a refresh. So the pet only animates when something happens (a few quick partial refreshes for a reaction), and otherwise only changes pose with the once-a-minute clock update, plus a blink every 5 minutes.

Animating a drawing with image processing

The second pet is a dog in sunglasses, and it isn't mine: it's the dog from Modern Baseball, one of my favourite bands. I've always loved that dog, so when the board needed a second pet there was really only one option.

It's a line drawing, and I didn't want to redraw it frame by frame, so the code splits it into parts automatically: the sunglasses become their own layer that can slide down so the eyes peek over them.

How do you find the sunglasses in a drawing? They're the only big solid black shapes. Everything else is thin lines. A morphological opening (shrink the black areas by a few pixels, then grow them back) erases thin lines completely, while big solid shapes survive:

# grow the white (= shrink the black), then shrink it back
opened = ink.filter(ImageFilter.MaxFilter(7)).filter(ImageFilter.MinFilter(7))

The nose is solid too, but much smaller, so only shapes at least 20% the size of the biggest one count as glasses. Two lines of Pillow, and the drawing can now look surprised, read, sulk, nod and hop.

Every mood and reaction frame of the dog, side by side
Every mood and reaction frame, all made from one drawing. The glasses slide, the head tilts, the tongue comes out.

Build a preview that runs the real code

I didn't want to deploy to the Pi every time I changed a pixel, so preview.py runs the real app on my PC, in a window that looks like the panel. The only thing swapped out is the display: instead of talking to the e-paper over SPI, it hands each image to the window.

Keys trigger every event (a note, a late check, a failure, rain, no network…), the API runs locally too, and it can record a scripted demo to a GIF. The two GIFs in this post come straight from it.

That one decision made the pet possible. Animations need dozens of small tweaks, and each one took seconds to try instead of a deploy.

Small bugs that taught me something

The favicon locked me out. The API locks an IP out for 10 minutes after 10 wrong tokens. Then I added a web page to manage the board, and every visit the browser quietly asked for /favicon.ico without a token. Each one was a "wrong token". A few page loads later, I'd locked myself out of my own Pi. Now /favicon.ico just returns 204.

Browsers open a lot of connections. To stop one device from hogging the Pi, I allowed 2 connections per client. Browsers open up to 6 at once, some in advance, so the page's requests were randomly dropped and it said "can't reach the Pi". Now it's 6 per device and 16 in total.

Every request needs a deadline. While testing those limits I found that a client sending one byte every few seconds could hold every connection open forever and lock everyone out, without ever knowing the token. Every request now has 15 seconds to finish.

Spanish iPhones eat the decimal comma. My phone sends its location through an iOS Shortcut. On a phone set to Spanish, putting a coordinate in a Number field silently drops the decimal comma: -34,60 arrives as -3460…. Sending it as Text keeps it intact, and the Pi accepts both , and ..

Being kind to the SD card (and to myself)

SD cards wear out with writes, and a Pi Zero runs 24/7. So:

  • Logs live in RAM only (16 MB, gone on reboot).
  • No swap file on the card. Compressed RAM swap (zram) instead.
  • State is written right away only when something visible changes. Routine "still OK" check-ins wait for a 30-minute flush.

And since it's on my network and reachable over Tailscale, it runs like something I'd put in production: no root, a sandboxed systemd service that can only open the SPI and GPIO devices, a 256-bit token compared in constant time, and size limits on everything. It's a desk toy, but the habits are the same.

What's next

It works, it's on my desk, and it has already caught a backup that silently stopped running. Things I'd like to try:

  • A small enclosure, so it stops looking like a circuit board leaning on my monitor.
  • More moods and more pets.

The main lesson: constraints made it better. Two colours, 250 pixels, slow refreshes and a tiny computer forced every decision to be deliberate, and the result is more useful than the dashboard I would have built without them.