Microprinter Sparklines

Ever since Tom Taylor inspired quite a few of us to play with printers, I’ve been seeing what I can get mine to do. So far: barcodes were pretty quick. More recently, daily digests, twitter updates and even printing an entire a book. What’s next?

Microprinter Sparklines

Sparklines turned out to be fairly easy. I’ve written a basic Java library for talking to the printer, which I’ve shared on Github. The latest version of Microprinter.java connects over USB to the microprinter_sketch.pde Arduino sketch which then simply relays whatever you send to it on to the printer.

The Java library contains a method called printSparkline(), which takes a label and an array of data. Here’s how you’d use it to create the printout shown above:

int[] sawBytes = new int[256];
int current = 0;
boolean flip = true;
for (int i = 0; i < 256; i++) {
   if ((current >= 7 && flip) || (current <= 0 && !flip)) flip = ! flip;
if (flip) {
} else {
   sawBytes[i] = current;
microprinter.printSparkline("saw............", sawBytes);

int[] sineArray = new int[256];
for (float i = 0; i < 256; i++) {
   sineArray[(int) i] = (int) (Math.sin(i / 5) * 1000);
microprinter.printSparkline("sin............", sineArray);

Please feel free to adapt and improve. If you make any serious changes I'd love to see them, and don't forget to get involved on the microprinter wiki.

More Microprinting

I’ve been experimenting a bit more with the thermal receipt printer I bought recently. Inspired by Tom’s daily digests I’ve been trying some of my own.

Microprinter testing - font A Microprinter testing - font B

You only get 48 characters per line using the default font. The alternative font (font B) is much denser, with 64 characters per line. The second printout is only about an inch longer than the first one, yet has twelve additional lines of content.

The barcode at the bottom is a sort of physical permalink using a Code 39 barcode. I’m thinking that each daily digest could also exist in a (private) blog, and a barcode (complete with text date stamp) could be a handy way in. If you’re using this code, or something like it, you could do this…

printBarcode("/2009/02/22/", barcodeModeCODE39);

I used EvoBarcode Scanner to test reading it back in.

Barcode scanning

More ideas for a daily digest:

Tonight I hooked it up to Twitter. Every minute to checks to see what my contacts are saying and prints whatever is new since it last checked (usually 2 or 3 updates).

30 minutes of my friends’ twitter updates equated to five feet of paper. I don’t think I’ll be running this all the time but it does feel reassuring to have it whirring away in the background.

Another use of the Microprinter: printing books. I took the text of Cory Doctorow’s Down and Out in the Magic Kingdom (mainly because I can). It has over 47,000 thousand words, and if you print it at 64 characters per line on standard 80mm thermal paper it’s about 60 feet long.

Printing a book Printing a book

Printing time: about 40 minutes (pausing briefly after every paragraph to let the printer catch up). Rolling it back up again took nearly as long.

At Nick‘s very cunning suggestion there are perforations at every chapter (as well as every sub-chapter, which the ASCII text denotes using a ‘#’ character on its own). Together this divides the book into 59 perforated segments which are about 30cm long on average. Rather than needing a bookmark I’ll just tear off the sections as I finish them.

It’s a portable, recyclable, tear-and-shareable book.


Inspired by Tom Taylor’s microprinter project, I’ve bought a Citizen CBM-231 thermal reciept printer of my own. I picked it up for just £20 on eBay, including shipping. It’s great.

Tom uses his to print the weather, his diary, where his friends are (according to Dopplr) and more. As soon as I saw it, I wanted one of my own to hack with. Reciepts, printed on cheap and recyclable thermal paper, are perfect for directions, schedules, TODO lists and other impermanent bits and pieces you might want to carry while you’re offline. I also like the idea of it politely telling me what I’m up to as part of my morning waking-up ritual. I have a feeling that the soft sound printing and the ‘clunk’ of the auto-cutting blade will be a nice start to the day.

Citizen CBM-231 Citizen CBM-231 Arduino Hacked cable MAX3221 Barcodes!

(More photos)

A few hours of soldering and programming later, and I’m quite a happy hacker. I’ve put an Arduino sketch on github which shows how to easily print text and barcodes to the printer from an Arduino. It’s just a sketch at the moment, but I’ll turn it into a reusable library soon.  With a few utility methods and constants, a “hello world” with two barcodes ends up looking as simple as this…

println("Hello, World!");

I think it can print bitmaps too. With a bit of work it should be able to print sparklines and QR Codes.

I know Tom has inspired a lot of people, and there are quite a few of these Citizen CBM-231 printers being repurposed at the moment. If you’re interested in building your own microprinter, you’ll hopefully find the wiki at microprinter.pbwiki.com useful.

Update: more microprinting fun including a book and sparklines.

Powered by WordPress with GimpStyle Theme design by Horacio Bella.
The postings on this site are my own and don't necessarily represent my employer's positions, strategies or opinions.