Tuesday, March 2, 2021

ESP8266 ESC/POS Smart Thermal Printer


The gear introduced here is a device that use a ESP8266 to print text that comes from a RESTful API or from an internal database to an ESC/POS thermal printer.


ESC/P (Epson Standard Code for Printers) is a printer control language developed by Epson to control computer printers. The ESC/POS is a variant for controlling receipt printers as commonly used at the point of sale (POS).


The clue here is to build a device that call a RESTful API, and print the text the API returns to a thermal printer, and eventually fits a thermal printer.

I want the printer to be capable of printing:
  • when a button is pressed
  • once in a day at a specific day time
  • many times after minutes have passed
To build this thing I decided to use a ESP8266.

At startup the ESP8266 try to connect to a WiFi network, if it does not reach the last network used, or no network was imposed before, the device comes to a "forced AP mode", that way one can connect to the device WiFi and set the main WiFi AP to be used for the internet connection. The WiFiManager (https://github.com/tzapu/WiFiManager) library it's used for this purpose.


Whenever the IP address is released at the device by the DHCP of the main AP, or even if a static address is imposed, the device address is printed on the thermal printer.
This address is useful to access the settings page.

All the settings for this device are accessible by the web page embedded in it, like custom header, footer, ESC/POS commands, cut paper and print logo enabler, day/time printing period, the text database and other.


If the device is connected to the internet, and the RESTful API uri is inserted, then the device call the API and print out the text returned, otherwise a random string is selected from an internal text database.

There's also a pretty pulsing light output can be connected to a led strip to make the device look more attractive.

The board is quite simple, it features a fixed voltage DC-DC Step Down regulator, the ESP8266 in the ESP-12 package, the strip led power stage, and a voltage converter that can be populated if the printer UART voltage is not the same of the ESP8266 UART voltage (3.3v).



I've build the first gear using a prototype board, it's the one you find in the video and pictures above, but also I've embedded the PCB board in a few printer I gifted to friends.


Code

Notes
  • read risk disclaimer
  • excuse my bad english

7 comments:

  1. What Uart printer did you use?
    Nice article by the way.

    ReplyDelete
    Replies
    1. Hello Tanmay.
      This was an XPrinter from aliexpress. But I've try this on other cheap ESC/POS printer and an Epson one. No problem with any of those. The only customization you need to do is the HEX code used to request the graphic logo. Thank you.

      Delete
    2. Thank you Davide for your clarification.

      Delete
  2. Hola gracias por compartir, como puedo hacer o convertir mi logo a hexadecimal.
    Gracias de antemano y saludos cordiales. 🤝🏽

    ReplyDelete
  3. Como puedo convertir mi logotipo gráfico a código hexadecimal para pasarlo a la esp8266?
    Gracias de antemano y saludos

    ReplyDelete
    Replies
    1. Hello, please write in english and do not double/post.

      Delete