Source: https://mokxi.com/parts/thermalprinter
Updated: 2026-11-19

Part

# Thermal receipt printer

Text, bold, inverse, double size and barcodes on a paper roll, over TTL serial at 19200 baud.

See every part

- 5 pins
- 2 settings
- In 1 project
- In 1 lesson

Drawn live by the editor's own code, at the size you see it.

At a glance

## The Thermal receipt printer in brief

What it is, and every setting the properties panel gives it.

The mini thermal printer, the CSN-A2 type, prints on 58 mm heat-sensitive paper with a 384-dot head and takes text and commands over a TTL serial port, 19200 baud by default. Text goes into a line buffer as it arrives and prints when a line feed comes or the line is full, and commands in between change how the next text looks. Mokxi follows those rules. A line is 32 characters, or 16 in double width, and a longer one wraps. It handles bold, double height and width, the size command, inverse, underline, left, center or right justification, feeding in lines or dots, and a barcode printed with its digits. A bitmap’s data is taken in full and shows as a placeholder with its size. The status request answers on TX with bit 2 set when the paper is out, which is how hasPaper() knows, and the P button takes the paper out and puts it back. The time a line takes, the darkness of the print and the character sets are not modeled.

Family

Outputs

Pins

5

baud

19200

paper

true

Pins

## 5 pins

Named as the editor names them, so a wire lands where you expect it.

Pin

What it does

VH

The print head's supply, 5 V to 9 V. Not from a board's 5 V pin.

GND

Ground, shared with the board.

RX

Into the printer: the board's transmit pin.

TX

Out of the printer: answers status requests. Optional.

DTR

Flow control. Not used here.

How to use it

## How to wire and drive a mini thermal printer from an Arduino

The printer needs two things the Uno cannot give: its own supply, 5 V to 9 V on VH, and a serial link. The head pulls well over an amp at peaks, so VH comes from a 9 V supply and never from the Uno’s 5 V pin, with the grounds joined. The printer’s RX goes to Uno pin 6, the Uno’s transmit pin, and the printer’s TX goes to pin 5. The project uses SoftwareSerial on 5 and 6 because pins 0 and 1 belong to the USB serial monitor. DTR is not used.

Each ticket in the project is a button press. justify('C') centers, boldOn() and setSize('L') make the header, and println() prints each line. printBarcode(code, CODE39) prints the lucky number as a barcode with its digits under it. Remember the line buffer: text is held until a line feed, so a missing println() prints nothing. A line of 32 characters fits, and a longer one wraps, while double width halves that to 16.

The TX wire is optional, and it is how the library asks for status. The printer answers with bit 2 set when the paper is out, which is what hasPaper() reads. Press P on the part to take the paper out and put it back, and the sketch can see it. The simulation does not time the print, so a ticket appears faster than the real head would draw it.

Part pin

Board pin

VH

Its own 5 V to 9 V supply, 2 A or more, not the Uno’s 5 V

GND

Ground, shared with the Uno and the supply

RX

Uno pin 6 (the Uno sends here)

TX

Uno pin 5 (status answers, optional)

DTR

Not used

Any board with a spare serial port can drive it: use Serial1 on a Mega or ESP32 instead of SoftwareSerial, and power VH separately in every case.

Hold the button

This is the simulator itself, running here. Click anything to open it in the editor.

Open this project in the editor Read the full tutorial

A centered bold header and a line, trimmed

Common errors

## Common Thermal receipt printer errors and fixes

What goes wrong

The fix

Nothing prints, though the sketch runs.

Text waits in the line buffer for a line feed. End each line with println(), or call feed() so the last line prints.

The printer resets, prints garbage or the Uno browns out.

It is powered from the Uno’s 5 V pin. The head draws over an amp at peaks. Give VH its own 5 V to 9 V supply and join the grounds.

Nothing happens, or characters are wrong.

RX and TX are swapped. The printer’s RX takes the board’s transmit pin. Also check the baud rate: the default is 19200.

hasPaper() always says there is paper.

TX is not wired, so the status answer never arrives. Connect the printer’s TX to the board’s receive pin, pin 5 in the project.

Questions

## Questions and answers

### How many characters fit on a line of a mini thermal printer?

Thirty-two in the normal width and 16 in double width. A longer line wraps onto the next. The head has 384 dots across 58 mm paper.

### Why does a thermal printer need its own power supply?

The head heats many dots at once and pulls more than an amp at peaks, more than an Arduino’s 5 V pin can give. VH takes 5 V to 9 V from a separate supply.

### Which library prints barcodes and bold text?

Adafruit_Thermal. boldOn(), setSize(), justify() and printBarcode() do it, and the project uses all four. Mokxi compiles the library.

### Does Mokxi model the print time or the darkness?

No. Lines, styles, feeding, barcodes, bitmaps as a placeholder and the paper-out status are modeled, but not the time a line takes, the heat setting or the character sets.

How it is modeled

## What is true about the Thermal receipt printer, here

In its help article’s own words: what the simulation gets right, and where it stops.

### Modeled

Lines. Text prints on a line feed; a carriage return is ignored; a line is 32
characters, 16 in double width, and a longer one wraps.

Styles. Bold, double height and double width (the print mode), the size command,
inverse, underline, and left, center or right justification.

Feeding, barcodes and bitmaps. Feeding lines or dots, a barcode printed with its
digits, and a bitmap's data taken in full (it shows as a placeholder with its size).

Status. The status request answers on TX, with bit 2 set when the paper is out,
which is how the library's hasPaper() knows.

### Not modeled

The time a line takes to print, how dark the heat settings make the print, the
character sets, the bitmap's picture itself, and DTR flow control.

From Thermal receipt printer, in full.

Projects

## See the Thermal receipt printer in a project

One built-in project uses it. It opens in the editor, already wired.

Lessons

## Where it turns up in a lesson

One lesson places it in its own circuit.

### Learn articles

1 lesson

- Arduino Thermal Printer: Wiring, Code and Barcodes

Boards

## The boards it is shown on

This board has a built-in project with the Thermal receipt printer in it.

- Arduino Uno R3

Libraries

## Arduino libraries for the Thermal receipt printer

Built in, so the sketch compiles with nothing to install. Each page has the calls, the wiring and an example to run.

- Adafruit Thermal Printer Library

Keep going

## Keep going

- UART Serial Explained: Baud, Frames and the Wire
- Arduino Serial.print vs println, and Decimals

More parts

## The rest of the bench

Every one of these is drawn and simulated the same way.

Full-size breadboard

A real 0.1 inch grid with the rails and the center channel, 63 columns wide.

Jumper wires

Drag from any pin or hole to any other. Corners snap, and you can drag them.

Power

A supply rail at the voltage you choose.

Ground

The other end of every circuit.

LED

Lights when current flows. Five colors, and the brightness is what your eye would see.

Filament lamp

A tungsten bulb in a holder: an inrush when it is switched on cold, tens of milliseconds to warm up, and dim on half its voltage.

Resistor

Any value you like, with the color bands drawn to match.

ESP32-C3-DevKitM-1

A RISC-V board that runs your firmware at 160 MHz on the real memory map.

Pushbutton

A 12 mm tactile switch. Hold it while the simulation runs.

Raspberry Pi Pico

The RP2040 board on our own Cortex-M0+ core. Pick a program and press Run.

Raspberry Pi Pico W

Raspberry Pi Pico W (RP2040). The same board and the same pinout as a Pico, with the CYW43439 on it. The WiFi is simulated (no radio; real internet through the Cloud panel’s switch), and the on-board LED, which hangs off that chip rather than off GP25, is driven through the same path. Everything else is the Pico.

Raspberry Pi 4 Model B

Raspberry Pi 4 Model B: the 40-pin header, driven by main.py with RPi.GPIO or gpiozero.

See every part

## Wire up the Thermal receipt printer

Open the editor and push it into the breadboard. It is free, and it runs on your own machine.

Start building free Open the editor
