Source: https://mokxi.com/libraries/adafruit-thermal
Updated: 2026-11-22

Libraries / Displays

Arduino library · Displays

# Adafruit Thermal: a mini receipt printer on Arduino

Yes. You can use the Adafruit Thermal Printer Library online in Mokxi with nothing to install, and the sketch runs in your browser against the simulated part (Thermal receipt printer). The example below, "Styled text and a barcode with Adafruit Thermal", runs on the Arduino Uno R3.

Run the example in Mokxi See the calls

Built in on Mokxi: #include <Adafruit_Thermal.h> and it builds, with nothing to install. Free, and no account needed.

## What Adafruit Thermal Printer Library does

The small TTL thermal printers sold by Adafruit and many others print 58 mm receipts by heating dots on special paper, with no ink. They take text and commands over a serial line at 19200 baud (some at 9600), and the Adafruit_Thermal library wraps the commands so a sketch can print styled text, barcodes and small bitmaps without learning the ESC/POS codes.

The library sits on any Stream, so on an Uno it rides a SoftwareSerial port and on a Mega or ESP32 a hardware one. Styles are switches you turn on and off around the text: boldOn() and boldOff(), underlineOn(), inverseOn(), doubleHeightOn(), and setSize() with S, M or L. justify() takes L, C or R. Everything printed after a style call uses it until you switch it back or call setDefault().

The print head needs real current, a couple of amps at 5 to 9 V while it prints, so it gets its own supply sharing ground with the board, as in the example: the printer’s RX on pin 5, its TX on pin 4, and a 9 V source on its head supply. In Mokxi the printout appears at once, so the timing settings change nothing, and a bitmap shows as a placeholder box of its size rather than its pixels.

Library Manager name | Adafruit Thermal Printer Library

Author | Adafruit

Include | #include <Adafruit_Thermal.h>

Boards | Arduino Uno, Arduino Nano, Arduino Mega 2560, Arduino Leonardo, SparkFun Pro Micro, Arduino Micro, Arduino Pro Mini 3.3 V, ESP8266 NodeMCU, ESP32 DevKit, ESP32-DevKitC V4, LOLIN32 Lite, Wemos D1 R32, Cheap Yellow Display, TTGO T-Display, ESP32-S3-DevKitC-1, Seeed XIAO ESP32-S3, Arduino Nano ESP32, ESP32-S3-CAM

In the simulator | Simulated: it runs against the part the way it does on the bench.

Parts it drives | Thermal receipt printer

## Install it

It builds on Arduino Uno, Arduino Nano, Arduino Mega 2560, Arduino Leonardo, SparkFun Pro Micro, Arduino Micro, Arduino Pro Mini 3.3 V, ESP8266 NodeMCU, ESP32 DevKit, ESP32-DevKitC V4, LOLIN32 Lite, Wemos D1 R32, Cheap Yellow Display, TTGO T-Display, ESP32-S3-DevKitC-1, Seeed XIAO ESP32-S3, Arduino Nano ESP32, ESP32-S3-CAM.

In Mokxi it is built in: #include <Adafruit_Thermal.h> and the sketch compiles, with no download, no zip and no Library Manager.

On a real board, install "Adafruit Thermal Printer Library" by Adafruit from the Arduino IDE’s Library Manager (Sketch, Include Library, Manage Libraries), or add Adafruit Thermal Printer Library to lib_deps in PlatformIO. Mokxi follows the calls of release 1.4.1, so a sketch written here builds there too.

What to know in the simulator: The printer prints at once, so the timing calls change nothing; a bitmap shows as a placeholder of its size.

- Arduino Uno
- Arduino Nano
- Arduino Mega 2560
- Arduino Leonardo
- SparkFun Pro Micro
- Arduino Micro
- Arduino Pro Mini 3.3 V
- ESP8266 NodeMCU
- ESP32 DevKit
- ESP32-DevKitC V4
- LOLIN32 Lite
- Wemos D1 R32
- Cheap Yellow Display
- TTGO T-Display
- ESP32-S3-DevKitC-1
- Seeed XIAO ESP32-S3
- Arduino Nano ESP32
- ESP32-S3-CAM

## The calls you will use

In the order a sketch meets them.

### Adafruit_Thermal printer(&mySerial)

The printer on a serial port you opened first, mySerial.begin(19200) for most models.

### printer.begin()

Wakes the printer, resets its settings and sets the heat time. Call it once in setup(), after the port is open.

### printer.boldOn()

Prints what follows in bold until boldOff(). underlineOn(), inverseOn() and doubleHeightOn() work the same way.

### printer.setSize('L')

Character size: S for small (the default), M for double height, L for double height and width.

### printer.justify('C')

Line alignment: L, C or R. It applies to every line until changed.

### printer.printBarcode("ADAFRUT", CODE39)

Prints a barcode of the given type: UPC_A, EAN13, CODE39, CODE128 and others. Each type limits which characters and lengths it takes.

### printer.feed(2)

Feeds blank lines so the last printed line clears the tear bar.

### printer.hasPaper()

Asks the printer’s paper sensor and returns true when paper is loaded. Needs the printer’s TX wired back to the board.

## Example: Styled text and a barcode with Adafruit Thermal

On the Arduino Uno R3. It runs in the browser exactly as printed.

sketch.ino · Arduino Uno R3

### Wiring

- Arduino Uno R3 5 to Thermal receipt printer RX
- Arduino Uno R3 4 to Thermal receipt printer TX
- Power VCC to Thermal receipt printer VH
- Arduino Uno R3 GND to Thermal receipt printer GND

Open it in the editor, wired and ready to run

## Common errors and how to fix them

### The printer prints garbage characters

The baud rate does not match. Hold the feed button while powering the printer to print its test page, which states the rate, and use that number in mySerial.begin().

### Print is faint, or the board resets in the middle of a receipt

The head is not getting enough current. Power the printer from its own 5 to 9 V supply rated for 2 A, never from the Arduino’s 5 V pin, and join the grounds.

### hasPaper() always says there is no paper

The printer’s TX line is not connected to the board’s receive pin, so the answer never arrives. Wire it to the first SoftwareSerial pin, or skip the call if you only send.

## Questions and answers

### Can it print images?

On a real printer, yes: printBitmap() takes a width, a height and a 1-bit array, usually stored in PROGMEM. In Mokxi the bitmap prints as a placeholder box of that size.

## Projects that use Adafruit Thermal Printer Library

Built-in projects that include it. Each page has the full sketch and opens in the editor, already wired.

Fortune printer Press the button and a thermal printer rolls out a fortune and a lucky number, in big bold type with a barcode under it.

## Keep going

### Learn

- Arduino Thermal Printer: Wiring, Code and Barcodes
- UART Serial Explained: Baud, Frames and the Wire

### Parts

- Thermal receipt printer

### More displays libraries

- Adafruit SSD1306
- Adafruit GFX Library
- LiquidCrystal I2C
- LiquidCrystal
- LCD_I2C
- hd44780
- TFT_eSPI
- U8g2
- DigitLedDisplay
- SevenSegmentTM1637
- OLED_I2C
- Adafruit PCD8544 Nokia 5110 LCD library
- LedController

Every built-in library · Open the editor

## Try Adafruit Thermal Printer Library without installing anything

Open the example, change the sketch, and keep your version in a free account.

Start building free

Open the editor
