Thermal printers for makers and programmers
Thermal printers are used to print bills, tickets, labels, and alike in shops and various venues. They are small, cheap, and get the work done. But how do they work? What can they print and how to control them?
Thermal printers are quite simple. There is a heating element that can precisely heat small points on its elongated surface. The paper that is used is covered with chemical compounds that change color when heated (usually to black). So by precise heating and moving the paper over the element you can get letters or even simple graphics printed.
Thermal paper is cheap to make, thermal printers are also simple and cheap to make, and there won't be problems with paper stuck deep inside a printer. Printing is fast and very quiet, there is no ink to manage. There is however a disadvantage - the print is fragile to elements like light, heat, and some other chemicals. Thermal prints aren't long-lasting, they can fade and vanish or the whole surface will change color. Also, the feed mechanism is simple so there may be distortions if the paper can’t move freely. Also, there can be a lack of uniformity of quality when printing images.
There are a lot of printers on the market. They can use USB, Bluetooth, or WiFi interfaces while using a serial connection behind them. Thermal printers often offer direct access to that serial connection too (TTL, RS232, RS485) which can be used for integration with microcontrollers or other industrial systems. They can print on standard thermal paper of one of the standardized widths. There are also specialized variants to support standardized tapes of stickers to print labels - from simple small stickers to full shipping labels.
The whole standard is called ESC/POS and if you have a thermal printer compatible with it (most of them) then any software or library supporting it can use those printers. To some extent, a thermal printer can be added as a
printer under Windows or Linux.
Peripage are printers made by Paperang company. They are intended for
consumer use and not as ESC/POS printers. They come with nice mobile apps as well as a large selection of additional types of thermal paper rolls - different colors, stickers, and alike. The main marketing pitch seems to be
analog blogging - making personal journals and like.
When testing the Peripage A6 printer I had no problems using it via my Android phone. It can be a bit tricky to manage text style via the mobile interface but it can be done. I could not make it work under Linux via ESC/POS library or via direct printing to a local printer device.
This is your typical ESC/POS printer. It has USB/Bluetooth and serial interfaces and a rechargeable battery. I was ale to configure it on Windows as well as on Linux - by direct lp usage as well as through the ESC/POS printing library. The prints look quite good.
This is a generic serial thermal printer, it looks nearly identical to the Adafruit one but there can be some electronics and firmware differences. The quality of prints from this printer is kind of worse than the other two. I was able to print via ESC/POS library as well as via Adafruit library although the printer would often not respond to serial commands sent - I had to execute the script few times before it reacted and printer what was sent.
I powered it with a lab power supply. At 8.9V it pulled up to 0.7 - 0.8A while printing which gives around 7W of power draw.
Aside from intended POS usages printing bills and whatnot thermal printers could be used for some personal use as well as in makers projects related to electronics. Peripage printers are directed at end-consumers for
analog blogging, printing ToDo lists, labels, and alike. Serial printers can be used in electronics projects with microcontrollers. The USB/Bluetooth ones would be for use with Raspberry Pi and regular PC and laptops.
PeriPage is intended to be used with mobile apps available for Android and iOS. ESC/POS printers with Bluetooth or WiFi interface can also be used with mobile devices. Just search the shop for
thermal printer and you will get a lot of apps available. On Windows basic support can be achieved by adding such local printer manually (text printing, more if it has a dedicated app/driver). On Linux, you can cat text files to the device, in some cases, CUPS printing service can support them (if a driver is available and it actually works). Usually using an ESC/POS library is better than trying to use CUPS.
The most reliable way of controlling ESC/POS printers is by using a library that implements that standard. This can cover USB, serial, and network-based printers
Connect the printer via USB and if not possible use the Bluetooth or WiFi interfaces. Go to printer settings and try to add one. Windows likely won't find anything and you will have to add it manually. Select at which interface the printer is located - when it's a USB then such an option will appear on the list. Pick the generic printer type and it should be done. In a lucky case vendor/model will be on the list to pick or there can be a custom driver provided by the manufacturer.
Now you should be able to print simple text from a Notepad.
For a USB printer check if it appears as printer in /dev/usb/ (lp* device)
Try cat-ing a small text file to it (by default it will likely require root):
This should make the printer print the contents of the file. Some printers may not support it.
To not be forced to use the root account to run ESC/POS code the printer has to have an udev rule and the user has to be added to a selected group like for example dialout.
lsusb before connecting the device after which connect and turn the device on. Run
lsusb again and see which entry was added - that's the printer (or check
dmesg logs). We need the vendor and device IDs:
In this example vendor ID is
0416 and device ID is
Now we have to add an udev rule for it so that non-root can use it. Create/edit a file named like
idProduct to those of your device. Also, add the selected Linux user (user account you use) to the
Restart udev or reboot the system to get all changes active.
python-escpos is one of the libraries that implement ESC/POS standards and allows printing text, images, barcodes, and QR codes on compatible thermal printers.
To use a USB thermal printer with this library we will have to get some data about the device. The initialization looks like so:
We already have both IDs, the
IN_ENDPOINT is usually
OUT_ENDPOINT can be found with this command:
You can skip the greps if you want to see the full info on the device. With all the data we can use the printer:
from escpos import printer p = printer.Usb(0x0416, 0x5011, in_ep=0x81, out_ep=0x03) p.text("Hello World!\n") p.text("Stay at home!\n") p.image("your_image_file.jpg") p.cut()
The image should be small, starting with like 380 pixels of width or alike. Big files will be cut (not printed fully). And you have to have that file in a given path. You can find more about what this library can print in the documentation.
Serial (UART) printers can be initialized by specifying the device name, for example:
For PeriPage there are dedicated Python packages, check Github for one of them.
Adafruit has a serial thermal printer in their product catalog and they do support Arduino and CircuiPython. Serial printers can be used with a microcontroller as well as with PCs.
There are also generic thermal printers that look exactly like the Adafruit printer but they may differ slightly with the electronics and firmware - they can work with Adafruit libraries but it's not guaranteed. The one that I have isn't the best quality but seems to work with the Adafruit library (although it does print some
trash characters from time to time.
You will find all the code and wiring in the Adafruit tutorial. In my case, I had to connect UART and the power supply ground for it to work.
There are libraries for ESC/POS printers in other languages too. I've seen a PHP one as well as some raw serial command tutorials. The serial Adafruit printer is supported by Arduino and likely by other microcontroller platforms that are compatible with Arduino stack (like ESP chips). You should be able to find such libraries on Github or via Google.
I hope this article was fun to read. Thermal printers can be used in some fun maker projects as well as in some practical applications like label printing. You should be able to find thermal printers and thermal paper locally, via general stores like Amazon, and eBay, electronics stores like Adafruit, and also China - Aliexpress and alike. Just check what length of thermal paper the given printer uses, what interfaces it has (USB, Bluetooth handy), and if it's something custom or just ESC/POS standard printer.