IoT Thermal Printer, all with a little Py and Pi
- Posted: Mar 28, 2014 at 6:00AM
- 11,569 views
Today's Hardware Friday has I think zero Microsoft technology in it. No Netduino, no .Net, no C#, nothing. But I thought it was really cool and well, sometimes we really need to look outside of our little Microsoft box anyway, right? Especially when it lets us build cool IoT gadgets... :)
Wade Wegner shows us how we can take something you might see every day, whenever you buy coffee or a burger and turn it into a cool IoT kitchen accessory...
How do you send a text message from your phone and have it print on a thermal printer that's sitting on your kitchen counter?
Hang on, we'll get to that shortly!
Shortly after Dreamforce last year I was turned on to Adafruit Industries by my teammate Reid Carlberg. I've since built a number of cool little gadgets, including the Brain Machine and the TV B Gone. Both projects were a ton of fun and a great way to get started with soldering and simple circuitry. It's been great fun having the TV B Gone when I travel. There's nothing more satisfying than turning off loud, annoying TVs (invariably on CNN) at the airport when you're trying to read or work.
I don't recall exactly how/where I first heard of it, but I was immediately drawn to the Internet of Things Printer for Raspberry Pi. I think it's the combination of a number of things that got me interested:
- A small thermal printer that doesn't require an ink cartridge.
- It's powered by a Raspberry Pi, providing lots of opportunities for coding.
- A miniature USB WiFi allowing it to run almost anywhere.
And of course, having three young kids, I thought of so many different ways the printer could be fun and useful (although, to be 100% honest, I haven't found all that much utility in it yet, but it sure has been fun).
The construction of the printer was fun. It took me a couple of days, but I'm slow.
Simply follow the Adafruit tutorial. It's fantastic and almost impossible to go wrong if you follow the directions.
The Adafruit tutorials also show you how setup some Python scripts to provide simple functions on the IoT printer, including:
- Daily weather scripts. Pretty useful at providing a local forecast.
- Twitter script. Prints everytime someone tweets you. I immediately disabled this script.
- Daily Sudoku puzzle. I love Sudoku and have kept this one running.
But, honestly, beyond this it's up to you to figure out interesting uses for the printer.
Not a problem for me. I had two ideas:
Figure out a way to let people send messages to the printer though simple text (SMS) messages.
Print out my kids daily school lunch menu. This had always been a huge annoyance as we'd have to load the school website almost every day to look it up.
Given that the thermal printer is powered by a Raspberry Pi, giving you the ability to write just about any kind of code you can think of in various languages, these ideas proved pretty simple.
Printing text messages on the IoT thermal printer
You may ask yourself, why would you want to send a text message to a printer? The best answer I can come up with is, because I can! As with most things, it's solving the challenge that provides the satisfaction, not the function itself.
As you've no doubt guessed, I used a number of cloud services to make it possible:
Twilio. Seriously one of the best developer services I've ever used. It's so much fun to bridge your applications with a phone (whether through SMS, MMS, or IVR).
Heroku. A cloud platform-as-a-service (PaaS) and part of the Salesforce1 Platform.
And, of course, some Python code on the Raspberry Pi ...
Getting the school lunch menu
As I said, I had grown tired of having to load up the school lunch menu every morning. We'd routinely have to browse to this lunch menu. It gets tiring after the 100th time.
So, with the help of my friend Steve Marx I created a Python script that does the following:
Downloads all the HTML from the lunch menu website.
Using a REGEX to extract the lunch menu data.
Iterates through the data until it finds today's date.
Formats and prints the menu on the printer.
There you have it! A solution guaranteed to reduce your daily stress and make your children incredibly happy!
I hope you found this solution interesting. If you do something like this yourself definitely let me know! You can find all the source code ...