Help Six Degrees Edinburgh with a speciality coffee survey

Skip to main content

The Thermal Printer Project: Part II

Written by . Published on under the IndieWeb category.

A piece of thermal paper with a welcome message written on it

In the first part of this series on my experiments with the Adafruit thermal printer I recently purchased, I mentioned how I was working on other modules for the thermal printer. A “module” refers to a specific program that retrieves information that I can print out using the thermal printer. The first module I built was the Aeropress recipe but at the time it was not much of a module because I had not written any other code yet. But I quickly began work on other modules.

The daily update

As I noted in the last article, I want to create a daily update for myself that is printed out. My goal is for this update to be printed out every day before I wake up, perhaps at 6am. The update will be scheduled using cron, which will run a specific program at 6am or whenever I decide the update should be printed. The code for the printer will be kept on my Raspberry Pi so that I can have my printer running 24/7. If I were to turn the computer off that was operating the program, my printer would not be able to function as intended. And because my Pi is needed to run the thermal printer, I need to keep it on. I have done some research and I found that the Raspberry Pi should be fine running all day, every day.

Logistics of scheduling the update aside, I have been thinking about what I would want in a daily update. I want this update to be delivered sort of like a newspaper, featuring information that is important to me. The Aeropress recipe was an obvious addition because: (i) I had already written the code; (ii) I use my Aeropress a lot, especially if I cannot be bothered to get out all of my pour-over equipment; and (iii) I love the idea of getting a random Aeropress recipe in the morning. But what else could I add?

Building modules

I slowly started working on different modules. I built a weather module that uses the OpenWeatherMap API (which is free to use for my purposes) to retrieve the weather where I am at the time the receipt is generated. This module tells me both the temperature and also gives a brief description of the weather. I also built a module that retrieves a random quote from the quotes.rest API and a random joke from the jokes.one API. Ideas kept flowing. All of the text I generate in my modules is printed to the receipt via the Adafruit Python thermal printer library.

One of the most important modules to me is the news module. I used The Guardian homepage RSS feed to retrieve the first five posts which appear on the homepage. This means I can see a few headlines every morning without having to open up the Guardian which usually results in my at least skimming a few articles and checking various pages. The Guardian module gives me news updates but not all of the news that I want to see is from The Guardian. I also wanted to stay up to date with other bloggers. That’s where the RSS module came in.

Using the Python feedparser library, I have been working on an RSS module which parses the feeds of people whose posts I want to appear in the daily update. I check for posts in the last 24 hours and print the title and URL of each post to the console. I can use this module to see who has posted new blog posts without having to check my RSS feed. I have only added five or so RSS feeds to this module so far (one of which is for my own blog) but I will likely add more in the future. This module needs quite a bit of testing as it is not presently working as expected and is thus not ready to use.

I also built a module that tells me what events are on my calendar. To do this, I used the private ical link that Google Calendar (the calendar provider I use) gives out. This link is private so only I can see the file. Thankfully, the link does not have any authentication, meaning I can use a simple requests.get() request in Python to retrieve the calendar. I then wrote a program that iterates through events and prints out those which are scheduled for the day the receipt is printed out. I used this same logic to print out all the birthdays in the week the receipt is printed (an idea based on a feature I saw available on the Little Printer).

Here’s a print-out of a receipt that uses some of the modules above:

A piece of receipt paper with a daily update written on it

I reference all of these modules in my main.py program which means that I can easily enable and disable modules by commenting out a line of code. This has been especially useful for testing but also for understanding the structure of my programs. Indeed, I have tried to make my code as readable as possible. I expect I’ll make quite a few revisions to the printer program in the future.

Printing out a daily update

I have run out of printer paper so I need to wait for that to be delivered. Thus, I am unsure if all of my modules are working. I know that one module which I haven’t talked about above (a random image printer) is not working but that’s because I have not uploaded any images to the Pi yet. There is still testing for me to do but so far I am happy with what I have. When the printer paper comes, I’ll plug my Pi and printer into an extension cable and schedule my first-ever daily update printed via a thermal printer.

I like the idea of having a daily update on paper because it feels more personal than anything on the internet. My daily update tests so far feel like a newspaper that was written just for me. Imagine waking up to the top headlines, all of the events on your schedule, a random joke or quote, and other pieces of information on paper. Without having to look at your phone. The idea of having something physical is really interesting to me. Those who read this blog quite a bit might have realised there is a theme emerging regarding making digital content physical given my recent posts on printing this blog.

I have also been working on a module that lets me print out webmentions sent to this site. The logic behind that program, and my rationale, will be detailed in the third and final part of this series on experimenting with the thermal printer.

Also posted on IndieNews.

Go Back to the Top