The Thermal Printer Project: Part I
Written by James. Published on under the Thermal Printer (Series) category.
A few days ago, I decided to purchase the Adafruit Thermal Printer, which was compatible with the Raspberry Pi. This thermal printer has been on my mind for a while but this week a reason for buying one came to mind (aside from the fun of experimenting with a thermal printer which was obvious to me). I decided that I wanted to generate a random Aeropress recipe that I could then print. I thought this would be both fun to create and, upon further reflection, good excuse for me to try new Aeropress recipes that I might otherwise not use. So this project would have been a nudge to help me get out of my Aeropress recipe rut.
Whereas most printers need ink, thermal printers work by heating certain parts of the paper depending on what you want to print. This means I can keep my thermal printer running as long as it works without ever having to buy an ink cartridge. You may know thermal printers better from their more mainstream application, which is printing receipts. Without further ado, I'm going to start talking about the work involved in this project.
The thermal printer arrived earlier this week. I bought the "kit" version which meant that alongside the printer came the paper and cables I needed to hook up the printer to my Pi. Unfortunately, the power adapter was not suitable for UK plugs, so I have had to order another one. Aside from that, the kit gave me everything I needed. Adafruit had tutorials on their websites from various thermal printer projects, one of which was recommended for the printer I had purchased. I used that tutorial to help me get started and then quickly realised this project would require a bit of electronics.
Before I could set up the printer, I needed to strip the power cable that came with the printer so that I could connect it to a converter which would let me power the printer with a wall adapter. The printer does need power from the wall. I have found that even the 12V 1A charger I use for my keyboard was not enough. I need more amps, apprarently, which is why I have had to order a power adapter. Anyway, I have never stripped a power cable before so suffice to say I was scared I would break something. I had wire strippers in a cupboard nearby so I dug them out and watched a tutorial on how to use them. Within a few minutes, and with a bit of force, I was able to strip the wires so I could connect them to the converter.
The rest of the work was easy. I looked at the diagrams on the Adafruit website which helped me figure out where the cables go on the Raspberry Pi. And then I had a thermal printer, ready to use. The next part of configuring the printer was setting up the software.
Adafruit's tutorial came with some guidance on how to print text to the printer. This guidance was helpful as it enabled me to see that the printer was working. However, I was unable to print out an image from the command line using cups, which the tutorial said I could do. I would only get gibberish text despite trying to print an image. I researched this problem for a bit and after trying a few solutions, such as experimenting with the baud rate, I decided it was not worth spending too much time on image printing. I wanted to build some software that would let me print text. Images could come later.
The thermal printer tutorial came with a Python library which can be used to work with the printer. This was perfect for me because it meant I would not have to rely on the command line for printing, which was not ideal given my ambitions for this project. I wanted to print out an Aeropress recipe but further down the line, as I shall discuss in the next part of this series, I wanted to work with web APIs. Anyway, this Python library was just right. I ran the printertest.py file and noticed that the file contained all of the code snippets I needed to understand how to configure and print text and images from Python. (Note: Image printing through this library seems to work better than through the cups command in the terminal, but I still have to do a lot more experimenting.)
The first program I wrote generated a random Aeropress recipe. This program would give me guidance on:
- How much water to use
- How much coffee to use
- How many times to stir the coffee
- How long to brew the coffee for
- How many filter papers to use
- What grind size to use
I worked on this program across a few days because I kept getting some new ideas on how to improve the program. I used my knowledge of coffee brewing I even added a feature that lets me enable whether I want there to be a chance that I get an inverted recipe (which is presently disabled because I much prefer the regular, upright method of brewing with an Aeropress). But I did not stop here. While this program was in the background, I kept working on other modules. In other words, I wrote programs that would give my printer more functionality.
Here are two recipes generated from the program:
I had already written the start of the Python program for generating a random Aeropress recipe before my thermal printer arrived. I got very excited about the idea. The main change I had to make to enable the program to work with my thermal printer was that instead of printing text to the console I had to use the Adafruit thermal printer library to print the text. For all of the other programs I have been working on, a lot of trial and error has been required. I have went through an entire roll of paper getting the printer set up and trying to configure my Aeropress program and other modules (which I will talk about in the next part of this series). I have had to order more paper. But now my programs are mostly working as expected.
The vision for this printer is to:
- Print me a daily update, with a random Aeropress recipe I can use that day.
- Print messages sent as webmentions from this blog.
I want this printer to be both a way for me to stay updated with pieces of information that matter to me as well as a way for anyone who knows how to send a Webmention to send me a message. The Webmention is not entirely accessible due to the technical work involved in setting it up but I am fine with this right now. I am adding the Webmention feature because I want to be able to receive printed comments on my blog. I might open this up further in the future but I am still thinking about how far to extend this idea.
As for the daily update, I have taken inspiration from the Little Printer, a project I discovered in the IndieWeb chat, which printed a daily newspaper for you. This project was an Internet of Things printer built for consumers. The printer is no longer in production as the company who created and maintained the printer, Berg, and its infrastructure has shut down. But, Berg have set a good precedent for experimentation with thermal printers. My daily update is going to be personal to me but I like the idea of having an update that prints at a certain time of day, based on my needs. I will explain my goals for my daily update in the next part of this series.
I'd like to conclude by sharing a link to Exciting.io's blog post on thermal printing. I skimmed over this post a few times before and after my thermal printer arrived. I think the posts paints a great example of the capabilities of thermal printing and how creative working with thermal printers can get.
Read more content like this
Check out the other posts I have written related to this article.
- Going back to the Aeropress
- My two-cup Chemex recipe
- The Chemex: A week or two on
- The Thermal Printer Project: Part I
- The Thermal Printer Project: Part II
Powered by Novacast
Other posts in this series
Check out the other posts I have written as part of this series.
Comment on this post
Respond to this post by sending a Webmention.