What is a Piem after all? Read a Piem example by Nobel prize sir James Hopwood Jeans:

How I want a drink, alcoholic of course, after the heavy lectures involving quantum mechanics!”

Parts used

  • Raspberry Pi Zero
  • 58 mmThermal printer
  • 7 segment 4 digit display
  • DFRobot Self locking switch
  • Custom case
  • 5V 4A Power Supply
  • microSD
  • Jumper cables

How does it work

There are many algorithms to calculate Pi digits. After some research I´ve decided to use the Chudnovsky algorithm, since there was a clean and good Python implementation and tutorial by Joshua Salako-

The original code returns the complete number giving how many decimals, so I have modified the code to get the latest decimal. In every iteration I´m making a random join with a dictionary file and I do print the words considering paper width. I´m also saving a timestamped log, calculating elapsed time, checking a button to pause the entire operation and replace the paper roll.


Using Fusion 360 I have designed a simple enclosure in 3 parts to hide the thermal printer aesthetic and to provide easy access to the paper replacement, the pause button and 4 digit display.

Raspberry Pi Zero Setup

No kidding, this was the most complicated part. Being a regular Raspberry Pi Zero, no wireless is included. I did not have a microUSB hub available to connect keyboard and all.

Save the Raspberry Pi OS with no desktop to a microSD.

Open microSD boot/config.txt. right at the end, add:


Open cmdline.txt. Find "rootwait" and insert this right after:


Add a ssh file in sd root

Install bonjour Apple app and mod-duo-rndis.zip driver. Update the driver.

Install Putyy. Connect with microUSB cable. Open Putty.

Use raspberrypi.local as the address in your SSH software

User pi, password raspberry

Enable hardware serial from raspiconfig

sudo pip3 install adafruit-circuitpython-thermal-printer

What about the display

The display is used to show current decimal. At first it will work fast but then, around 500 decimals, it will start to take some time to calculate and print the next Piem word.

What about print ending

Pi number will be printed along with elapsed time and some other info.

What about logs

Piems will be also stored into a txt file with a timestamp.

What about 0 length words?

The first 0 appears in the 33 decimal and in fact around 10% of decimals are 0, but there are no 0 letter words, right? So I had to make a decision here: whenever a 0 appears, the Piempi machine will print an empty line.

Why didn’t you wait until Pi Day

Pi Day is celebrated on March 14 and it is a common date to release anything related to Pi number but being in April, the wait is too long.

Could it use other languages?

Sure. You only have to replace english.csv by any other language file with one word per line. Words don’t have to be ordered by length.

Does the poetry has any meaning?

I thought about adding an artificial intelligence layer with ChatGPT API to enforce some kind of predictive meaning in Piems but I did not want to connect this machine to WiFi (I do not have a Raspberry Pi Zero W) and finding some random meaning once in a while is satisfactory.


# send to printer


# how many decimals


# Paper width


# Gpio button


# dictionary file


# pause between iterations