Fully esphome thermal printer!
Hardware:
- 58mm embedded thermal printer, 60mm/s print speed TTL DC 5-9V Print Command: ESC/POS
- Waveshare ESP32-S3-Zero,
- Screwable USB type C port,
- Shrink tube,
- Wires
ESP32-C3 Super Mini | Printer TTL | Description |
---|---|---|
3V3 | VH | 5V from usb-c power |
GND | GND | Ground |
GPIO1 | RX | TX ESP → RX Printer |
GPIO2 | TX | RX ESP ← TX Printer |
GPIO3 | DTR or RST | DTR or RST control |
Available Home Assistant Action Commands:
The configuration exposes several custom actions through the ESPHome API that can be called from Home Assistant automations or scripts:
print_text
: Prints a simple string of text to the printer. It initializes the printer and adds three line breaks after the message.print_centered
: Prints a string of text centered on the paper. After printing, it returns the alignment to left.print_large
: Prints text using double width and double height characters. It resets the text size to normal after printing.print_report
: Prints a formatted report including a centered, large title, a separator line, content, another separator line, and a centered footer.print_sensors
: Prints a “SENSOR STATUS” title (centered and double width), followed by the current date and time, a separator, and then the provided sensor data.cut_paper
: Sends a command to the printer to perform a partial paper cut, if supported by the printer.feed_paper
: Feeds a specified number of lines.print_qr_code
: Generates and prints a QR code.
data_to_encode
(string) : The actual data (e.g., URL, text) to be encoded in the QR code.module_size
(int): Optional. Sets the size of the QR code dots (1-16, default 8). A larger number results in a larger QR code.error_correction
(int): Optional. Sets the error correction level (0=L, 1=M, 2=Q, 3=H, default L). Higher levels make the QR code more robust but also larger. The QR code is automatically centered.
print_ascii_smiley
: Prints a predefined ASCII smiley face based on thesmiley_type
variable. Supported types include “happy”, “sad”, “wink”, and “laugh”. Unknown types default to “:?”.print_home_assistant_logo
: Prints the Home Assistant ASCII art logo.print_tux
: Prints the ASCII art for Tux, the Linux mascot, in bold.print_cow
: Prints a cow ASCII art, in bold.print_sign_warning
: Prints an ASCII art warning sign, in bold.print_sign_mail
: Prints an ASCII art mail sign, in bold.print_weather_sunny
: Prints an ASCII art for sunny weather, in bold.print_weather_cloudy
: Prints an ASCII art for cloudy weather, in bold.print_weather_rainy
: Prints an ASCII art for rainy weather, in bold.print_weather_snowy
: Prints an ASCII art for snowy weather, in bold.print_weather_partialy_cloudy
: Prints an ASCII art for partially cloudy weather, in bold.set_alignment
: Sets the text alignment to “left”, “center”, or “right”.print_styled_text
: Prints text with various styles.
message
(string) : The text to print.bold
(bool) : Enables or disables bold text.underline
(bool) : Enables or disables underlined text.text_size
(int) : Sets the text size (0=normal, 1=double width, 2=double height, 3=double width & height).
set_inverted_mode
: Enables or disables inverted printing (white text on black background).set_upside_down_mode
: Enables or disables printing text upside down (rotated 180°).set_line_spacing
: Sets the line spacing in dots (0-255).print_barcode
: Prints a 1D barcode.
data_to_encode
(string) : The data to be encoded in the barcode.barcode_type
(string) : The type of barcode (e.g., “EAN13”, “CODE39”, “CODE128”).height
(int): Optional. Height of the barcode in dots (default 80, range 1-255).width_module
(int): Optional. Width of the thinnest bar in dots (default 3, range 2-6).hri_position
(string): Optional. Position of Human Readable Interpretation (HRI) characters: “none”, “above”, “below”, “both” (default “below”). The barcode is centered. If the barcode type or data length is invalid, an error message will be printed instead.
Link to yaml code: Home-Assistant/esphome/thermalprinter/esphome_thermal_printer.yaml at 636b3d24bd72432fa428efdb832b99ee961696cb · lyntoo/Home-Assistant · GitHub
If you’re interested in recreating this project, remember to review the code and modify it wherever there’s a # comment (change me) for your specific use. The logos in the programming may appear out of alignment, but this is a specification of the ASCII code.