Skip to content

Python program for controlling a serial thermal printer

License

Notifications You must be signed in to change notification settings

HN-Vignolles/thermal-printer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

version

Seismograph

thermal-printer printing like a seismograph

Using slinktool and the SeedLink protocol, I pull data supplied by the rtserve.iris.washington.edu server, from Fort Macarthur Park, California, USA station "CI_FMP", channel "BHZ" STS-2 seismometer:

slinktool -s BHZ.D -S CI_FMP rtserve.iris.washington.edu -p -u | ./thermal-printer.py -p '-2000 3000' > /dev/serial0

Chusmiza, Chile, Nanometrics Trillium 240 Broadband Sensor:

slinktool -s BHZ.D -S C_GO01 rtserve.iris.washington.edu -p -u | ./thermal-printer.py -p '-1000 1000' > /dev/serial0

Barcodes

barcode example

./thermal-printer.py -b 'ITF HN-VIGNOLLES ' > /dev/serial0

Image Printing

image printing example

./thermal-printer -i imagefile > /dev/serial0
# Another example:
qrencode "WIFI:S:<SSID>;T:WPA;P:<PASSWORD>;;" -s 30 -o qr_wifi.png
./thermal-printer -i qr_wifi.png > /dev/serial0

Hookup

R-Pi
─────┐
 1 2 │
 ■ ● │
 ● ● │      ┌──────────────
 ● ●─┼─GND──┤GND   TTL level
 ● ●─┼─TX───┤RX    Printer
 ● ●─┼─RX───┤TX 
     │
...  │   ┌────────────┐      ┌──────────────
     ├───┤ USB-to  GND├──────┤GND   RS-232
     │   │ RS-232   TX├──────┤RX    Printer
     │   │          RX├──────┤TX
     │   └────────────┘

Notes

  • My printer model: JP-QR701-RS232
  • Power Supply for the printer: 5-9V, >=2A
    • The peak current consumption can reach 3.89A
    • I have tested the LM2596 module at 9v with good results
  • Baud rate typically 9600 or 19200

TCP/IP

Using socat and nc.

On the thermal-printer side (Raspberry Pi):

socat -gx TCP-LISTEN:3000,fork,max-children=10,reuseaddr OPEN:/dev/serial0

On the "client" side:

./thermal-printer.py [options] | nc <raspberrypi-ip> 3000

Debugging serial data

./thermal-printer.py [options] 2> /dev/null | hexdump -e '52/1 "%02X "" "' -e '8/1 "%_p""\n"'

About

Python program for controlling a serial thermal printer

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages