Simple guide to use a thermo printer with python

From Interaction Station Wiki
Revision as of 13:51, 21 September 2022 by Joak (talk | contribs) (Created page with "1. connect the printer via usb to your PC/Pi/... 2. install the escpos library via pip. more info about this python library [https://github.com/python-escpos/python-escpos her...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

1. connect the printer via usb to your PC/Pi/... 2. install the escpos library via pip. more info about this python library here

pip install escpos 

3. create a script.py file

from escpos.printer import Usb       #imports the library in the script.py
import time                          #import the time library
iprinter = Usb(0x0416,0x5011)        #defines where the printer is connected


white True:                          #this function is running now for ever
    iprinter.text("Hello World")     #sends "Hello World" to the printer
    iprinter.text("\n")              #sends a new line to the printer
    time.sleep(1)                    #makes a break for one second