Electronics project notes/Thermal printer notes

From Helpful
(Redirected from ESC/POS)
Jump to: navigation, search
This is for beginners and very much by a beginner / hobbyist.

It's intended to get an intuitive overview for hobbyist needs. It may get you started, but to be able to do anything remotely clever, follow a proper course or read a good book.

Some basics and reference: Volts, amps, energy, power · batteries · resistors · transistors · fuses · diodes · capacitors · inductors · ground

Slightly less basic: amplifier notes · varistors · changing voltage · transformers · baluns · frequency generation · Transmission lines · skin effect

And some more applied stuff:

IO: Input and output pins · wired local IO · wired local-ish IO · ·  Various wireless · 802.11 (WiFi) · cell phone

Sensors: General sensor notes, voltage and current sensing · Knobs and dials · Pressure sensing · Temperature sensing · humidity sensing · Light sensing · Movement sensing · Capacitive sensing · Touch screen notes

Actuators: General actuator notes, circuit protection · Motors and servos · Solenoids

Noise stuff: Stray signals and noise · sound-related noise names · electronic non-coupled noise names · electronic coupled noise · ground loop · strategies to avoid coupled noise · Sampling, reproduction, and transmission distortions

Audio notes: See avnotes

Platform specific

Arduino and AVR notes · (Ethernet)
Microcontroller and computer platforms ··· ESP series notes · STM32 series notes

Less sorted: Ground · device voltage and impedance, audio and otherwise · electricity and humans · power supply considerations · Common terms, useful basics, soldering · PLL · pulse modulation · signal reflection · resource metering · SDR · Project boxes · vacuum tubes · Unsorted stuff

Some stuff I've messed with: Avrusb500v2 · GPS · Hilo GPRS · JY-MCU · DMX · Thermal printer ·

See also Category:Electronics.

These are primarily notes
It won't be complete in any sense.
It exists to contain fragments of useful information.

I once got thermal printers (Point of Sale style, typically for receipts) to play with, so here are my notes.

See also Party printer project

Hardware notes

The wiring and signaling can be slightly specific to a model, so read the manual.

I have a serial printer (Parallel also exists, and transport via USB and ethernet is similar).

In my case, Having Ground, Rx, Tx, and a single hardware flow control pin ('my buffer is full, pause please') was enough.

Keep in mind this can be the older +15V/-15V variant of serial. If you want to connect to TTL level (0-5V) serial port you'll need a MAX232 or similar.

Higher port speeds are nice if you want to print fine bitmap graphics not-very-slowly.

ESC/POS notes

ESC/POS is a standard from Epson, with a series of revisions.

Some commands are new, some outdated, so not all ESC/POS printers support everything.

Characters special in some way:

  • Many commands start with ESC (0x1B),
  • a bunch with GS (0x1D)
  • a few with FS , relating to non-volatile memory
  • LF (0x0a) and FF (0x0c) have similar but specific meaning depending on whether the printer is in standard or page mode


GS V m
GS V m n

For m

  • 0 or '0' - full cut (if supported)
  • 1 or '1' - partial cut
  • 65 - feed n lines according to current pitch, then full cut
  • 66 - feed n lines according to current pitch, then partial cut

If the cutter is after the print head, cutting without movement would cut off perhaps three lines of of what we just printed. This is why some feed is part of the command (you could of course manually feed too, if you want more control).

If cutting is not supported, the feed-and-cut commands still feed.

Mixed content

When you mix text, bit images, barcodes (and variants, such as double-height text),

...there are various well-defined details to how these will be printed alongside (or not) and how far they will extend horizontally and vertically. Read the standard :)


ASCII is typically printed as-is.

Non-ASCII is typically handled through codepages.

You can also often define your own character set.(verify)

Line wrapping is applied automatically (though for e.g. receipts it may be less messy if you can avoid this).

Be aware of potentially different handling between:

  • regular text
  • magnified text
  • HRI (Human Readable Interpretation), the text under a barcode
  • chinese characters

Magnification: GS ! n n is two nibbles, for horizontal and vertical where. Bitwise:

0000 for 1, though to 0111 for 8
1000-1111 undefined

Standard mode and page mode handling of text

Short version:

  • Standard mode prints lines, that is, it acts when it sees a LF character in the text data
  • Page mode buffers incoming text data, but does not act until it gets
    • ESC FF (print and stay in page mode)
    • FF (print and switch to standard mode)
  • There are a few commands that are ignored, completely or selectively, in one of the modes
In most cases it's fairly obvious (e.g. switching to the already active mode, printing bit images in page mode)
in other cases it is more interesting, e.g setting text direction

Switching between the modes:

  • ESC L: switch to page mode
  • ESC S: switch to standard mode (presumably clear page mode's leftover buffer(verify))

Print region, direction

ESC W - set margin ESC T - set print direction

Bit graphics

GS v 0
  • now obsolete, but is typically still supported
  • takes data from
  • useful for one-time use
GS ( L
GS 8 L

Download bit images

GS *
sets current download image
GS /
prints current download image
  • Useful for e.g. store logo
  • Size restrictions:
    • x in 1..255 (units of 8 dots)
    • y in 1..48
    • (x*y) must be <= 1536
So, for example, if the print width is 576 dots, x=72, so y must be <=21

Download bit images are meant for re

Status and such

  • ESC @ (0x
    • Clears the print buffer, download bit images
    • Retains reception buffer, DIP settings, macros, NV bit images,
    • leaves the printer in standard mode

EPL2 notes