Electronics project notes/ESC/POS notes

From Helpful
Jump to: navigation, search
This is for beginners and very much by a beginner. It's meant to try to cover hobbyist needs, and as a starting point to find out which may be the relevant details for you, not for definitive information.

Some basics and reference: Volts, amps, energy, power · Ground · batteries · resistors · changing voltage · transistors · fuses · diodes · varistors · capacitors · inductors · transformers · baluns · amplifier notes · frequency generation · skin effect

And some more applied stuff:

IO: IO and wired communication · localish communication · wireless (ISM RF, GSM, RFID, more) · 802.11 (WiFi) · 802.15 (including zigbee)

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

Some stuff I've messed with: Avrusb500v2 · GPS · Hilo GPRS · Bluetooth serial · JY-MCU · DMX · ESC/POS notes

Audio notes: basic audio hacks · microphones · amps and speakers · device voltage and impedance, audio and otherwise ·

Less sorted: Common terms, useful basics, soldering · Microcontroller and computer platforms · Arduino and AVR notes · ESP series notes · Electronics notes/Phase Locked Loop notes · mounts, chip carriers, packages, connectors · signal reflection · pulse modulation · electricity and humans · Unsorted stuff

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 a thermal printer (Point of Sale style, typically for receipts) to play with, so here are my notes.

Aside from a proprietary protocol, it also talks ESC/POS is a fairly simple escape-code based protocol.


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 may be the +15V/-15V variant of serial. If you want to connect to a 0-5V serial port you'll need a MAX232 or similar.

Higher port speeds are nice if you want to print detailed graphics.

Notes on commands and behaviour

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

since the cutter is regularly above the print head, cutting without movement would cut off perhaps three lines of of what we just printed. This is why the feed is in here (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 :)
  • There are some conditions on what you can do exactly when
Various involve the Top of line state, which is basically:


ASCII is typically printed as-is.

Non-ASCII is typically handled through codepages. You can typically 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