Pi Thermal Printer
Pi Thermal Printer
Pi Thermal Printer
Guide Contents 2
Overview 4
Parts List 6
Parts List (Pre 2017) 7
Software Prep 10
Installing From the NOOBS Card 10
Overwriting NOOBS with Raspbian Lite 11
Raspberry Pi OS Setup 12
OS Install and First-Time Configuration 12
Configure Wireless Networking 13
Hidden Networks 14
Reboot 14
Raspberry Pi Software Setup 16
Update Packages, Install Libraries and Printer Essentials 16
Install Printer Driver 17
Finish Up 18
Soldering 19
Prepare Wires 19
But my kit didn’t come with any female/female jumper wires! 21
Prepare Button 21
Prepare DC Jack 23
Soldering (Pre 2017) 26
Prepare the T-Cobbler 26
But my kit didn’t come with a T-Cobbler! 26
Prepare Wires 28
Prepare Button 29
Prepare DC Jack 31
Wiring Diagram 34
Solder the Serial Data Cable to the T-Cobbler 34
Solder Remaining Wires to the Cobbler 35
Case Prep 37
Peel and Clean Case Parts 37
Case Assembly: 1 of 2 39
Install Raspberry Pi on Bottom Plate 39
Install Thermal Printer 40
Case Assembly 1 (Pre 2017) 42
Install Raspberry Pi on Bottom Plate 42
Install Thermal Printer 44
Case Assembly: 2 of 2 47
Using “T-Slots” 47
The “Internet of Things” is the idea of pervasive connections between physical objects and the online world. These
connected devices don’t just idly sit around waiting for commands or files…they’re active agents that anticipate your
needs and can push or pull data from the internet.
Our Internet of Things Printer is a small, internet-connected thermal printer that can have a daily weather forecast
ready before you head out in the morning, a puzzle to work on while riding the subway, provide a list of “tweets”
relating to your interests…or any other task you can program!
This second version of the printer is built around the Raspberry Pi, a tiny computer that packs a wallop: more
processing power, more RAM and the potent Linux operating system. The new kit has an easier time handling graphics
and looks super tidy with its wireless networking:
The Internet of Things Printer Project Pack for Raspberry Pi includes the following items:
Not included with the kit, the following tools and items are also needed for assembly and setup:
USB keyboard (and mouse, if installing from NOOBS GUI), maybe a hub as well
Monitor (HDMI or composite) and cable
USB cable: A to micro B (http://adafru.it/592) (for powering Raspberry Pi)
Small screwdriver
Soldering iron and solder
Wire cutter and stripper
A wireless (WiFi) internet access point
Desktop or laptop computer with USB, internet connection and at least one gigabyte of free disk space for
downloading and uncompressing software
Optional: sticky tape, heat-shrink tubing
The (pre-2017) Internet of Things Printer Project Pack for Raspberry Pi includes the following items:
4GB or larger SD card (http://adafru.it/102) (or microSD card with full-size adapter)
SD (or microSD (http://adafru.it/939)) card reader
USB keyboard (and mouse, if installing from NOOBS GUI), maybe a hub as well
Monitor (HDMI or composite) and cable
USB cable: A to micro B (http://adafru.it/592)
Small screwdriver
Soldering iron and solder
Wire cutter and stripper
A wireless (WiFi) internet access point
Desktop or laptop computer with USB, internet connection and at least one gigabyte of free disk space for
downloading and uncompressing software
Optional: sticky tape, heat-shrink tubing
The SD card will remain installed in the device; the remaining parts from this list are needed only during setup.
The software for this project is built upon the Raspbian Lite operating system, a pared-down version of Linux for the
Raspberry Pi.
The current kit comes with a card loaded with NOOBS. This can be used to download and install Raspbian Lite, but we
recommend you overwrite the card so you have the most minimal setup (less things can go wrong!)
When booting the NOOBS card, you’ll briefly see the “rainbow screen” — normally bad news, but it’s okay in this case
— the Pi will then reboot and launch the NOOBS installer menu:
First order of business is to connect NOOBS to a wireless network so software can be downloaded. Use the “WiFi
networks” icon (top center) to set this up. It’s a fairly straightforward WiFi configurator…select a network from the
available list and enter a network password if required.
NOOBS WiFi supports wireless-capable Raspberry Pi boards as well as the “official” Raspberry Pi USB WiFi
adapter. Not all third-party adapters are supported. If this presents trouble, you might use the “Overwriting
NOOBS” directions below instead.
With an internet connection now made, select “Raspbian Lite” from the list of available operating systems. Do NOT
select “Raspbian with PIXEL” — this contains a whole lot of software we do not need or want!
Click the “Install” icon. This will download Raspbian Lite (about 300 megabytes), install it on the SD card and (after
prompting) will reboot into the newly-installed operating system. You can then skip ahead to the “Setup” page.
Start by downloading the latest version of Raspbian Lite from the Raspberry Pi web site (https://adafru.it/fQi).
Do NOT use “Raspbian with Desktop PIXEL” — this contains a whole lot of software we do not need or want! Also, if
you’ve previously downloaded Raspbian Lite for other projects, check if a newer version is available. This project relies
on some recent features!
Here’s a tutorial explaining how to install the Raspbian software on the SD card (https://adafru.it/aYV) (replacing
NOOBS), with links to nice GUI apps for Windows and Mac. The first couple of pages can be skipped, as we’re already
downloading the right software for this project.
If you ever need to restore the NOOBS card to its original state, this guide (https://adafru.it/usd) explains the whole
process.
The case should NOT be assembled yet. Let’s get the system running before sealing it up.
1. Connect a monitor and a USB keyboard to the Raspberry Pi (a mouse is not required).
2. Insert the SD card containing the Raspbian Lite software.
3. Connect a micro-B USB cable to the power connector on the Raspberry Pi.
4. Plug the other end of the USB cable into a power source: a mobile phone charger, a powered USB hub, or
simply a USB port on your computer.
The Raspberry Pi should now boot, and you’ll see the monitor fill with lots of “Unix stuff.” On first boot, the system may
automatically reboot once as part of the setup process. This is normal.
Linux can be daunting to the uninitiated. Don’t worry about messing something up…if all else fails, you can re-
format the SD card and begin again.
Within a minute or so you should get a login prompt. Log in as user “pi” and password “raspberry”. Then enter the
following command for essential system setup:
sudo raspi-config
Use the up/down arrow keys, tab and return/enter to navigate the config menu:
Under “Interfacing Options,” select “Serial.” Turn OFF the login shell over serial, and ENABLE the hardware
serial port. NO and YES, respectively. This is vital!
Do NOT touch “Overclock” or other esoteric settings. Overclocking can wreak havoc with the serial port we’ll
be relying on! Do not overclock.
Tab to "Finish" and press enter, but DO NOT REBOOT YET. We still need to set up the wireless networking. Select
“No” when prompted to reboot. Raspi-config will exit to the command line.
Some configuration files will now be edited. Our examples show the “nano” text editor being used, as it’s
easiest for the uninitiated. Power users can substitute “vi” or their editor of choice.
Delete everything in the file, then enter the below text in instead. Check your spelling, everything’s got to be spot-on!
Then edit the SSID and password lines to reflect your actual network name and password (keeping the double quotes
on both):
country=US
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
ssid="SSID"
psk="YOUR_PASSWORD"
scan_ssid=1
}
Skip ahead to the “Reboot” section below. This next section pertains only to hidden wireless networks.
The network configuration in this case is a fair bit more complicated. And the slightest typo here, even one character,
can prevent the system from joining the network! Again, we strongly recommend using a “broadcast” network, it’s far
easier and less error-prone. But if you must…
Delete everything in the file, then enter the below text in instead. Check your spelling, everything’s got to be spot-on!
Indent the 'network' section using tabs, not spaces. Then edit the ssid and psk (password) lines to reflect your actual
network name and password (keeping the double quotes on both):
ctrl_interface=/var/run/wpa_supplicant
update_config=1
ap_scan=2
eapol_version=1
network={
ssid="my-network-ssid"
scan_ssid=1
mode=0
proto=WPA2
auth_alg=OPEN
pairwise=CCMP
group=CCMP
key_mgmt=WPA-PSK
psk="my-network-password"
}
Reboot
Finally, shut down the system:
Wait for the system to report that it’s halted before disconnecting power. It should take about 30 seconds.
Following shutdown, remove the keyboard (if using a Model A board), insert the WiFi adapter and re-connect power
(keep the monitor attached for now). With a Model B board, you can keep both the keyboard and WiFi adapter
attached until you know the networking is properly configured.
What's nice is Raspbian now comes with Bonjour so you do not need to memorize IP addresses.
If you have Windows, go here and install the Bonjour support (via Apple print support) (https://adafru.it/q1e)
If the wireless connection doesn’t work, unplug the WiFi adapter and connect the keyboard and double-check the
network setup steps above. It might simply be a typo. Correct any mistakes and reboot.
Once WiFi is working, the keyboard and monitor are no longer required. All further configuration can be done remotely
via SSH, if you’ve enabled it in raspi-config.
Further configuration of the Raspberry Pi will take place over the network using SSH, not the keyboard and mouse.
You also don't have access to the serial console so you can only use ssh or logging in over HDMI + Keyboard.
As you can probably figure by now, we have an in-depth SSH tutorial (https://adafru.it/aWc). In summary:
The SSH server should already be enabled on the Raspberry Pi — this was done during the initial raspi-config
setup.
On Mac or Linux systems, you can use a Terminal or xterm window.
For Windows systems, you can download PuTTY (https://adafru.it/aYY).
ssh pi@raspberrypi.local
(If you changed the hostname in raspi-config, use that instead, e.g. iotp.local)
Or — if your computer can’t resolve the “.local” address — try the numeric IP address that you can get from your pi by
typing in hostname -I
ssh pi@10.0.1.10
(Substitute the numeric IP address actually reported by the system during boot.)
You’ll be prompted for a password — either use the password that you set up from raspi-config, or “raspberry” if you
left the default. Additionally, the first time connecting you may be prompted regarding a host key for security…enter Y
(or click Yes) when prompted.
The “update” step refreshes the list of available software packages and takes a couple of minutes.
cd ~
git clone https://github.com/adafruit/zj-58
cd zj-58
make
sudo ./install
Your thermal printer may have arrived with a test page in the box or the paper bay. If not, or if you threw that away,
you can generate a new one by installing a roll of paper and holding the feed button while connecting power.
Look for the baud rate that’s printed near the bottom of the page. This is typically either 9600 or 19200 baud. This is
important…you’ll need to know the correct value for your printer.
You can recreate the test page by holding down the feed button and then powering the printer.
To set up this printer as the system default, we’ll be typing two lines similar to the following (but not necessarily
identical…read on)…
On the first line, change the “baud” value to 9600 or 19200 as required for your printer. The rest of the line should be
typed exactly as it appears above. Likewise for the second line, which needs no changes.
Finish Up
Shut down the system. We'll work on the case and wiring next, then return to the final software configuration later.
After about 30 seconds, you can disconnect the USB power cable.
Remove the SD card and WiFi adapter, and get your soldering iron ready…
Some soldering steps take place close to pieces of the case. Be very careful where you set your soldering iron so as
not to damage the plastic parts! Also watch out for flux spatter.
During the soldering and assembly process, certain parts will become “tethered” together by wires…always pick up
and move these parts together, don’t let pieces hang by the wires…this could damage parts or solder joints.
Prepare Wires
2 Black
1 Red
1 Yellow
1 Green
Prepare Button
Don’t be confused by the colors here. This sequence is three of the jumper wires, not the serial data cable!
LED +
NC (Normally Closed)
NO (Normally Open)
COMMON
LED –
Do not do this with the serial data cable! Use the one-
sided jumper wires.
Repeat with the GREEN wire on the LED + pin and the
YELLOW wire on the NO (Normally Open) pin.
Prepare DC Jack
Strip about 1/4" insulation from the red and black wires
on the power cable and the one-sided jumper wires.
Twist the two red wires together, feed through the large
center leg (+) and solder in place.
Secure the DC jack from the other side with the included
nut. You’ll need to fish the wires through this to get it
into place.
Some soldering steps take place close to pieces of the case. Be very careful where you set your soldering iron so as
not to damage the plastic parts! Also watch out for flux spatter.
During the soldering and assembly process, certain parts will become “tethered” together by wires…always pick up
and move these parts together, don’t let pieces hang by the wires…this could damage parts or solder joints.
Prepare Wires
You should also have five loose wires (two black, one
red, yellow and green). Keep these for later steps.
Prepare Button
This is done using three of the spare pieces of wire, not the serial data cable!
Do not do this with the serial data cable! Use the spare
wire pieces.
Repeat with the GREEN wire on the LED + pin and the
YELLOW wire on the NO (Normally Open) pin.
Prepare DC Jack
Strip about 1/4" insulation from the red and black wires
on the power cable and the spare wires.
Wiring Diagram
In the next few steps, we’ll be connecting components to the Cobbler according to the following diagram:
The wires are inserted from the top side of the board
and soldered on the underside.
After peeling, the parts may have a little bit of paper soot on them from laser cutting. Wiping off may suffice, or they
can be washed with soap and water…but be absolutely certain that everything is completely dry before assembling
components in the case!
Some case pieces are reversible and can be flipped over and installed either way, while others have a specific
orientation. You’ve already been acquainted with a couple of these pieces during the soldering stage. Let’s assign
names to the rest of these parts so we can refer to them in these directions:
Set the printer and top piece face-down and insert the
two brackets and screws. Use a small screwdriver to
secure these in place. Use gentle pressure! Cranking
these down tightly can crack the case.
The enclosure is comprised of seven (7) laser-cut acrylic pieces. The paper backing should already have been peeled
off during the “Preparation” step. If any remains, take care of that now.
Some case pieces are reversible and can be flipped over and installed either way, while others have a specific
orientation. You’ve already been acquainted with some of these pieces during the soldering stage. Let’s assign names
to the rest of these parts so we can refer to them in these directions:
Set the printer and top piece face-down and insert the
two brackets and screws. Use a small screwdriver to
secure these in place. Use gentle pressure! Cranking
these down tightly can crack the case.
With these three pieces now “tethered” by wires, they should always be lifted and moved around as a single unit.
Don’t pull on any of the wires.
Here’s the map of case parts again, as you may need to refer back to it some more:
Using “T-Slots”
The case is assembled using “t-slot” construction, common among laser-cut kits. You’ll notice a couple case parts
(back and center support) have t-shaped slots along their edges. These slots hold nuts, while perpendicular case parts
have holes for a corresponding machine screw.
Let’s start with one of the t-slots at the top. Insert a nut
into the cross part of the “t” and hold it there between
finger and thumb.
We’ll attach this piece to one of the sides. The sides are
interchangeable — there is no right or left — but they do
have a definite top and bottom, front and back.
Repeat the above step with the second nut and screw between these two case pieces.
Make sure the tops of the two parts are aligned. In this
picture the case is being held at an angle to access the
slot…the top of the case faces the bottom-right.
Stand the partial case up on its side and move the top
piece (with button and thermal printer attached) roughly
into position. Don’t fit this into the slots yet, just an
approximate position.
Loosen the two screws at the back of the case 1/2 turn.
Loosen the two front screws so the tip is flush with the
nut.
Lift the side piece and pop the front into place.
Pop!
Install Bottom
Nearly done! The anticipation is deadly…
The end of the data cable with the trimmed plug should
connect to the Pi. See how it makes space for the
adjacent jumper wire?
Make sure all the pins are properly aligned with the
header. If it’s off by one pin in any direction, there’s the
possibility of damaging the board when the power
supply is connected.
Now you can go around the case and tighten each screw. Gently! Just finger pressure plus a fraction of a turn will hold
it firmly. If you crank these down too hard you’ll crack the plastic.
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 apps.twitter.com (https://adafru.it/usB) (the
Twitter Developer App home page). Click "Create new App"
You’ll be asked for some basic information about your application — the tweet-printing program we’ll be loading on the
Raspberry Pi. 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 before finalizing your application. Read, agree, and click “Create
your Twitter application”:
Once you complete these steps and the app is created, you’ll have the credentials needed to authorize your
application. Click on the “Keys and Access Tokens” tab. On the next page of this guide we’ll copy and paste the
“Consumer Key” and “Consumer Secret” strings into a Python script.
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!
Once logged in, install the Adafruit thermal printer library and example code:
Make sure a roll of paper is installed in the printer and the top is securely latched. Then we’ll test all the basic
functionality:
cd Python-Thermal-Printer
python printertest.py
This should progress through different text sizes, styles and formats, as well as barcodes and images.
Get your API secret key, and go ahead and modify the following line in forecast.py and timetemp.py
API_KEY = "YOUR_API_KEY"
python forecast.py
This should now print the current weather and the forecast for NYC, the default location. Change the latitude and
longitude variables too to reflect the location you'd like to get the weather for. I use NASA's site (https://adafru.it/usC)
If this works, also edit the file timetemp.py and make the same change there. This is a different script that prints the
current time and local weather conditions.
nano twitter.py
Copy the Consumer key and Consumer secret strings from the Twitter application page into the corresponding spots,
keeping the quotes around them.
Just below this is the search term. You can change Adafruit to any other valid Twitter account.
queryString = 'from:Adafruit'
Different search types are possible, such as by tag. Refer to the SEARCH OPERATORS section of the Twitter
Developers Documentation (https://adafru.it/aHv) for guidance.
Any search string used by the “Gutenbird” sketch for the original Internet of Things Printer can also be used here.
The “main” script must be run as root (i.e. using “sudo”) because it directly accesses hardware — the GPIO pins for the
button and LED.
Each morning at 6:30 am, the once-daily actions are performed again. You can change this time (or the actions) by
editing the main.py script.
Press control+C to stop the program. We’ll set it up to run automatically when the printer is turned on…
cd /home/pi/Python-Thermal-Printer
python main.py &
If you downloaded or otherwise placed the printer software in a different location, the first line should be changed
accordingly. “sudo” isn’t necessary here because the rc.local script is already run as root.
sudo reboot
After 30 seconds to a minute, you should see the status light come on. After another 30 seconds, the greeting image
should be printed, then the “once daily” functions. After that, the printer will go into Twitter-monitoring mode.
Regular Operation
When the printer is idle, tap the button for the current time and local weather conditions.
Hold the button down to initiate an orderly shutdown. This is always a good idea — you don’t want to just pull the plug
The case I received is tan, not the pretty shade of blue in the pictures.
The case acrylic is covered in adhesive paper to prevent scratches in transit. Pull up one corner with a fingernail,
and the rest should peel cleanly from there. (We get this question a LOT…don’t feel silly for asking!)
I need to diagnose a software or configuration problem, but can’t connect to the Raspberry Pi over WiFi.
The bottom of the case can be unlatched and swings open. Stand the case on its side, connect an HDMI or
composite monitor and a keyboard or USB hub, and you can work with the system like a regular “desktop”
Raspberry Pi to troubleshoot the issue.
Sometimes the paper jams in the printer, especially when printing inverse blocks of text.
Edit the file Adafruit_Thermal.py and look for this line (around line 53):
defaultHeatTime = 60
Replace '60' with a smaller number. Try decreasing it by 10 and repeating until the problem is resolved.
defaultHeatTime = 60