# Mini Thermal Receipt Printers

## Overview

![](https://cdn-learn.adafruit.com/assets/assets/000/001/942/medium800/components_thermalprinter_LRG.jpg?1396777649)

Add printing to any microcontroller project with these very cute thermal printers. Also known as receipt printers, they’re what you see at the ATM or grocery store.&nbsp;Now you can embed a little printer of your own into a project. These printers is ideal for interfacing with a microcontroller, you simply need a 3.3V to&nbsp;5V TTL serial output from your microcontroller to print text, barcodes, bitmap graphics, even a QR code!

These printers use very common 2.25" (58mm) wide thermal paper, available in the Adafruit shop&nbsp;or most office or stationery supply stores. You will also need a 5 Volt to 9 Volt regulated DC power supply that can provide 2 Amps or more&nbsp;during high-current printing&nbsp;—&nbsp;[our 5V 2A power supply will work very nicely](https://www.adafruit.com/products/276).

**[You can pick up a thermal printer pack including printer, paper, power supply and terminal-block adapter in the Adafruit shop!](http://www.adafruit.com/products/600 "Link: http://www.adafruit.com/products/600")**

Of course, we wouldn't leave you with a datasheet and a “good luck!” — this tutorial and matching Arduino library demonstrate the following:

- Printing with small, medium and large text
- **Bold,** &nbsp;<u>underline</u>&nbsp;and inverted&nbsp;text
- Variable&nbsp;line&nbsp;spacing
- Left, center and&nbsp;right justification
- Barcodes in the following standard formats:&nbsp; **UPC A, UPC E, EAN13, EAN8, CODE39, I25, CODEBAR, CODE93, CODE128, CODE11** &nbsp;and&nbsp; **MSI** &nbsp;- with adjustable barcode height
- Custom monochrome bitmap graphics
- How to print a QR code

## Models
Our _[**Mini Thermal Receipt Printer**](https://www.adafruit.com/product/597)_ is a popular choice as it accommodates a [full-length thermal roll (15m/50')](https://www.adafruit.com/product/599), meaning fewer paper changes.&nbsp;It’s also available in a [**starter pack**](https://www.adafruit.com/product/600) that includes a 5V power supply and DC jack adapter.

This model has a **3-pin serial interface** for connecting to 3.3V or 5V microcontrollers or Raspberry Pi.

![components_mini.jpg](https://cdn-learn.adafruit.com/assets/assets/000/117/073/medium640/components_mini.jpg?1671038975)

The [_ **Tiny Thermal Receipt Printer** _](https://www.adafruit.com/product/2751) is a bit more compact, accommodating shorter&nbsp;[10m/33' rolls](https://www.adafruit.com/product/2754).

What’s interesting and **unique to this model** is that it has _both_ a 5-pin serial header and a **USB port** , which can make for easier interfacing on Raspberry Pi.

![components_tiny.jpg](https://cdn-learn.adafruit.com/assets/assets/000/117/074/medium640/components_tiny.jpg?1671039054)

For the most compact and portable situations, the [_ **Nano Thermal Receipt Printer** _](https://www.adafruit.com/product/2752) is smaller still, accommodating a [5m/16' paper roll](https://www.adafruit.com/product/2755).

This one has a **5-pin header** &nbsp;for serial data and power.

![components_nano.jpg](https://cdn-learn.adafruit.com/assets/assets/000/117/075/medium640/components_nano.jpg?1671039078)

For the most peculiar situations not covered above, the&nbsp;[_ **Thermal Printer Receipt Guts** _](https://www.adafruit.com/product/2753) is _just the insides_ of a thermal printer.&nbsp;You will need to design and build an enclosure to mount the hardware and hold a paper roll…in principle, _any length_ roll can then work with this.

This unit has a **5-pin header** for serial data and power.

![components_guts.jpg](https://cdn-learn.adafruit.com/assets/assets/000/117/076/medium640/components_guts.jpg?1671039111)

The thermal paper rolls in the Adafruit shop are BPA-free and ready sized to each of the above units.&nbsp;You can also find compatible 2.25" (58mm) wide thermal paper at many office supply stores,&nbsp;though usually in 80–85 foot (25m) lengths that won’t fit as-is in any of these printers. With some patience you can re-roll these onto an empty spool, cutting when the roll reaches a suitable diameter.

**None of these small thermal printers&nbsp;have a cut feature; pull the finished print against the perforated edge.** The _Thermal Printer Guts_ has no perforated edge; you’ll need to design this into your enclosure.

Primary: 

# Mini Thermal Receipt Printers

## Power

These printers use a thermal head to heat the special receipt paper and draw images and text. That makes them very small — there's no moving ink head — but it means they require a _lot_ of power: **5 to 9 Volts DC** , at least **2 Amps** of current.&nbsp;That means you will need a fairly beefy supply and you&nbsp; **cannot** &nbsp;run it off of USB power. An external adapter is _required!_

![](https://cdn-learn.adafruit.com/assets/assets/000/001/943/medium800/components_5v2A_LRG.jpg?1396777657)

As a baseline, we suggest the [5V 2A power supply in our shop](http://www.adafruit.com/products/276). It provides sufficient power to keep the printer happy, and usually enough overhead to power a modest microcontroller project along with it.

A quick way to connect this to the printer’s red/black power wires is with a&nbsp;[2.1mm jack adapter](http://www.adafruit.com/products/368 "Link: http://www.adafruit.com/products/368"):

![](https://cdn-learn.adafruit.com/assets/assets/000/001/944/medium800/components_poweradapt.jpg?1396777663)

The 5V 2A supply mentioned above is a _baseline._ If using this, you might want to power the microcontroller separately through its USB port, to prevent a brownout condition when the printer is drawing a lot of current.&nbsp;Higher current supplies — [4 Amp](https://www.adafruit.com/product/1466) and [10 Amp](https://www.adafruit.com/product/658)\* — are also available in the shop, bulkier but with ample overhead for both the printer and supporting hardware you might be adding.

The higher current can make for darker printing and quicker, more assertive paper feed. Slightly higher _voltage_ can too — to a point. One should **never exceed 9 Volts** to the printer; 12V or more will permanently damage it! 2A (or more) current is still recommended at these higher voltages. If upcycling a power supply from something else, carefully check the polarity (most, _but not all,_ are “tip positive”) and that the output is DC, _not AC._

A benefit to 5V power is that many dev boards can run from this directly and will regulate to 3.3V if needed; only a single power source is needed. That’s not necessarily true with higher voltages…though some, like the Arduino Uno, _can_ accept 9V through the board’s DC power jack.

_\* The printer will never draw_ anywhere near _this much current, but larger supplies are less susceptible to voltage droop when there’s a sudden demand. Sometimes just a matter of what’s presently in stock without waiting, or what other projects you might want to use this with in the future (e.g. large NeoPixel projects could benefit from the extra capacity of a 4A or 10A 5V supply)._

The **Mini** thermal printer has two 3-pin sockets—one for power, one for serial communication. Power goes to the jack labeled “ **DC&nbsp;IN**.” Only the outer two pins of this connector are used.

![components_small-connections.jpg](https://cdn-learn.adafruit.com/assets/assets/000/117/133/medium640/components_small-connections.jpg?1671137114)

The **Tiny** printer has three sockets: a **2-pin connector for power** , 5-pin for TTL serial communication, and a USB port.

DO NOT attempt powering from the red and black wires of the serial cable. This cable is _not_ following common electronics color conventions and connecting power here may damage the printer! Use ONLY the 2-pin connector for power.

![components_tiny-connections.jpg](https://cdn-learn.adafruit.com/assets/assets/000/117/134/medium640/components_tiny-connections.jpg?1671137258)

The **Nano** printer and “printer guts” have a single 5-pin connector for power and serial data. The outermost&nbsp; **red** and **black** wires are for +V and ground, following typical conventions.

![components_nano-connections.jpg](https://cdn-learn.adafruit.com/assets/assets/000/117/136/medium640/components_nano-connections.jpg?1671137534)

## Making the Power Connection
During initial testing and for quick temporary projects, it’s usually okay to jam [breadboard prototyping wires](https://www.adafruit.com/product/1956) into the end connector on the DC power cable (or power+serial cable on Nano and guts), and the other end to a DC barrel jack adapter.

However, breadboard wires are small gauge and not suited to continuous heavy power draw. Once you’re “moved in” — confident the printer works and will suffice for a project — one option is to cut the DC cable, strip the wire ends and screw these _directly_ to the DC barrel jack, without the breadboard wires as a go-between.

Keep the serial wires intact though. Breadboard wires work splendidly there.

![components_power-proto.jpg](https://cdn-learn.adafruit.com/assets/assets/000/117/138/medium640/components_power-proto.jpg?1671138344)

The most robust option, if you want to get all _fancy,_&nbsp;is to splice a DC jack pigtail to the power cable.

This is not a part we carry. One option is to cut a [DC barrel jack extension cable](https://www.adafruit.com/product/327) in half and use the socket end. Or, the pigtails are commonly used in security camera installations, so you might find something by searching around.

![components_power-permanent.jpg](https://cdn-learn.adafruit.com/assets/assets/000/117/140/medium640/components_power-permanent.jpg?1671139002)

# Mini Thermal Receipt Printers

## First Test

The first test you should do will ensure that paper is loaded and power is wired up correctly and the printer is running.

First up, pull the little plastic tab up top to open up the paper holder. Then insert a roll of 58 millimeter (2 1/4 inch) thermal paper into the bay as shown in the image below.

To reiterate from the first page, the printer models and corresponding roll sizes are:

- **[Mini](https://www.adafruit.com/product/597):** [15m / 50 foot roll](https://www.adafruit.com/product/599)
- **[Tiny](https://www.adafruit.com/product/2751):** [10m / 33'](https://www.adafruit.com/product/2754)
- **[Nano](https://www.adafruit.com/product/2752):** [5m / 15'](https://www.adafruit.com/product/2755)
- **[Guts](https://www.adafruit.com/product/2753):** no paper bay; use any size roll

Make sure that the paper doesn't bind or stick in the bay, it should rotate freely.

![](https://cdn-learn.adafruit.com/assets/assets/000/001/945/medium800/components_insertpaper.jpg?1396777672)

As described on prior page,&nbsp;power the printer using a&nbsp;5V to&nbsp;9V 2A or higher power supply, such as wiring up a 2.1mm DC power jack:

![](https://cdn-learn.adafruit.com/assets/assets/000/001/946/medium800/components_poweradapt.jpg?1396777679)

## Print Test Page

Most of these thermal printers have a test feature providing basic diagnostics. You’ll then know that power is good, paper is correctly loaded, and have some configuration details of the particular unit.

On most **Mini** and **Tiny** printers: **hold down** the button on the top of the printer **while connecting power** to print a test page. In normal use, tapping this button feeds the paper by one line.

On most **Nano** printers and **printer guts** : **connect power first** , then **tap** the button on the control board to print a test page.

_Not all “printer guts” units have a button installed. If needed, you can make a temporary connection across the “J1” pads using a jumper wire or metal tweezers._

Occasional factory production changes occur…if you don’t get a test page using the method above for you model, try the opposite method. A few may even lack a test page feature, but the status LED provides an indication of good power.

![](https://cdn-learn.adafruit.com/assets/assets/000/001/947/medium800/components_testprint.jpg?1396777687)

Info: 

If you don't get a printout, check that the paper is inserted correctly and not binding, that the power is correctly wired, power supply is plugged in, etc. Then try again.

Note the baud rate on the test page. This may be 19200 or 9600. We'll need this number later:

![](https://cdn-learn.adafruit.com/assets/assets/000/001/948/medium800/components_test-baud.jpg?1396777693)

Info: 

# Mini Thermal Receipt Printers

## Making Connections

These printers might see use with **microcontrollers** or with Linux-based computers such as **Raspberry Pi**. The **Tiny** printer has the distinct option of connecting to a Raspberry Pi’s **USB** port, covered later on this page. But to start, let’s talk about&nbsp;_ **TTL serial** _—the non-USB connection present across _all_ of these printers.

## TTL Serial

Most microcontrollers can provide a 3.3V or 5V _TTL serial connection_. It’s not&nbsp;same as the 10V RS232 serial from a computer’s 9-pin serial port — don’t connect the printer directly to a standard PC port or you may damage it. A&nbsp;_USB-to-serial cable_&nbsp;(such as those made by FTDI, or similar) is an option on Linux PCs, but most will be using it with a microcontroller.

It **makes no difference** if the controller is a **5 Volt** or **3.3 Volt** device. The printer logic is 3.3V, but “5V tolerant,” meaning **no extra level-shifting circuitry is needed** in either direction. Some older documentation may still show a _voltage divider_ (two resistors and some extra wires), but that’s since been found unnecessary. The printer and 5V _or_ 3.3V devices can connect directly.

To start, we’ll connect to the data cable of the printer. Easiest is to simply press breadboard jumper wires into the data plug, then use those to extend the connection to the host: an Arduino or other microcontroller, Raspberry Pi, or USB-to-serial cable.

If the controller is on a **breadboard** or the **socket headers** along the edges of an Arduino Uno-like board, or with most **USB-to-serial** cables: **male/male** jumper wires are suitable.

If the controller is a **Raspberry Pi** : use **female/male** jumper wires to the Pi’s GPIO header.

The **wire color for each pin** is **_not_ the same** across all these printers. Please read the descriptions carefully.&nbsp;It’s _nice_ (but not _mandatory_) to match jumper wire colors to the printer’s data cable, to help keep track of things.

![](https://cdn-learn.adafruit.com/assets/assets/000/117/148/medium800/components_jumper-to-socket.jpg?1671212407)

## For Product #597: “Mini”

The **Mini** printer data cable has three wires:

- Black =&nbsp; **GROUND** reference
- Yellow = data **IN** to the printer (RX)
- Green = data **OUT** of the printer (TX)

This is in addition to the separate power cable, described on the prior page.

## For Product #2751: “Tiny”

The **Tiny** printer data cable has **five** wires:

- Red =&nbsp; **GROUND** (yes, red, and yes this totally is the opposite of common electronics conventions)
- Green = data **IN** to the printer (RX)
- Blue = data **OUT** of the printer (TX)
- Yellow (DTR) and black can be left **unconnected**

This is in addition to the separate power cable, described on the prior page.

## For Product #2752: “Nano”

The&nbsp; **Nano** printer cable has **five** wires and _no_&nbsp;separate power cable.

- Black = power _and_ signal&nbsp; **GROUND**
- Blue = data **IN** to the printer (RX)
- Green = data **OUT** of the printer (TX)
- Red = 5–9V DC power
- Yellow = DTR, can be left unconnected for now

Power and data share a single connector here. Ground must go to _both_ the power supply _and_ the microcontroller, meaning you’ll need a split here, perhaps using a breadboard’s power rail.

## For Product #2753: “Guts”

The **Printer Guts** &nbsp;cable has **five** wires and no separate power cable.

Some printers have a color-coded cable, while others have&nbsp;just have a plain white cable. Unplug this temporarily from the printer and you should find the pin functions **labeled on the PCB** :

![](https://cdn-learn.adafruit.com/assets/assets/000/029/179/medium800/components_2753-04.jpg?1450470643)

The pin order here is **not the same** as the Tiny or Nano printers. And if you have both Guts and Nano printers, be _super careful_ about the wiring, because the plugs are interchangeable but the sequence of wires and colors (if any) _do not_ have the same functions!

- **VH** = 5–9V DC power
- **GND** = power _and_ signal&nbsp; **GROUND**
- **RX** on the PCB&nbsp;= data **IN** to the printer
- **TX** on the PCB&nbsp;= data **OUT** of the printer
- **DTR** on the PCB = can leave unconnected for now

As with the Nano printer, power and data share a single connector. Ground must go to _both_ the power supply _and_ the microcontroller, meaning you’ll need a split here, perhaps using a breadboard’s power rail.

## To Arduino
For a board like the **Arduino Uno** , the other end of the jumper wires can insert into the **board edge sockets**. For smaller devices on a&nbsp; **breadboard** , insert into the corresponding **contact strip**.

**Ground** from the printer always connects to **GND** on the microcontroller board. For the data wires ( **TX** and **RX** ), which pins to connect to can vary by hardware and software, explained further on subsequent pages. Some situations may require specific pins, but you can usually use any two pins.&nbsp;Here’s the printer’s TX line connected to digital pin 5, and RX to digital pin 6:

![](https://cdn-learn.adafruit.com/assets/assets/000/117/149/medium800/components_jumpers-to-arduino.jpg?1671212539)

Warning: 

## To Raspberry Pi
Before connecting any **TTL serial** printers to **Raspberry Pi** , it’s _vitally important_ to perform a little **system configuration** first.

The Raspberry Pi board has a TTL serial connection on the GPIO breakout header. By default, it’s configured for a _serial console_ — connected to a terminal, this provides another way to log into the system (along with Ethernet, WiFi or keyboard+monitor).&nbsp;We need to **turn off** the serial console behavior, or a connected printer will just spit out endless gibberish! This only applies to a **TTL serial** connection; **Tiny** printers using **USB** , or others when using a&nbsp; **USB-to-serial** adapter, don’t need this step.

If using a **desktop** OS (mouse and GUI), it’s just a few clicks.&nbsp;From the “Pi” menu at the top left, select **Preferences→Raspberry Pi Configuration…**

Select the **Interfaces** tab.

Turn **Serial Port _ON_** _,_ and **Serial Console _OFF_** _,_ as shown in the image.

Click the “ **OK** ” button, then “ **Yes** ” when asked whether to reboot

![components_pi_a___b___2__3_pi-config.png](https://cdn-learn.adafruit.com/assets/assets/000/117/154/medium640/components_pi_a___b___2__3_pi-config.png?1671214340)

![components_pi_a___b___2__3_pi-config-serial.png](https://cdn-learn.adafruit.com/assets/assets/000/117/155/medium640/components_pi_a___b___2__3_pi-config-serial.png?1671214353)

If a “ **lite** ” OS (text login), this is done from the command line:

```terminal
sudo raspi-config
```

You’ll find the Serial Port settings under “ **Interface Options**.” Select “ **No** ” for the login shell, and “ **Yes** ” if asked about the serial port hardware (this option might not show up on older Pi models, where it’s always on). Tab over to “ **Finish** ” and reboot when asked.

_Now_ the printer can be connected without making a mess.

The diagram at left shows the Pi’s GPIO header. For orientation reference, the 5V pin at the top right is nearest the corner of the board.

TX and TXD mean the same thing: _transmit_ or _transmit data._ Likewise with RX and RXD. The terms might get used interchangeably.

![components_raspberry_pi_gpio-diagram.png](https://cdn-learn.adafruit.com/assets/assets/000/117/151/medium640/components_raspberry_pi_gpio-diagram.png?1671212601)

 **TX** and **RX** from the printer go to specific GPIO pins with _opposite_ functions. TX to RX and RX to TX, known as a _crossover_ configuration:

![](https://cdn-learn.adafruit.com/assets/assets/000/117/150/medium800/components_printer-to-pi.png?1671212562)

Really you can use _any_&nbsp;GND shown in the pinout diagram above. The third pin is easy to locate, but that spot’s sometimes occupied by other hardware like small cooling fans.

If you happen to be using the **Mini** printer with the 3-pin data cable, and if the Pi and printer are kept close together, you might not even need jumper wires. Skip the first two 5V pins on the GPIO header, and the data cable can press right on to the next 3 pins in sequence: GND, TX and RX.

![components_pi_a___b___2__3_pi-printer-to-header.jpg](https://cdn-learn.adafruit.com/assets/assets/000/117/152/medium640/components_pi_a___b___2__3_pi-printer-to-header.jpg?1671212621)

## To USB-to-Serial Cable (FTDI, etc.)
The principle here is similar to Raspberry Pi above: create a _crossover_&nbsp;by connecting the printer’s TX to the adapter cable’s RX pin, RX to TX, and ground to ground.

The diagram here is representative, not literal. Some adapter cables might have this pinout, but others will not. FTDI cables, for example, usually have a 6-pin header with its own color code; only 3 pins are needed here. You’ll find pin functions and colors in the specific cable’s documentation.

![](https://cdn-learn.adafruit.com/assets/assets/000/117/153/medium800/components_printer-to-ftdi.png?1671212643)

Any of these cables will require _device driver_ software. Popular ones (FTDI, Prolific, etc.) might already be present on Linux systems. Check documentation.

Also, _how_ the device manifests when connected to a computer’s USB port will vary among manufacturers and drivers. In Linux it might show as `/dev/tty.USBserial` (followed by a number), but other conventions are sometimes used.&nbsp;Skim through the `/dev` directory and/or try the `lsusb` command to help identify the device.

## “Tiny” Printer: USB to Linux (Raspberry Pi, etc.)

The **Tiny** printer has the lovely option of connecting via USB cable, no jumper wires needed. On Raspberry Pi, there’s _no need_ to change anything with raspi-config…but there _are_ some things to know about the system.

On current Tiny printers, and on earlier ones _when suitably configured,_ the printer appears to the system as **/dev/usb/lp0** &nbsp;and operates through the _USB printing subsystem._ Sometimes there will be a different number at the end, if more printers are attached.

On earlier Tiny printers, the factory configuration instead has it appear as **/dev/ttyUSB0** , which mimics a Prolific _USB-to-serial bridge.&nbsp;_Sometimes there will be a different number at the end, if other USB-to-serial devices are attached.

Any software or commands that want to issue data to the printer should speak to the appropriate device name (try `ls /dev` from the command line to see what’s present, or try `lsusb`). Project code will often have the system device name in a global variable somewhere. Aside from that difference, they should both function the same; open the device, issue data, printer prints it.

If you have an older Tiny printer (defaulting to _USB-to-serial bridge_) and specifically _require_ USB printing subsystem compatibility instead, there’s a way to switch it over:

1. Similar to the self-test, **hold** the **paper feed button** while applying power…but now&nbsp;_ **keep holding it.** _
2. After the QR code, the current USB mode is printed: this will either be **COM** (USB-to-serial mode, the default) or **Printable Port** (USB printing subsystem).
3. **Release** the paper feed button.
4. To **keep** the current setting, **tap** the paper feed button once more.
5. To **change** to to the opposite USB setting (COM or Printable Port), **hold** the feed button for at least **2 seconds**. The printer will confirm the change.

![](https://cdn-learn.adafruit.com/assets/assets/000/117/145/medium800/components_printer_mode_change.jpg?1671161191)

This is present only&nbsp;in older Tiny printers. Current units work strictly in USB printing subsystem mode—it’s considered more modern—and continuing to hold the paper feed button will just eject a lot of paper…so don’t.

# Mini Thermal Receipt Printers

## Arduino Code

Connections are explained on the prior page. For the Arduino example code, we’ll connect the printer’s data out (TX) wire to digital pin 5, and data in (RX) to digital pin 6. Ground can go to any Arduino GND pin. Pins are configurable, but this is what the example uses, so let’s stick with that for now.

On the Arduino side, pin 5 _receives_ (RX) and 6 _transmits_ (TX)…opposite of the printer’s pin functions…called a _crossover_ configuration, something you’ll hear a lot in serial communication and networking.

![](https://cdn-learn.adafruit.com/assets/assets/000/117/156/medium800/components_jumpers-to-arduino.jpg?1671217204)

## Install Library

We made an [Arduino library to assist working with these printers](https://github.com/adafruit/Adafruit-Thermal-Printer-Library).

Go to the _Arduino Library Manager_ under **Sketch→Include…Library→Manage…Libraries…**

![](https://cdn-learn.adafruit.com/assets/assets/000/049/608/medium800/components_managelib.png?1513997151)

Search for and install the&nbsp; **Adafruit Thermal Printer** library:

![](https://cdn-learn.adafruit.com/assets/assets/000/049/609/medium800/components_themal.png?1513997206)

We also have a great tutorial on Arduino library installation at:  
[http://learn.adafruit.com/adafruit-all-about-arduino-libraries-install-use](http://learn.adafruit.com/adafruit-all-about-arduino-libraries-install-use "Link: http://learn.adafruit.com/adafruit-all-about-arduino-libraries-install-use")

You should now be able to access the sample code by navigating through menus in this order: **File→Sketchbook→Libraries→Adafruit\_Thermal→A\_printertest**

![](https://cdn-learn.adafruit.com/assets/assets/000/029/177/medium800/components_thermaltest.png?1450468458)

 **If your printer test page shows 'BAUDRATE: 9600', you'll need to make a small change to the library source code.** &nbsp;Using a text editor (Notepad, etc.) open&nbsp;the file Adafruit\_Thermal.cpp and change this line:

```auto
#define BAUDRATE  19200
```

to this:

```auto
#define BAUDRATE  9600
```

Some printers arrive from the factory set for 19200 baud, but a few may be set to 9600. This will&nbsp;_not_&nbsp;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.

OK upload the sketch (with baudrate change if necessary) to the Arduino. You should see the printer print out the example receipt which includes all the capabilities of the library.

![](https://cdn-learn.adafruit.com/assets/assets/000/001/951/medium800/components_printdemo.jpg?1396777717)

If this does not work, first check that the printer and Arduino are both powered, and that the data in, out and ground wires are properly connected to the Arduino.

# Mini Thermal Receipt Printers

## Printing Text

![](https://cdn-learn.adafruit.com/assets/assets/000/001/952/medium800/components_printdemo.jpg?1396777724)

The thermal printer has a few handy things it can do, most of which are in the **A\_printertest** &nbsp;sketch. These are shown in the image above. In order, starting from the top:

- Inverted text:&nbsp;this is invoked by calling&nbsp;**inverseOn()**&nbsp;— you will get text that’s white-on-black instead of black-on-white.&nbsp;**inverseOff()&nbsp;**turns this off.
- Double height: this makes text thats extra tall, call&nbsp;**doubleHeightOn()**&nbsp;—&nbsp;likewise, turn off with&nbsp;**doubleHeightOff()**
- Left/Center/Right justified: this aligns text to&nbsp;the left or right edge of the page, or centered. You can set the alignment by calling&nbsp;**justify('R')&nbsp;**(for right-justified),&nbsp;**justify('C')&nbsp;**(for centered) or&nbsp;**justify('L')&nbsp;**(for left-justified). Left-justified is the default state.
- **Bold** text: makes it stand out a bit more, enable with&nbsp;**boldOn()**&nbsp;and turn off with&nbsp;**boldOff()**
- Underlined text: makes it stand out a bit more, enable with&nbsp;**underlineOn()**&nbsp;and turn off with&nbsp;**underlineOff()**
- Large/Medium/Small text: by default we use small, medium is twice as tall, large is twice as wide/tall. Set the size with&nbsp;**setSize('L')**,&nbsp;**setSize('M')**&nbsp;or&nbsp;**setSize('S')**
- Line spacing: you can change the space&nbsp;_between&nbsp;_lines of text by calling&nbsp;**setLineHeight()**&nbsp;where&nbsp; **numpix** &nbsp;is the number of pixels. The minimum is 24 (no extra space between lines), the default spacing is 32, and double-spaced text would be 64.

Look through the source of the A\_printertest sketch to see these used in context.

# Mini Thermal Receipt Printers

## Bitmap Printing

This printer can produce bitmaps, which can add a touch of class to a receipt with your logo or similar.

The first step is to get the image prepared. The printer can only do monochrome (1-bit) images, and the maximum width is 384 pixels.&nbsp;We suggest starting with a small bitmap (100 pixels or less on each side) and then experimenting to get the size and look you want.

A few steps are required to prepare an image for printing. For Windows users, there’s a nice graphical user interface for this. For Mac and Linux, different tools are used…not as visually slick, but they do the job well.

Danger: 

## Windows
Use an image editing program to save your image as a 1-bit BMP — in Windows, the built-in&nbsp; **Paint** &nbsp;program will suffice.  
  
Download, install and run **[LCD Assistant](http://en.radzio.dxp.pl/bitmap_converter/)**. This program is for Windows only but does a really fantastic job! Load the BMP file you previously generated (in Paint, etc.). The file&nbsp;<u>must</u> be in BMP format — the software won’t read PNG, GIF, etc. Then a couple of settings need to be adjusted…

![](https://cdn-learn.adafruit.com/assets/assets/000/001/955/medium800/components_lcd-assistant.png?1396777773)

First, in the “Byte orientation” section of the settings, select “Horizontal” (item A in the image above).  
  
Second (item B above), you may need to change the Width setting.&nbsp;Because this software (and the thermal printer) handle images in horizontal groups of eight&nbsp;pixels, if the image width is not a multiple of 8, it will be truncated (cropped) to the nearest smaller 8-pixel boundary. For example, with the 75 pixel wide image above, the output will be cropped to only 72 pixels wide, losing some data from the right edge.&nbsp;To avoid this, **increase this number to the next multiple of 8** (that would be 80 for the example above), and the output will be padded with blank pixels to cover the gap. Remember the number you use here, you’ll need it later.  
  
The image height does not need to be adjusted this way, only width.  
  
Set the table name to something short but&nbsp;descriptive (e.g. “adalogo” above), then select Save Output from the File menu. Give the file a similarly brief but descriptive name, ending in “.h” (e.g. “adalogo.h”).  
  
To get this file into your Arduino sketch, select “Add File…” from the Sketch menu. This will add a new tab to your code. Your original code is still there under the leftmost tab.  
  
A couple of small changes are now needed in both tabs. First, at the top of the&nbsp;file containing the new table data, change “const unsigned char” to “static const uint8\_t PROGMEM” as shown below:

![](https://cdn-learn.adafruit.com/assets/assets/000/026/979/medium800/components_progmem.png?1438715537)

Next, in the tab containing the main body of your code, add an “include” statement to reference the new file:

```auto
#include "adalogo.h"
```

Check the **A\_printertest** example sketch if you’re not sure how to include the code properly.

You can now output the image by calling **printBitmap(width, height, tablename)**, where **width** and **height** are the dimensions of the image in pixels (if you changed the image width to a multiple of 8 as previously described, use that number, not the original image size), and **tablename** is the name of the array in the new tab (e.g. “adalogo” above).

![](https://cdn-learn.adafruit.com/assets/assets/000/001/957/medium800/components_bitmap-print.jpg?1396777794)

Having a graphical user interface is nice, but some of these extra steps can be confusing and error-prone. If you prefer, the technique below for Mac and Linux works in Windows as well.

## Mac and Linux
The conversion tool for Mac and Linux doesn’t include a fancy GUI, but it works well and avoids several steps (and potential mis-steps). The source image doesn’t need to be in BMP format — most image formats can be read natively — and the output can be added to a sketch with no&nbsp;further editing. It works for Windows as well, if you’d rather use this method.  
  
First, if you don’t already have the **Processing** language installed, [download it from processing.org](http://processing.org). Processing&nbsp;looks almost exactly like the Arduino IDE, but it’s for writing code for your normal computer, not a microcontroller. This can be a little confusing to first-timers, so if something doesn’t seem to compile, make sure you’re running code in the right environment: _Arduino_ for for the Arduino board, _Processing_ for your computer.

Danger: 

The Adafruit\_Thermal library folder that you previously downloaded contains a sub-folder called&nbsp; **processing**. Inside that is a sketch called&nbsp; **bitmapImageConvert.pde**. Load this into Processing and press RUN (the triangle button).  
  
You’ll be prompted to select an image using the system’s standard file selection dialog. The program runs for just a brief instant, and will create a new file alongside the original image file. For example, if you selected an image called “adalogo.png”, there will be a new file called “adalogo.h” in the same location. This file contains code to add to your Arduino sketch. You shouldn’t need to edit this file unless you want to change the variable names within.  
  
To get this file into your Arduino sketch, select “Add File…” from the Sketch menu. This will add a new tab to your code. Your original code is still there under the leftmost tab.  
  
Next, in the tab containing the main body of your code, add an “include” statement to reference the new file:

```auto
#include "adalogo.h"
```

Check the&nbsp; **A\_printertest** &nbsp;example sketch if you’re not sure how to include the code properly.

If the source image was called adalogo.png, then the resulting .h file (adalogo.h) will contain three values called adalogo\_width, adalogo\_height and adalogo\_data, which can be passed directly and in-order to the printBitmap() function, like this:

```auto
printBitmap(adalogo_width, adalogo_height, adalogo_data);
```

# Mini Thermal Receipt Printers

## Barcode Printing

Thermal printers are really good at printing barcodes! This printer supports 11 different codes -&nbsp; **UPC A, UPC E, EAN13, EAN8, CODE39, I25, CODEBAR, CODE93, CODE128, CODE11** &nbsp;and&nbsp; **MSI**. It only supports linear (1-D) barcodes, and can’t generate 2-D barcodes like QR codes (although there is a hack you can do, see below!) Barcodes are generated “on the fly,” which is nice — you can customize the height and data included quite easily.

You can make a barcode by calling&nbsp;**printBarcode("barcodedata", BARCODETYPE)**,&nbsp;where the first string is the data to encode (e.g. a&nbsp;UPC code)&nbsp;and&nbsp; **BARCODETYPE** &nbsp;can be&nbsp; **UPC\_A, UPC\_E,&nbsp;**** EAN13, EAN8, CODE39, I25, CODEBAR, CODE93, CODE128, CODE11 **&nbsp;or&nbsp;** MSI**.

Some barcodes are very restricted — you can only put in 12 numbers, no characters. Others are very flexible and take nearly any character input.[&nbsp;Please check out the wikipedia list detailing kinds of barcodes&nbsp;](http://en.wikipedia.org/wiki/Barcodes#Linear_barcodes "Link: http://en.wikipedia.org/wiki/Barcodes#Linear\_barcodes")to pick the right one for your application.

The available range of barcodes varies with the printer firmware revision. Check Adafruit\_Thermal.h for a list of codes.

It’s also possible to print QR codes, if you’re willing to pre-generate them. This might be handy if you want to, let’s say, include a URL on the receipt and the URL doesn’t change.&nbsp;[You can generate QR codes at many sites including this one.](http://qrcode.kaywa.com/ "Link: http://qrcode.kaywa.com/")&nbsp;Use the smallest QR code size. The image will be in PNG format, so if you’re using the Windows LCD Assistant tool you’ll need to convert it to BMP first (Windows Paint works for this). Then you can convert and embed this in your Arduino sketch as previously described.

&nbsp;

![](https://cdn-learn.adafruit.com/assets/assets/000/001/958/medium800/components_qr-code.jpg?1396777795)

# Mini Thermal Receipt Printers

## CircuitPython and Python

It's easy to use the thermal printer with CircuitPython (or Python [via the _Blinka_ library](https://circuitpython.org/blinka)) and the&nbsp;[Adafruit CircuitPython Thermal Printer](https://github.com/adafruit/Adafruit_CircuitPython_Thermal_Printer)&nbsp;module. This module allows you to easily write Python code that controls the printer, like printing text and barcodes (note right now bitmap printing is **not** supported by CircuitPython code).

 **Wiring is explained on the “Making Connections” page.**

On **Raspberry Pi** , a common choice is to use the board’s **GPIO** pins to connect to the printer’s **TTL serial** port. Also on Pi, and on most other **computer** (not microcontroller) situations, there’s the **USB port** on the Tiny printer, or using a **USB-to-serial** or FTDI cable.&nbsp;[Please visit the guide for CircuitPython on Linux to see whether your platform is supported](https://learn.adafruit.com/circuitpython-on-raspberrypi-linux).

## CircuitPython Installation of Thermal Printer Library

If you're using a CircuitPython microcontroller, you'll need to install the&nbsp;[Adafruit CircuitPython Thermal Printer](https://github.com/adafruit/Adafruit_CircuitPython_Thermal_Printer)&nbsp;library on your CircuitPython board.

First make sure you are running the&nbsp;[latest version of Adafruit CircuitPython](../../../../welcome-to-circuitpython/installing-circuitpython)&nbsp;for your board.

Next you'll need to install the necessary libraries&nbsp;to use the hardware--carefully follow the steps to find and install these libraries from&nbsp;[Adafruit's CircuitPython library bundle](https://github.com/adafruit/Adafruit_CircuitPython_Bundle).&nbsp; Our introduction guide has&nbsp;[a great page on how to install the library bundle](../../../../welcome-to-circuitpython/circuitpython-libraries)&nbsp;for both express and non-express boards.

You can also download the&nbsp; **adafruit\_thermal\_printer** folder&nbsp;from&nbsp;[its releases page on Github](https://github.com/adafruit/Adafruit_CircuitPython_Thermal_Printer/releases).

Copy the **adafruit\_thermal\_printer** folder into the CircuitPython drive’s **lib** directory. Place the _whole&nbsp;folder itself_ there, _not_ the individual files within.

![](https://cdn-learn.adafruit.com/assets/assets/000/117/157/medium800/components_printer-circuitpy-contents.png?1671223883)

## Python Installation of Thermal Printer Library
If you're using a Raspberry Pi or other computer with Python, you'll need to install the Adafruit\_Blinka library that provides the CircuitPython support in Python. This may require verifying you are running Python 3. [Since each platform is a little different, and Linux changes often, please visit the CircuitPython on Linux guide to get your computer ready](https://learn.adafruit.com/circuitpython-on-raspberrypi-linux)!

Once that's done, from your command line run the following command:

```terminal
sudo pip3 install adafruit-circuitpython-thermal-printer
```

## Firmware Version and Baud Rate

Before you can use the printer module you must determine the firmware version and baud rate of the printer.&nbsp; This is easy to find out by printing a test page from the printer as described on the [“First Test” page](../../../../mini-thermal-receipt-printer/first-test), hold the printer button as power is applied.&nbsp; Print out the test page and take note of these values printed at the bottom:

- **Baudrate** - Remember this value, typically 19200 or 9600.
- **Version** - Take note of this value too, it's a value like 2.2, 2.64, 2.68, etc.&nbsp; You will use the version to pick the appropriate module for interacting with the printer.

![](https://cdn-learn.adafruit.com/assets/assets/000/049/602/medium800/components_testprint.jpg?1513987053)

## Usage

If you're using a CircuitPython microcontroller, [connect to the board's serial REPL&nbsp;](../../../../welcome-to-circuitpython/the-repl)so you are at the CircuitPython&nbsp; **\>\>\>** &nbsp;prompt.&nbsp; If you're using a computer like the Raspberry Pi, bring up a REPL at the command prompt by typing `python3`.&nbsp; (On some systems, `python` may run Python 3 - just make sure you're not using Python 2, as it isn't supported.)

To demonstrate the usage of the sensor we'll initialize it and print some text from the REPL.

First you must import the necessary modules to initialize the hardware serial connection to the printer.&nbsp; These commands will vary depending on your hardware - choose the appropriate set:

```python
# On a CircuitPython microcontroller:
import board
import busio
uart = busio.UART(board.TX, board.RX, baudrate=19200)
```

```python
# On the Raspberry Pi with built-in UART:
import serial
uart = serial.Serial("/dev/serial0", baudrate=19200, timeout=3000)
```

```python
# On the Raspberry Pi with the USB-to-serial converter:
import serial
uart = serial.Serial("/dev/ttyUSB0", baudrate=19200, timeout=3000)
```

```auto
# On the Raspberry Pi with recent Tiny printers on USB:
import serial
uart = serial.Serial("/dev/usb/lp0", baudrate=19200, timeout=3000)
```

Notice the baud rate of the serial connection is specified with the **baudrate** keyword.&nbsp; For most printers they'll use a rate of 19200 baud, however other printers might be configured to use a different rate like 9600 baud.&nbsp; **Use the baud rate you saw printed on the test page of your printer!**

Also be aware CircuitPython currently requires bi-direction UART connections so even if you don't have the board RX pin hooked up (as recommended) you **must** keep the RX pin disconnected and ignore using it in your project.

## Create ThermalPrinter Class

Next you'll need to import the thermal printer module and call a function to get the right class depending on the version of your printer firmware. &nbsp; **Be sure you've found the exact version number for your printer by following the steps mentioned above and on the previous test page!**

```auto
import adafruit_thermal_printer
ThermalPrinter = adafruit_thermal_printer.get_printer_class(2.69)
```

Notice you call the `get_printer_class` function from within the `adafruit_thermal_printer` module. &nbsp;You must pass this function the version of the thermal printer that you're using and it will internally find the right class to import and use in your code. &nbsp;In this example we're specifying a printer with version 2.69 firmware, but be sure to specify your printer's version!

The result is a class which you can immediately initialize:

## Initialize ThermalPrinter

Now construct an instance of the `ThermalPrinter` class:

```auto
printer = ThermalPrinter(uart)
```

Notice you must pass in the serial UART connection that was previously constructed.

Be aware it will take from a half to even 5 seconds for the printer to be created and initialize itself and warm up. &nbsp;You can optionally specify `auto_warm_up=False` as a keyword and manually call the `warm_up` function to control when this warm-up time occurs if needed in your application (or you are confused why your code takes so long to start up).

## Test Page Print

Now you're ready to print!

Try printing a full test page with the `test_page` function:

```auto
printer.test_page()
```

You should see the printer test page print out.

You can advance the paper forward a number of lines with the `feed` function, try feeding 2 lines to make some space:

```auto
printer.feed(2)
```

Now print a small line of text with the `print` function and feed a few lines to move it out of the printer to read:

```auto
printer.print('Hello from CircuitPython!')
printer.feed(2)
```

![](https://cdn-learn.adafruit.com/assets/assets/000/049/603/medium800/components_IMG_20171222_160825308.jpg?1513988858)

## Printer Fonts

There are a few properties you can use to adjust how text is printed.&nbsp; Each of these can be set to a `True` value to enable, or a `False` value to disable:

- `bold` - Print bold text.
- `inverse` - Print inverted (white on black) text.
- `upside_down` - Print upside down text (might not work on all versions of printers).
- `double_height` - Double height size text.
- `double_width` - Double width size text.
- `strike` - Strike-through text (again might not work on all versions of printers).

Try turning on bold text and printing a line:

```auto
printer.bold = True   # Turn on bold
printer.print('This is bold text!')
printer.bold = False  # Turn off bold
# Feed lines to make visible:
printer.feed(2)
```

![](https://cdn-learn.adafruit.com/assets/assets/000/049/604/medium800/components_IMG_20171222_161932763.jpg?1513988869)

There are a few properties you can set to special values to further control text printing:

- `underline`&nbsp;- This controls underline printing and can be None (off), `adafruit_thermal_printer.UNDERLINE_THIN`, or `adafruit_thermal_printer.UNDERLINE_THICK`.
- `size` **-** This controls the size of text and can be `adafruit_thermal_printer.SIZE_SMALL` **,** `adafruit_thermal_printer.SIZE_MEDIUM` **,** or` adafruit_thermal_printer.SIZE_LARGE` **. &nbsp;** The default is small.
- `justify` **-** This controls the justification or location of printed text and can be `adafruit_thermal_printer.JUSTIFY_LEFT` **,** `adafruit_thermal_printer.JUSTIFY_CENTER` **,** or `adafruit_thermal_printer.JUSTIFY_RIGHT` **. &nbsp;** The default is justify left.

For example to print thick underlined, medium text, with center justification:

```auto
printer.underline = adafruit_thermal_printer.UNDERLINE_THICK
printer.size = adafruit_thermal_printer.SIZE_MEDIUM
printer.justify = adafruit_thermal_printer.JUSTIFY_CENTER
printer.print('Medium center!')
# Reset back to normal printing:
printer.underline = None
printer.size = adafruit_thermal_printer.SIZE_SMALL
printer.justify = adafruit_thermal_printer.JUSTIFY_LEFT
# Feed lines to make visible:
printer.feed(2)
```

![](https://cdn-learn.adafruit.com/assets/assets/000/049/605/medium800/components_IMG_20171222_161851022.jpg?1513988886)

## Print Barcodes

Finally you can print a barcode with the `print_barcode` function.&nbsp; Each printer supports a different type and format of barcode so consult the product sheet in the downloads section for each type.&nbsp; However here's an example of printing a UPC A barcode with value '123456789012':

```auto
printer.print_barcode('123456789012', printer.UPC_A)
printer.feed(2)
```

![](https://cdn-learn.adafruit.com/assets/assets/000/049/606/medium800/components_IMG_20171222_162151771.jpg?1513988906)

The first parameter to `print_barcode` is a string that defines the barcode value (this varies depending on the type of barcode, a UPC A code is 13 digits).&nbsp; The second parameter is the type of the barcode, which again is dependent on the printer firmware.&nbsp; Typical values you might use include:

- `printer.UPC_A`
- `printer.UPC_E`
- `printer.EAN13`
- `printer.EAN8`
- `printer.CODE39`
- `printer.ITF`
- `printer.CODABAR`
- `printer.CODE93`
- `printer.CODE128`

## Check Paper

With some printers (not all, and it varies among firmware releases), if you've connected the RX pin of your board to the printer TX, **&nbsp;** you can query paper status with the `has_paper` function that returns `True` or `False` if there is paper present:

```auto
printer.has_paper()
```

![](https://cdn-learn.adafruit.com/assets/assets/000/049/607/medium800/components_Screen_Shot_2017-12-22_at_4.37.31_PM.png?1513989477)

That's all there is to using the thermal printer with CircuitPython!

A complete demo of the usage is in the [thermal\_printer\_simpletest.py demo in the library](https://github.com/adafruit/Adafruit_CircuitPython_Thermal_Printer/blob/master/examples/thermal_printer_simpletest.py).

Warning: 

On the Raspberry Pi, comment out the `uart = busio(...)` line, and uncomment the `import serial` and `uart = serial.Serial(...)` lines, changing `/dev/ttyUSB0` to the appropriate serial port.

Unless you used a voltage divider to hook up the printer TX line, make sure you comment out the paper check code:

```auto
# Check if the printer has paper.  This only works if the RX line is connected
# on your board (but BE CAREFUL as mentioned above this RX line is 5V!)
#if printer.has_paper():
#    print('Printer has paper!')
#else:
#    print('Printer might be out of paper, or RX is disconnected!')
```

&nbsp; Now you can run the program with the following command:

```auto
python3 thermal_printer_simpletest.py
```

https://github.com/adafruit/Adafruit_CircuitPython_Thermal_Printer/blob/main/examples/thermal_printer_simpletest.py

# Mini Thermal Receipt Printers

## Python Docs

# Mini Thermal Receipt Printers

## Downloads

- [Adafruit\_Thermal library for Arduino](https://github.com/adafruit/Adafruit-Thermal-Printer-Library "Link: https://github.com/adafruit/Adafruit-Thermal-Printer-Library").
- [LCD Assistant](http://en.radzio.dxp.pl/bitmap_converter/)&nbsp;— optional bitmap conversion utility for Windows.
- [Processing](http://processing.org/download/) language — needed for bitmap conversion for Mac or Linux (and optionally Windows). DOWNLOAD VERSION 1.5.1, not the 2.0 beta.
- [Thermal Printer&nbsp;User Manual](http://www.adafruit.com/datasheets/CSN-A2%20User%20Manual.pdf).
- [An older version of the&nbsp;Thermal Printer User Manual](http://www.adafruit.com/datasheets/A2-user%20manual.pdf).
- [Thermal Printer Product Sheet](http://www.adafruit.com/datasheets/cashino%20thermal%20printer%20a2.pdf).

## Firmware Changer

If you'd like to risk it, you can revert/change the firmware using this tool that is from the manufacturer. We haven't tried it. It's completely utterly unsupported and you may break your printer. We won't replace it if it stops working due to a firmware change!

[update_firmware.zip](https://cdn-learn.adafruit.com/assets/assets/000/033/332/original/update_firmware.zip?1467047457)
# Mini Thermal Receipt Printers

## Troubleshooting!

### 

First thing to try is the power up test. You do not need an Arduino for this.  
  
**Make sure the paper is in the bay correctly, it should feed under and up so that the paper comes through the slot without bending.**  
  
For _mini_ and _tiny_ printers, hold down the button on the top, then plug in the printer to power. It should print out a test page. On _nano_ printers and _guts,_ connect power first, then tap the button.  
  
The printer’s LED will not be on solid, it will blink once in a while, that's normal.

### 

Make sure you have a good power supply that can deliver the required current. If you are trying to operate at 5V, your power supply must be able to maintain a constant 5V even when the current demand spikes during printing. If your printer is making an attempt to print, but then struggling, then it is likely your power supply is dipping below 5V.

If you have one available, try a higher voltage power source, but no more than 9 Volts.

### 

Make sure the paper is in the bay correctly, it should feed under and up so that the paper comes through the slot without bending.  
  
Make sure the paper roll is not 'stuck' feeling in the bay, it should rotate easily!.

### 

Some changes have been made to support a broader range of Arduino-like boards. Older code will require updating. Fortunately it's just a few lines around the global declarations and the setup() function.

Old syntax:

`Adafruit_Thermal printer(RX_PIN, TX_PIN);`

New syntax: declare a SoftwareSerial object and pass its address to the Adafruit\_Thermal constructor, like so:

`SoftwareSerial mySerial(RX_PIN, TX_PIN);`

`Adafruit_Thermal printer(&mySerial);`

Then, in the setup() function:

`mySerial.begin(19200);`

`printer.begin();`

Some boards (e.g. Arduino Due) have _multiple_ hardware serial ports, and the extras might be named `Serial1`, `Serial2`, etc. These can be used by passing the address of the serial device like so:

`Adafruit_Thermal printer(&Serial1);`

### 

The printer's features and behavior have changed over various firmware releases.

First, check the PRINTER\_FIRMWARE value in Adafruit\_Thermal.h, make sure it matches the value at the bottom of the printer test page (hold down the paper feed button when connecting power to print out a test page).

Some features just behave a little differently among releases…barcodes, line feeds, etc.…if you were previously using an older library or an older printer, you may need to tweak the code to produce the desired formatting with a current setup.

### 

_How_ a USB-attached printer manifests can vary by OS, USB adapter, printer firmware version and what other devices are attached.&nbsp;In Linux (e.g. Raspberry Pi), you might find the printer device at&nbsp;`/dev/serial0`, `/dev/usb/lp0`, `/dev/ttyAMA0`, `/dev/tty.USBserial0`&nbsp;or other names, and the digit(s) at the end might be different.

It’s common to snoop around in the system’s&nbsp;`/dev` directory, comparing with the USB cable disconnected and then connected, to find the printer’s device name. The `lsusb` command also sometimes helps.

Earlier model Tiny (USB) printers might appear by one of two different device names.&nbsp;Switching between them is explained toward the bottom of the “Making Connections” page. Newer units always appear in the `/dev/usb`&nbsp;subdirectory.

# Mini Thermal Receipt Printers

## Hacking!

![](https://cdn-learn.adafruit.com/assets/assets/000/025/205/medium800/components_bigprints.jpg?1430762656)

Look at those huge, razor-sharp image prints! You want some?

The following…

- Is an **undocumented** &nbsp;printer feature and is **NOT guaranteed** to work.
- May require&nbsp; **modifying** your printer — a **warranty-voiding** operation! Continue at your own risk.

You should _only_ attempt this if **_all_** of the following apply:

- Have first confirmed that the **printer works as expected** &nbsp;when operated through **conventional procedures**.
- Have a **genuine performance bottleneck** that cannot be adequately resolved by&nbsp; **adjusting the printer** timing and thermal settings first.
- Are comfortable **opening things** and **soldering**.

Danger: 

These printers have a limited serial receive buffer. Push bits to the printer faster than it can physically heat dots and feed paper, and you experience an “overflow” — bitmap images become garbled, text and formatting commands may be skipped.

The thermal printer library tries to throttle data to the printer at just the right rate. Too fast and an overflow occurs. Too slow and it wastes your time; the printer isn’t operating at peak throughput. This is an imperfect process…though we use very conservative timing estimates, the actual speed through the printer is impossible to predict…sometimes overflows _still_ occur.

_Hardware handshaking_ is a means by which a printer or other device can report to the microcontroller that it’s ready to receive more data, virtually eliminating buffer overflows while operating at peak throughput…the paper feed stops only when it physically absolutely must. Optimal performance.

It appears that some varieties of these thermal printers support hardware handshaking (e.g. firmware v2.64, 2.68). This is barely mentioned&nbsp;in the datasheet, and in fact **there isn’t even a physical connection&nbsp;for this on the outside of the printer.** A little surgery is in order…

Primary: 

# Parts and Tools Needed

- Small Phillips head screwdriver
- Pliers
- Soldering iron and related paraphernalia
- A bit&nbsp;of wire…but ideally a female jumper wire

# Procedure
Unplug all cables, turn the printer over and remove the two small Phillips screws.

![components_backscrews.jpg](https://cdn-learn.adafruit.com/assets/assets/000/025/207/medium640/components_backscrews.jpg?1430763081)

Take the back plate off, then remove the two (or sometimes four) Phillips screws holding the circuit board in place.

&nbsp;

These screws are a little smaller than the back-holding ones…don’t get them mixed up!

![components_pcbscrews.jpg](https://cdn-learn.adafruit.com/assets/assets/000/025/209/medium640/components_pcbscrews.jpg?1430763780)

Carefully, so as not to unseat or unplug the connectors, turn the circuit board over and look for the unpopulated via&nbsp;labeled “DTR.”

&nbsp;

There are some other interesting solder points in here, if you’re so inclined. “HV” is the raw 5–9 Volts from the power supply. On the right is a 3.3V pin, though I don’t know the available current. Conceivably one could bring these out to reduce overall cabling in a project…or even install a tiny microcontroller right inside!

![components_dtrpin.jpg](https://cdn-learn.adafruit.com/assets/assets/000/025/210/medium640/components_dtrpin.jpg?1430763797)

Cut an end off a female jumper wire and strip & tin the end.

&nbsp;

This will be hanging out of the printer…so a _female_ jumper prevents accidental contact with things if you’re not using the connection. If you only have regular wire, that’s fine, just be careful not to leave a bare&nbsp;end dangling.

![components_cutwire.jpg](https://cdn-learn.adafruit.com/assets/assets/000/025/212/medium640/components_cutwire.jpg?1430764324)

Solder the wire to the DTR pad. Top, bottom, doesn’t matter…it’s right up against the serial connection plug, so use whatever path works best for you, there’s ample room for routing the wire around either way.

![components_solderwire.jpg](https://cdn-learn.adafruit.com/assets/assets/000/025/214/medium640/components_solderwire.jpg?1430764727)

Language pedants may note that this isn’t technically a DTR pin, but rather CTS.&nbsp;It’s long-standing thing among printer manufacturers…apparently the misnomer was made decades&nbsp;ago but has stuck for consistency.

On the back plate, there’s a small metal “finger” between the serial and power sockets. Using pliers, this can be bent back to provide an exit route&nbsp;for the DTR wire.

![components_finger1.jpg](https://cdn-learn.adafruit.com/assets/assets/000/025/215/medium640/components_finger1.jpg?1430765440)

![components_finger2.jpg](https://cdn-learn.adafruit.com/assets/assets/000/025/216/medium640/components_finger2.jpg?1430765478)

Screw the controller board back in place (check that neither of the cables has come unseated), routing the DTR wire around between the two sockets, then screw the back on.

&nbsp;

Finished with the hardware!

![components_close.jpg](https://cdn-learn.adafruit.com/assets/assets/000/025/217/medium640/components_close.jpg?1430765650)

You can then reconnect the power and serial sockets, and wire those up as before.

Use a jumper wire to connect DTR to any available Arduino pin. In our examples, we’ll use digital pin 4.

The printer electronics operate&nbsp;at 3.3V (but are “5V safe”), so no level shifting is needed with&nbsp;3.3V boards (Arduino Due, etc.)…this can safely be connected directly.

# Code Changes

Just one line…the Adafruit\_Thermal constructor…needs changing. It can accept an optional parameter, a pin number to use for DTR:

```auto
Adafruit_Thermal printer(&amp;mySerial, 4);
```

This works just as well with a hardware serial port (e.g. Arduino Mega or Due):

```auto
Adafruit_Thermal printer(&amp;Serial1, 4);
```

No other changes are necessary. Try this with one of the example sketches…you’ll find the printer is suddenly _lots_ faster! That’s because the software&nbsp;throttle is no longer used…the printer continually reports its actual “ready” state to the microcontroller.

# Printing Huge Images
![](https://cdn-learn.adafruit.com/assets/assets/000/025/225/medium800/components_chrysler.jpg?1430768599)

The printBitmap() function can output images from an open stream or stored in PROGMEM (flash memory)…as explained on the “Printing Bitmaps” page.

Although the Arduino Mega has a whopping 256K flash space, a limitation of the AVR microcontroller is that a single array can’t exceed 32K…that’s about a 384x680 pixel bitmap image. If you try to embed a larger image in your code, the compiler will report an error.

One workaround might be to break really long images into multiple smaller images, and print these out consecutively without a feed() in between.

Another is to use a non-AVR Arduino-compatible board, such as the 32-bit Arduino Due. This has no problem with massive arrays. The&nbsp;Chrysler Building image above is 384x1132 pixels!

# &nbsp;Other Things to Know

This type of printer fares best with light line art and sometimes dithered&nbsp;photographic images as long as the overall dot density is fairly low, like under&nbsp;50%. Large solid-filled areas exhibit strange streaky artifacts…this isn’t a bug of the library or printer firmware, but just a side-effect of how receipt printers operate, that they can only heat so many dots at a time and have to pull shenanigans to&nbsp;go beyond that, else they jam.

Here are a couple examples from fancy commercial receipt printers.

&nbsp;

Notice in the first one that the “solid black” area isn’t _really_ solid black…examining it closely, you can see it’s densely dithered, but not 100% filled.

&nbsp;

The second _does_ have solid fills, but limits the total area. On any given row, only so many pixels are set.

![components_receipt-subway.jpg](https://cdn-learn.adafruit.com/assets/assets/000/025/324/medium640/components_receipt-subway.jpg?1431152828)

![components_receipt-lucky.gif](https://cdn-learn.adafruit.com/assets/assets/000/025/325/medium640thumb/components_receipt-lucky.jpg?1448318087)

If you try to print a “dense” image and the paper jams (image gets squashed vertically), pass a lower density value to printer.begin(). Default value is 120. So for example:

```auto
printer.begin(80);
```

DTR support is not a panacaea. **Glitches occasionally do&nbsp;still happen** …sometimes overflows, sometimes “framing errors” with serial data. But overall it seems fairly reliable and _buttery smooth!_


## Primary Products

### Mini Thermal Receipt Printer

[Mini Thermal Receipt Printer](https://www.adafruit.com/product/597)
Add a mini printer to any microcontroller project with this very cute thermal printer. Thermal printers are also known as receipt printers, they're what you get when you go to the ATM or grocery store. Now you can embed a little printer of your own into an enclosure. This printer is ideal...

No Longer Stocked
[Buy Now](https://www.adafruit.com/product/597)
[Related Guides to the Product](https://learn.adafruit.com/products/597/guides)
### Tiny Thermal Receipt Printer - TTL Serial / USB

[Tiny Thermal Receipt Printer - TTL Serial / USB](https://www.adafruit.com/product/2751)
Add a _really small_ printer to any microcontroller project with this very cute thermal printer. Thermal printers are also known as receipt printers, they're what you get when you go to the ATM or grocery store. Now you can embed a little printer of your own into an enclosure. This...

No Longer Stocked
[Buy Now](https://www.adafruit.com/product/2751)
[Related Guides to the Product](https://learn.adafruit.com/products/2751/guides)
### Nano Thermal Receipt Printer - TTL Serial

[Nano Thermal Receipt Printer - TTL Serial](https://www.adafruit.com/product/2752)
Add a _really really small_ printer to any microcontroller project with this very cute thermal printer. Thermal printers are also known as receipt printers, they're what you get when you go to the ATM or grocery store. Now you can embed a little printer of your own into an...

No Longer Stocked
[Buy Now](https://www.adafruit.com/product/2752)
[Related Guides to the Product](https://learn.adafruit.com/products/2752/guides)
### Thermal Receipt Printer Guts

[Thermal Receipt Printer Guts](https://www.adafruit.com/product/2753)
Add printing capability to any microcontroller project with **just the innards of a thermal printer.** Thermal printers are also known as receipt printers, they're what you get when you go to the ATM or grocery store. Now you can embed a little printer of your own into a...

No Longer Stocked
[Buy Now](https://www.adafruit.com/product/2753)
[Related Guides to the Product](https://learn.adafruit.com/products/2753/guides)

## Featured Products

### Mini Thermal Receipt Printer Starter Pack

[Mini Thermal Receipt Printer Starter Pack](https://www.adafruit.com/product/600)
Hit the ground running (and printing!) with this starter pack that includes a thermal printer and all the extras and save a few dollars while you're at it.  
  
Includes:

- [A mini thermal receipt printer](http://www.adafruit.com/products/597) - with cables and...

No Longer Stocked
[Buy Now](https://www.adafruit.com/product/600)
[Related Guides to the Product](https://learn.adafruit.com/products/600/guides)
### Female DC Power adapter - 2.1mm jack to screw terminal block

[Female DC Power adapter - 2.1mm jack to screw terminal block](https://www.adafruit.com/product/368)
If you need to connect a DC power wall wart to a board that doesn't have a DC jack - this adapter will come in very handy! There is a 2.1mm DC jack on one end, and a screw terminal block on the other. The terminals are labeled with positive/negative assuming a positive-tip configuration...

In Stock
[Buy Now](https://www.adafruit.com/product/368)
[Related Guides to the Product](https://learn.adafruit.com/products/368/guides)
### 5V 2A (2000mA) switching power supply - UL Listed

[5V 2A (2000mA) switching power supply - UL Listed](https://www.adafruit.com/product/276)
This is an FCC/CE certified and UL listed power supply. Need a lot of 5V power? This switching supply gives a clean regulated 5V output at up to 2000mA. 110 or 240 input, so it works in any country. The plugs are "US 2-prong" style so you may need a plug adapter, but you can pick one...

In Stock
[Buy Now](https://www.adafruit.com/product/276)
[Related Guides to the Product](https://learn.adafruit.com/products/276/guides)
### Thermal paper roll - 50' long, 2.25" wide

[Thermal paper roll - 50' long, 2.25" wide](https://www.adafruit.com/product/599)
A mini roll of thermal paper, this fits very nicely into our mini thermal printer. 2.25" wide (about 57mm) and 50 feet long (15 meters). BPA-free.  
  
[Perfect for use with our mini thermal printer!](http://www.adafruit.com/products/597)

No Longer Stocked
[Buy Now](https://www.adafruit.com/product/599)
[Related Guides to the Product](https://learn.adafruit.com/products/599/guides)
### Thermal Paper Roll - 33' long, 2.25"

[Thermal Paper Roll - 33' long, 2.25"](https://www.adafruit.com/product/2754)
A little roll of thermal paper! This fits very nicely into our&nbsp;[Tiny Thermal Receipt Printer](https://www.adafruit.com/products/2751). It's ~2.25" wide (about 57mm) and 33 feet long or about 10 meters.

No Longer Stocked
[Buy Now](https://www.adafruit.com/product/2754)
[Related Guides to the Product](https://learn.adafruit.com/products/2754/guides)
### Thermal Paper Roll - 16' long, 2.25"

[Thermal Paper Roll - 16' long, 2.25"](https://www.adafruit.com/product/2755)
A little roll of thermal paper! This fits very nicely into our [Nano Thermal Receipt Printer](https://www.adafruit.com/products/2752). It's ~2.25" wide (about 57mm) and 16 feet long or about 5 meters.

No Longer Stocked
[Buy Now](https://www.adafruit.com/product/2755)
[Related Guides to the Product](https://learn.adafruit.com/products/2755/guides)
### Adafruit METRO 328 Fully Assembled - Arduino IDE compatible

[Adafruit METRO 328 Fully Assembled - Arduino IDE compatible](https://www.adafruit.com/product/50)
We sure love the ATmega328 here at Adafruit, and we use them&nbsp;_a lot_&nbsp;for our own projects. The processor has plenty of GPIO, Analog inputs, hardware UART SPI and I2C, timers and PWM galore - just enough for most simple projects. When we need to go small, we use a <a...></a...>

Out of Stock
[Buy Now](https://www.adafruit.com/product/50)
[Related Guides to the Product](https://learn.adafruit.com/products/50/guides)
### Breadboarding wire bundle

[Breadboarding wire bundle](https://www.adafruit.com/product/153)
75 flexible stranded core wires with stiff ends molded on in red, orange, yellow, green, blue, brown, black and white. These are a major improvement over the "box of bent wires" that are sometimes sold with breadboards, and faster than stripping your own solid core wires. Makes...

In Stock
[Buy Now](https://www.adafruit.com/product/153)
[Related Guides to the Product](https://learn.adafruit.com/products/153/guides)

## Related Guides

- [Track Your Treats: Halloween Candy GPS Tracker](https://learn.adafruit.com/track-your-treats-halloween-candy-gps-tracker.md)
- [Bluefruit LE Connect for iOS and Android](https://learn.adafruit.com/bluefruit-le-connect.md)
- [Let’s Put LEDs in Things!](https://learn.adafruit.com/lets-put-leds-in-things.md)
- [Nokia 5110/3310 Monochrome LCD](https://learn.adafruit.com/nokia-5110-3310-monochrome-lcd.md)
- [2.8" TFT Touchscreen](https://learn.adafruit.com/2-8-tft-touchscreen.md)
- [OLED TRON Clock](https://learn.adafruit.com/oled-tron-clock.md)
- [Character LCDs](https://learn.adafruit.com/character-lcds.md)
- [Electronic Demon Costume](https://learn.adafruit.com/electronic-demon-costume.md)
- [Adafruit 16-channel PWM/Servo Shield](https://learn.adafruit.com/adafruit-16-channel-pwm-slash-servo-shield.md)
- [Arduino Lesson 2. LEDs](https://learn.adafruit.com/adafruit-arduino-lesson-2-leds.md)
- [2.2" TFT Display](https://learn.adafruit.com/2-2-tft-display.md)
- [Arduino GPS Clock](https://learn.adafruit.com/arduino-clock.md)
- [Adafruit Data Logger Shield](https://learn.adafruit.com/adafruit-data-logger-shield.md)
- [WiFi Candy Bowl Monitor](https://learn.adafruit.com/wifi-candy-bowl.md)
- [Making Adabot: Part 2](https://learn.adafruit.com/making-adabot-part-2.md)
