Skip to content

jbmorley/Python-Thermal-Printer

 
 

Repository files navigation

Python-Thermal-Printer Module

Python3 port of the original Adafruit Python-Thermal-Printer library.

Getting Started

Install Raspbian Buster and Wire the printer according to this. I powered the printer with the GPIO pins as well.

Run a test to see if the printer is working by punching in these commands into the terminal.

stty -F /dev/serial0 19200
echo -e "This is a test.\\n\\n\\n" > /dev/serial0

Installing

  1. Enable the serial port.

    sudo raspi-config

  2. Update the system and install perquisites.

    sudo apt-get update
    sudo apt-get install git cups wiringpi build-essential libcups2-dev libcupsimage2-dev python-serial python-pil python-unidecode
    
  3. Install the printer driver. Don't worry about the warnings that g++ gives.

    git clone https://github.com/adafruit/zj-58
    cd zj-58
    make
    sudo ./install
    
  4. Make the printer the default printer. This is useful if you are going to be doing other things with it.

    sudo lpadmin -p ZJ-58 -E -v "serial:/dev/serial0?baud=19200" -m zjiang/ZJ-58.ppd
    sudo lpoptions -d ZJ-58
    
  5. Install the Python dependencies:

    sudo apt-get install --yes python3-pip
    pip3 install --user \
        Pillow \
        pyserial
  6. Restart the system. Clone this repository and try to run printertest.py.

    git clone https://github.com/galacticfan/Python-Thermal-Printer/
    cd Python-Thermal-Printer
    python3 printertest.py
    
  7. Use cron to run the management script on startup by adding the following line to your crontab (crontab -e):

    @reboot /usr/bin/python3 /home/pi/Projects/Python-Thermal-Printer/main.py
    

    You will need to update the path to main.py depending on where you cloned the repository.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%