I built a receipt printer for GitHub issues by horsellama
I have a lot of side projects on GitHub. Some of them are kind of popular, and I tend to get issues posted from time to time. The problem though is that usually they kind of get lost in the mix of my emails, or I forget to go through my repos and add new items to my todo list.
I’ve been occasionally writing new issues down on sticky notes whenever I see a notification for an issue, but I always wanted an excuse to streamline the process a bit more. After seeing a receipt printer spitting out orders while grabbing some take-out the other day, I wondered if I could use one to print out a ticket each time an issue was added to one of my repos.
Spoiler alert, it worked!
So here’s why I bought a receipt printer:
Every time one of my GitHub repos gets a new issue, I now get a physical ticket printed out on my desk 🪄 pic.twitter.com/g6uYtGP9J7
— Andrew Schmelyun (@aschmelyun) March 24, 2022
So let’s dive in and I’ll show you exactly what I used, and how I set it up!
Hardware list
In order to get started, I’ll need a thermal receipt printer and some way to get data into it. I ended up using:
- Epson TM-T88IV
- Raspberry Pi Zero W
- Micro USB to USB adapter
- USB Type-B cable
The reason that I went with an Epson thermal printer is that they use the ESC/POS command set, for which there’s established libraries in a variety of programming languages. Plus they’re pretty ubiquitous in the second-hand market, and I was able to pick one up on Ebay along with some receipt paper for a pretty fair price.
The other piece I need is some kind of hardware to connect from the internet to the printer, and facilitate the actual data sending. I could just hook it up to my PC, but I want this to be a fully-contained unit that could just be constantly on idle sitting in a corner. I have an old Raspberry Pi Zero W laying around that I’m not using, so I’ll choose that.
Because the RPi Zero has just a single micro USB port, I’ll use an adapter as well as a USB Type-B cable to connect it to the receipt printer.
Sending data to the printer
Alright, so we have the printer hooked up, the Raspberry Pi good to go, but now I need a way to send data to the printer from the Raspberry Pi. This could easily be accomplished with Node or Python, but since I’m a PHP developer and I enjoy stretching the limitations of the language, I’ll reach for that. Luckily for me, there’s a pretty solid library for working with ESC/POS commands available in PHP.
Before I write any code though, I have to make sure the printer is available to the program I create. Since I’m using Ubuntu on the Raspberr