BeardedTinker / ESP8266-MQTT-Thermal-Printer-for-HA

Software to print data from an ESP-controlled Thermal Printer over MQTT
31 stars 6 forks source link
esp8266 hacktoberfest homeassistant mqtt

ESP8266 MQTT Thermal Printer for HA (V2.1)

This project is fork from ESP8266 MQTT Thermal Printer and a I really would like to thatnk original author for it.

Here I'll try to improve it to the best of my abilities for specific use - adding it to [Home Assistant] as printer for anything that wou want to print from it.

in Version 2 we can:

Although COMPLETELY unnecessary, this printer is really fun addtion to it allowing you to expand your system output options and it would be great to have it in future as part of the notification platform. BUT that is out of my (I'l just a sales guy tinkering) programming capabilities.

About printer

This 58mm Thermal Printer can print by using USB/TTL connection. In the package you will receive power cable and data cable. It has preloaded firmware with Latin alphabet (ASCII) but also has capability to print Bar Code (something I still havent test) and 2D Bar code. Yes, if you know how to convert, pritner can also print very simple images.

Paper needs to be 57.5mm (58 is ok) and there are even sticker version, which opens up some more capabilites.

Parts required

Adafruit Thermal Printer library

For printing, we are using Adafruit Thermal Library. At this point, I tried to improve on original code, by adding 2 options in static configuration file.

Bitmap printing

Maximum size for bitmap printing is 384 pixels width

Printer has no paper

In Version 2.1 the controller sends in topic mqtt_listen_topic_papercheck every defined seconds (papercheck_milliseconds) a yes or no

Badcode usage

in Version 2.1 Important: your thermal printer has only 58mm to print the barcode in the example below "Hello!!" the CODE93 barcode the max with of the paper has been reached. :-(

v------ use this number to config below
0 = UPC_A, < UPC-A barcode system. 11-12 char
1 = UPCE, < UPC-E barcode system. 11-12 char
2 = EAN13, < EAN13 (JAN13) barcode system. 12-13 char
3 = EAN8, < EAN8 (JAN8) barcode system. 7-8 char
4 = CODE39, < CODE39 barcode system. 1<=num of chars
5 = ITF, < ITF barcode system. 1<=num of chars, must be an even number
6 = CODABAR, < CODABAR barcode system. 1<=num<=255
7 = CODE93, < CODE93 barcode system. 1<=num<=255
8 = CODE128, < CODE128 barcode system. 2<=num<=255
payload for the barcode
topic (configed below) is
<barcodetype>|<barcode_value> e.g. 7|Hello!!

Configuration

In order to compile this project, you need to rename example-config.h to config.h and edit values there:

MQTT Topics

mqtt topic* payload
mqtt_listen_topic_text2print e.g. "Hello world!"
mqtt_listen_topic_textsize S = small,
M = medium,
L = large
mqtt_listen_topic_textlineheight minimum 24 and maximum 64 e.g. 24
mqtt_listen_topic_textinverse 1 = inverse,
0 = not inverse
mqtt_listen_topic_textjustify left = L,
center = C,
right = R
mqtt_listen_topic_textbold 1 = bold,
0 = not bold
mqtt_listen_topic_textunderline 1 = underline,
0 = not underline
mqtt_listen_topic_barcode \<barcodetype>|\<barcode_value>
e.g. 7|HelloMaster
mqtt_listen_topic_papercheck readonly!
- yes
- no

*defined in config-file above

Credits