This tutorial may be outdated. It is no longer recommended for beginners, and may need modifications to code or hardware that is not indicated in the tutorial.

Introduction

In the future, everything will be connected to the internet. And all restaurants will be Taco Bell!
The "Internet of Things" refers to the idea of pervasive, ambient connections between physical objects and the virtual world. If every modest sensor or output device could share information via the internet, what new paradigms will arise? Our little printer is one such experiment. What value can be culled from the internet without a browser interface, or even a computer screen for that matter?

Parts List

The printer package kit has been discontinued by Adafruit. If you make your own similar project, you will have to buy the parts separately.

The Internet of Things Printer Project Pack includes the following items:

Electronics

Because many users already have Arduino hardware, the kit does not include microcontroller and/or network boards. You will need to additionally purchase or bring:

-or-

Directions are provided for both. In either case, you will also need:

  • Cables for USB programming and Ethernet.

Acrylic Parts

As the kit of parts is not available at present, the design files for cutting your own acrylic are provided below. You may want to change these depending on your design.

Tools

The following tools are needed:

  • Soldering iron and solder.
  • Small screwdriver.
  • Optional: tape, pliers.
  • Not shown: wire cutters and strippers, lighter or heat gun for heat-shrink.

 

Preparation

  • If using the Arduino Ethernet (board, not shield), gently remove the 6-pin 90-degree male programming header from its socket.
  • If using the Arduino Uno + Ethernet Shield, remove the Ethernet Shield if it's currently installed.
  • Peel the backing paper off the acrylic parts. This may create a static charge, so building the kit with a grounding mat or wrist strap is recommended.
  • If using Ethernet Shield, there's an extra cutout on the back piece of the acrylic case that can be snapped off using finger pressure or pliers. If sharp points remain, trim with wire cutters or a file. If using the Arduino Ethernet, leave this cutout in place.

  • Note the unique Ethernet MAC address on the board — usually a white sticker on the bottom. You will need this later, so write it down or snap a photo.

Don't forget to peel the paper off the backing of the acrylic pieces before fitting them together

Assembly

1: Prepare pin headers

  • Using pliers or wire cutters, snap off three sections of pin header: two, three and five pins.

  • If using an Arduino Uno with Ethernet Shield, the three- and five-pin headers should be bent at 90 degrees to allow clearance inside the case. This can be done with a firm grip and pliers, or you may want to use a bench vise. The 2-pin header can be left straight. You do not need to bend headers if using an Arduino Ethernet board.

2: Prepare ribbon cable, power button

  • Peel away five strands from the ribbon cable. Here we'll be using the brown, red, orange, yellow and green conductors. Save the other wires, they'll be used in a later step.
  • Strip about 1/4" (6mm) of insulation from these five wires.
  • Twist the ends of the orange and red wires together.

  • The power button has five solder legs. Looking at the back of the button, turn it so that the legs are toward the bottom, forming a "smile" arrangement. Then use the following guide to solder the wires to the legs shown. Note that the second leg is not connected, and the fourth leg is joined to both the orange and red wires.

  • Locate the top piece to the acrylic case (it has a large rectangular cutout for the thermal printer, and a smaller circular cutout for the power button). Feed the ribbon cable through the round hole, then secure the power button with the included nut. (This acrylic piece is symmetrical — there is no "top" or "bottom," so you can insert the button through either side.)

  • The wires of the ribbon cable can now be separated — but leave about 2 inches (toward the power button) intact for sturdiness. Peel apart the remaining length of the green, yellow and orange wires. The red and brown wires can be left mostly together — peel apart about 2 inches near the end.

3: Install DC power jack

  • Locate the back piece of the acrylic case (with the Adafruit logo) and insert the DC power jack from the outside, then secure it from the inside with the included nylon nut.

  • Peel away two more strands from the unused section of ribbon cable. Here we'll use black and white. Strip about 1/4" of insulation and twist these together.
  • Solder the black and white wires to the outer of the two smaller legs on the DC jack. The inner of these two legs is not connected.
  • Solder the yellow wire (from the power switch) to the large center leg on the DC jack. The top and back case pieces are now conjoined by this wire and cannot be separated — be careful to always move these two parts together.

4: Solder row headers

  • Strip about 1/2" (13mm) of insulation from all of the unconnected wire ends, and twist each to prevent fraying.

  • Read the next few steps before proceeding. In a moment, we'll solder the wires to the row headers following the diagram below. But don’t rush into that just yet…read this through.

  • When joining wires to headers, pinch the tip of a wire against the header's plastic support and wrap the wire around the pin. Solder in place, then use wire cutters to snip off the starting bit of wire. But really, don’t start on this quite yet…
  • When finished, your wires will look almost like this. (Yes, the 5-pin header has only a single green wire connected…this is normal.) Read ahead one more step before you start on this…

  • The important part we skipped: the solder connections to the black and orange wires need to be covered with heat-shrink tube. We’ve shown them bare in the images above to mark the connections more clearly, but they really do need protection! Slide a bit of heat-shrink tube over each wire first, then twist and solder the wires to the headers, and finally heat with a lighter or heat gun to secure the tubing, like this:

  • Okay, now that you’ve read all that, go ahead and assemble the three headers, with insulation on the black and orange wires first.
  • Don't plug the headers into anything just yet. We'll refer back to our diagram later.

5: Install printer in top plate

  • Slide the thermal printer through the large cutout in the top piece of the case:

  • Secure the printer using the two plastic wedges. Screw down gently so as not to crack the acrylic.

  • Connect the power and serial cables into the back of the printer. Note the functions of each wire as labeled on the printer — we'll refer back to these later.

6: Attach board to bottom plate

This varies slightly between the Arduino Ethernet and the Uno + Ethernet Shield. In either case, only three of the four mounting holes are used, but it's different for each board type.

For Arduino Ethernet Board:

  • The mounting hole near the DC power jack is NOT used!
  • Insert a screw in the mounting hole near the Ethernet jack and secure it in place with a nut.

  • Insert screws in the remaining two holes near the microSD card slot. Do NOT secure these with nuts yet.
  • Place board on bottom plate by feeding the three screws through the corresponding holes.
  • Secure the three screws with nuts.
  • The 6-pin programming header can now be reinstalled.

Only the screw near the Ethernet jack has the extra "standoff" nut — the others pass straight through. Once installed, the board will be very slightly canted. This is normal and won't show once finished, and does not adversely affect operation.

For Arduino Uno + Shield:

  • The mounting hole nearest the USB connector is NOT used!
  • Insert three screws in the remaining holes — one near the DC power jack, and in the remaining two holes at the far end of the board.
  • Place board on plate by feeding the three screws through the corresponding holes.
  • Secure the three screws with nuts.
  • The Ethernet shield can now be installed on top of the board.

With this board combination, you will have an extra unused nut when finished. Once installed, the board will be very slightly canted. This is normal and won't show once finished, and does not adversely affect operation.

7: Join first case side

  • Identify the two acrylic side pieces. These are interchangeable; there is no right or left, but there is a specific orientation:

  • Identify the "middle" acrylic piece. This is the only piece not spoken for yet. It has a small round bite out of one end, and a large square bite out of the other (these are the top and bottom, respectively).
  • The case is assembled using "T-slot" construction. Holding the middle piece, insert a nut into the cross part of a "T". Place one of the side pieces, using the alignment slot toward the front, over the corresponding tab on the middle piece, then insert a screw into the hole that's aligned with the nut. If this is a dexterity challenge, the nut can also be held with tape:

  • Make sure the tops of the two pieces are correctly oriented. Insert a second nut and screw, and just finger-tighten for now.

8: Join case back and second case side

  • Things start to get tricky now — the back and top pieces of the case are joined by a wire at this point, so the two can't be separated very far. Work slowly and methodically to make sure you don't break the wire or get anything tangled.
  • Connect the back piece to the first side using the same T-slot technique:

  • Route the yellow wire under the bottom of the case, then install the second side using two more screws and nuts. Just finger-tight for now, and it's okay if the box isn't perfectly square at this stage.

9: Install case top

  • Route the two cables from the printer (power and serial) down through the middle of the box.
  • On one side of the case, loosen the two lower screws just a couple of turns. Then loosen, but do not completely remove, the two upper screws on the same side. The tip of the screw should be flush with the face of the nut. The side piece can then pivot upward slightly.

  • On the opposite side of the case, insert the top piece into the two alignment slots.
  • Pivot the loose side piece upward, press the case top into place, then re-tighten the four side screws (finger-tight is sufficient for now).

10: Connect wires and install case bottom

  • Connect 3-pin header to Arduino power pins. Two wires — white and brown — connect to GND, while the red wire connects to 5V.
  • Connect 5-pin header to Arduino pins 3 through 7. The single green wire should go to pin 3, and there will now be bare protruding pins.
  • Press the serial socket (3 wires) from the printer onto the protruding pins 5, 6 and 7. The green wire should go to pin 5, yellow wire to pin 6, and black wire to pin 7. Pin 4 (reserved for the SD card socket) is not used…here we've clipped off the exposed pin to avoid installing the printer socket in the wrong position:

  • Connect 2-pin header to the power socket (2 wires) from the printer. Orange connects to red, and black to black. Because this connection doesn't go to a fixed socket, it could shift around inside the case and come in contact with exposed metal. Danger! It is vitally important to cover this exposed header with a bit of tape, heat-shrink tube, or a dollop of Sugru. Go do that if you haven't already.

  • Connect 2-pin header to the power socket (2 wires) from the printer. Orange connects to red, and black to black. Because this connection doesn't go to a fixed socket, it could shift around inside the case and come in contact with exposed metal. Danger! It is vitally important to cover this exposed header with a bit of tape, heat-shrink tube, or a dollop of Sugru. Go do that if you haven't already.

  • The case bottom is installed similarly to the top, just inverted. Loosen the two upper screws on one side a couple of turns, and the two corresponding lower screws to where the tip is flush with the nut, allowing the side to pivot slightly outward. You might want to loosen the screws on both sides of the case. Stuffing the wires into the case makes this perhaps the most fussy step of the whole kit, and the extra wiggle room can be helpful.

  • Once the bottom is in place, finger-tighten all the side screws.

11: Install front face

  • One last time with the screw-loosening trick…this time around with the front of the case, enough to insert the tabs from the white acrylic front piece into the circular holes in the side pieces. There are only two tabs here…it acts as a hinge.

  • Be sure to orient the "@" sign the correct way:

  • Finally, all 8 case screws can be tightened. Finger-tight plus about 1/8 turn should suffice…not too tight or the acrylic could crack!

Download

In addition to the Arduino IDE software itself (if not already installed), three downloads are required:

First, retrieve the thermal printer Arduino library from our repository on GitHub. Click the DOWNLOAD ZIP button, extract the archive and then rename the uncompressed folder to "Thermal". Confirm that this folder contains the files Thermal.cpp and Thermal.h and the examples folder.

Second, download Cryptosuite, another Arduino library. When extracted, rename this folder to Sha and confirm the files sha1.cpp and sha1.h are inside this.

Finally, download the Adafruit "Tweet Receipt" code from its own repository, extract the archive and then rename the uncompressed folder to Gutenbird. Confirm that this folder contains the file Gutenbird.ino. This code is reliant on Arduino 1.0 features and will not work with Arduino 0023 or earlier.

Place the Thermal and Sha folders inside your Arduino libraries folder. You may need to create this folder if it does not yet exist. In Windows, this would be (home folder)\My Documents\Arduino\Libraries. For Mac, (home)/Documents/Arduino/Libraries. And for Linux, (home)/sketchbook/libraries. We also have a tutorial on library installation.

Place the Gutenbird folder inside your Arduino sketch folder (one level above the libraries folder).

After installing the libraries and sketch, restart the Arduino IDE. You should now be able to access the Twitter sketch by navigating through the menus: File→Sketchbook→Gutenbird

Twitter Setup

Our example application prints an ongoing timeline of live “tweets” from Twitter. Even if you don’t use the Twitter service yourself, you’ll still need to sign up for an account to use the search function in software. If you don’t yet have one, begin at the Twitter homepage and use the sign-up form:
In addition to some basic account information, you’ll need to provide a real email address in order to confirm and activate the account. Within a few minutes you should receive an email with an activation link.

Once you have an account and have logged in, you can then proceed to dev.twitter.com (the Twitter Developers home page). At the top right is a pull-down menu including the option “My applications”:
From this page, select the “Create a new application” button:
You’ll be asked for some basic information about your application — the tweet-printing program we’ll be loading on the Arduino. Provide a reasonable name and description…we don’t know if applications are audited, but being honest and descriptive here would be helpful. You also need to provide a Website URL. If you have a personal or company web site, enter that on the form, else you can use Adafruit’s home page.
You’ll need to agree to the developer terms of service and complete a CAPTCHA before finalizing your application. Read, agree, complete the puzzle and click “Create your Twitter application”:
Once your application is created, there will be a long screen full of information about it (shown abbreviated here). At the bottom of this page, click the button labeled “Create my access token”:
Once you complete these steps, you’ll have the full set of credentials needed to authorize your application. In a moment we’ll copy and paste these four strings into an Arduino sketch: Consumer key, Consumer secret, Access token, and Access token secret.
Do not share these strings with anyone—they’re for the secure and exclusive use of your application. If you’re sharing source code via Github or other management system, remember to remove these before posting the code!

Program Arduino

If using an earlier Arduino Uno “R1” or “R2” board, you might encounter the issue below. If you have a current “R3” board, skip ahead to the “Edit Code…” section.

Gutenbird is a big program, nearly filling the Arduino’s entire program space. We’ve gone to great lengths to help it fit, but if you add a lot of new functionality of your own it may run into an issue…

If the code compiles but fails to upload on an R1 or R2 Arduino Uno, you’re seeing an obscure bug in the board’s bootloader when dealing with very large programs. There are a couple of workarounds for this:

  • FIX 1: If you build a lot of projects and have an Arduino Uno R3 handy, swap it out. Dedicate the R3 board for Gutenbird and use the R2 for the majority of Arduino projects that aren’t quite so demanding. This is the easiest option, if you have the spare board.
  • FIX 2: Update the bootloader on the older Uno using directions on Arduino.cc. A second Arduino is required during the upgrade, and there’s a small risk of “bricking” your R1/R2 board, so this option is best left to advanced users.

Edit Code…

  • You'll now need to edit the Gutenbird sketch to match all your particular settings. First, copy and paste the four authentication strings from your Twitter application page to the corresponding spots in the software, keeping the quotes around them. The order of these strings in the code does not match the order on the Twitter form — be sure to copy each to the correct position!

  • As written, the sketch will search for Tweets originating from Adafruit, but you can change this to any search string supported by the Twitter Search API. Refer to the SEARCH OPERATORS section of the Twitter Developers Documentation for guidance.
  • Edit the Ethernet MAC address to match the value you previously wrote down from the sticker on your Arduino Ethernet board or shield.
  • The code uses DHCP (which dynamically assigns an IP address) by default. If your network doesn't use DHCP, or if you just want to provide a fallback address in case of a problem, edit the IP Address value in the code.
  • If using the Arduino Ethernet board, flip up the front face of the enclosure and connect an FTDI Friend or other USB-to-serial adapter to the programming header on the board. If using an Arduino Uno, use the USB port on the back of the box.

 

  • Select your board type and serial port from the Arduino IDE Tools menu, build the sketch and upload to the board. USB can now be disconnected; the box will operate standalone.
  • Attach Ethernet and power cables to the back of the unit. The other ends should be connected to your network router and the included DC power adapter, respectively.
  • Install a roll of thermal receipt paper in the printer. This is accessed by pulling up the lever to the left side of the paper slot. Install the paper to unroll "underhand" as it passes up through the slot.

  • Press the power button on top — it's somewhat recessed and you'll need to press it in with a fingertip. If everything is working correctly, the green power light should pulse, then shine steadily during network access, and then the most recent Adafruit Tweet will be printed.
  • Once per minute, the printer will contact the Twitter server and print any new Tweets.

Other IoT Printer Software

  • The Internet of Things Assistant is a self-hosted Ruby on Rails-based application that turns your IoT Printer into a handy assistant that will print out snippets of information you tell it to at a certain time of day. For example you could set it to print your unread emails, calendar, and recent tweets at 8am.

Troubleshooting

Note that since this tutorial is archived, Adafruit does not provide any support for the outdated instructions in this guide.

Nothing seems to be working!

First open the front flap and check for any LED power indicator on the Arduino board. If there's no light, the power supply might not be plugged in, or there may be an electrical short in your wiring. Reverse the assembly steps to open the box and check all your wiring.

The green status light comes on but Tweets are never printed

Connect a USB cable and use the Serial Monitor in the Arduino IDE (set the line speed to 57600 baud). The sketch will show its current status at each stage of its operation. Most likely, the network settings will need to be edited.

It might also be a simple paper issue. Open the printer top latch and confirm that thermal paper is loaded and properly fed out the top.

If you turn on green button while holding down the little black button next to the printer's green LED it will do a small print test, that can help determine if you're having printing issues as well.

Help! My printer just prints gibberish!

Hold down the small black button on top of the printer while turning it on. A test page should print showing the font table and some diagnostic information. Look for the line that reads 'BAUDRATE':

Most printers arrive from the factory set for 19200 baud, but a few may be set to 9600. This will not negatively impact the performance of your unit! The speed of the paper through the printer is already much less than this and you will not see any difference…it's strictly a data protocol issue of getting the microcontroller and printer communicating. So, if you do have a 9600 baud printer, you'll need to edit the library fileAdafruit_Thermal.cpp, changing this line:
Download: file
_printer->begin(19200);
to this:
Download: file
_printer->begin(9600);
Recompile and upload the sketch to the Arduino board, and the output should now be legible.
This guide was first published on Jul 29, 2012. It was last updated on Jul 29, 2012.