PROTOTYPE: Thermal Tweeter, networked Twitter printer @dangerousproto

in Prototypes, web platforms by Ian | 18 comments

Free video chat by Ustream

Send a Tweet to @dangerousproto and watch it print live on the USTREAM feed.

Thermal Tweeter is hacked together from a SparkFun thermal printer and the web platform internet development board. No computers are used to query twitter or run the printer, this is a 100% stand-alone Twitter appliance.

This is a soft-launch of our project for the Adafruit/Instructables Make it Tweet Challenge. We need your help stress testing the system today.

Keep reading to find out how it works.

Overview

You tweet, the web platform contacts Twitter and grabs the newest tweets, the tweets are formatted and output to the printer.

Is this wasteful? You bet. And the thermal chemicals on the paper may cause cancer – don’t eat it! Thermal Tweeter is an homage to the waste generated by checkout receipts. Unlike a store checkout where you always get a receipt, you’re in charge of the Twitter waste. Save the earth, don’t Tweet. Or whatever.

Credit for this project idea goes to Sjaak, who also provided the printer. Thermal Tweeter builds on our previous interactive internet projects like the @tweet_tree and internet graffiti wall.

Hardware

Setup is really simple. The thermal printer connects to the web platform with one data wire. A second wire connects the common ground between them.

Printer Web platform
RX IO7
GND GND

A serial port assigned to pin IO7 on the web platform outputs serial data to the printer RX pin at 19200bps.  See the web platform intro article for more about assigning hardware peripherals with peripheral pin select. See SparkFun’s Arduino code and the printer datasheet for the simple control commands.

The printer requires a beefy 5volt power supply for the heating element (1.5A+). We used a 1.5A 5volt wall wort.

The web platform can be powered from USB or a wall wort. Our best wall wort is powering the printer, and we want to use the web platform USB connection for debugging info, so we used the USB supply. USB connection is only for power and debugging info, it doesn’t contribute anything to the Twitter printer.

Firmware

Firmware is built on the @tweet_tree source. It searches twitter for the latest tweets to @dangerousproto and prints them.

{“from_user_id_str”:”207791348″,

“profile_image_url”:”http://a0.twimg.com/profile_images/1239094780/Photo_on_2011-02-08_at_19.45__2_normal.jpg”,

“created_at”:”Wed, 22 Jun 2011 16:19:17 +0000″,

“from_user”:”bertjwregeer”,

“id_str”:”83569757827248129″,

“metadata”:{“result_type”:”recent”},

“to_user_id”:37626644,

“text”:”@dangerousproto Missed it =). Didn’t know ustream doesn’t work on the iPad.”,

“id”:83569757827248129,

…}

Tweets, user names, and IDs are extracted from a simple JSON search results feed like shown above. JSON is a way to share data, like XML, but way more compact. The web platform stores the text in a giant array. After all new Tweets are processed, the text is sent to the printer.

The ID tag is especially important. The highest ID number is stored and appended to the next search URL. Twitter only sends tweets newer than the ID number so we only get fresh commentary.

The printer is controlled by 19200bps serial UART output from the web platform. Simple commands configure it. Using it is simple, send a line of ASCII text and print it with a line feed character (0x0a).

We used a 32 character wide row. Row breaks are inserted into the tweet by the web platform without regard for the location of words, words will often be split to two lines.

Server responses are dumped out the USB serial connection to help with debugging. The activity can be viewed on a PC with a serial terminal set to 115200bps. Even if you don’t have a thermal printer, you can program the firmware into your web platform and watch the twitter queries.

Playing nice

Twitter doesn’t like it when you hammer their server with requests. Thermal Tweeter waits at least 30 seconds between updates. This should be responsive, but stay within the 150 search/hour limit set by Twitter.

Don’t kick Twitter when it’s down. If Twitter doesn’t reply or responds with an error, Thermal Tweeter retries twice and then waits a few minutes before trying again. It’ll be easier for Twitter to get their act together if we don’t flood them with search requests.

Compiling

The firmware uses Microchip’s TCPIP stack, which is a separate (free but not open source) download. It is compiled with the free C30 compiler. Our source and HEX files are in SVN.

Taking it further

Originally we wanted to add a keyboard for two way communications. Type a message and it is pushed to Twitter on enter, or every 140 characters.

Microchip’s non-open source TCPIP stack is a pain to work with because we can’t share all our code. We’d prefer to use the FreeRTOS port for the web platform instead.

Neither of these ideas made it into the final design due to our server battle over the last two weeks.

Build one

You can build this project with SparkFun’s thermal printer ($50), the web platform ($40), and a good 5volt power supply.

This entry was posted in Prototypes, web platforms and tagged , , , , , .

Comments

  1. Ian says:

    First tweet was a Rick Roll. Right on! gooberdlx PM me for a free PCB :)

    • Sjaak says:

      You’ve been rick-rolled ;)

      It was fun to do this project together! Too bad we hadn’t time on our side and we couldn’t use the regular api to display the mentions. After all we had some fun and a result :D

      It is fair to mention the same printer is also obtainable through sure (the price is lower but they charge lots of $$ for shipping, so my *guess* is the price is approx the same) link: http://www.sureelectronics.net/goods.php?id=1286

      BTW: an idea to put a random tweet (cut out) in the pcb drawer? ;)

  2. qube23 says:

    UTF-8 characters like █ don’t seem to work.

  3. Jack Fuge says:

    I think it’s broken…. someone hit the reset button please?

    Or is it just on a 15 minute refresh or something?

  4. JBeale says:

    Nifty project. Send an email over the wire and it prints out, hmmm… anyone here old enough to remember the TELEX machine?

  5. JBeale says:

    hmmm.. the lights blink, but nobody’s home. At least, my twitter didn’t get printed after 5 minutes.

  6. Ian says:

    Twitter seems to arbitrarily decide whose Tweets to include in the feed. You can check the JSON to see if yours was included. Don’t know why this happens, but it also happens for the XML feed I have on my PC.

    http://search.twitter.com//search.json?rpp=11&q=%40dangerousproto&since_id=

    • Sjaak says:

      The problem is on the search api. It does not index every tweet so some are missed. I think (if we had more time) we should use the api.twitter.com/1/status/mention.json this seems to return all the tweets mentioning you (it is designed to do this ;))

  7. bluehash says:

    Just tweeted and it printed. Pretty awesome. Good luck on the contest!

  8. Schazamp says:

    I had an idea like this some time ago, called “The IdeaBot”, a way I could tweet ideas or things I wanted to look up later to myself. That way, they would all be there, in order, on a receipt, at my desk, at home, and I could go through the list when I had time to work on projects.

    Very nice implementation, I wish you as much luck as I dare in the contest (for I also have entered, though I cannot but admit your entry is more compelling and useful than my own).

  9. Butch Ross says:

    Curious, could this be made to run on a well-hacked version of something like this? http://www.old-computers.com/museum/computer.asp?c=474

  10. Bob says:

    You should sell the filled roll on ebay

  11. balaji says:

    String xml = wc.DownloadString(“http://twitter.com/statuses/user_timeline/XXXXXXXX.xml?count=2″);

    DataSet ds = new DataSet();

    ds.ReadXml(new StringReader(xml));

    if (ds.Tables["status"] != null && ds.Tables["user"]!=null)
    {

    // Response.Write(ds.Tables["status"].Rows[0]["created_at"].ToString()+” “);
    //Response.Write(ds.Tables["user"].Rows[0]["name"].ToString() + “”);
    Response.Write(ds.Tables["status"].Rows[0]["text"].ToString() + “”);

    Response.Write(ds.Tables["user"].Rows[0]["description"].ToString() + “”);

    }

  12. Lance says:

    could this system be able to be used for a facebook news feed?

  13. Liz says:

    I’ve been playing round with the but using an ardunio, while connected to my MacBook. However I want to try and stop words splitting when they have reached maxium character width.

    And ideas?

Leave a Comment

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Notify me of followup comments via e-mail. You can also subscribe without commenting.