Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/alifeee/thermal-printer-pi
Thermal Printer scripts for Raspberry Pi
https://github.com/alifeee/thermal-printer-pi
escpos python raspberry-pi thermal-printer zj-58
Last synced: 20 days ago
JSON representation
Thermal Printer scripts for Raspberry Pi
- Host: GitHub
- URL: https://github.com/alifeee/thermal-printer-pi
- Owner: alifeee
- Created: 2024-09-03T22:29:15.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2024-10-28T11:10:00.000Z (23 days ago)
- Last Synced: 2024-10-28T14:32:36.977Z (23 days ago)
- Topics: escpos, python, raspberry-pi, thermal-printer, zj-58
- Language: Shell
- Homepage:
- Size: 4.88 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Thermal Printing
For more context on the printer, see:
-
## python-escpos
The main Python library used is python-escpos:
Here is an example file:
```python
from escpos.printer import Usbp = Usb(0x0416, 0x5011, profile="ZJ-5870")
p.text("Hello World\n")
p.barcode('4006381333931', 'EAN13', 64, 2, '', '')
p.qr("https://alifeee.co.uk")p.close()
```## Installation
```bash
# download files
mkdir -p /usr/alifeee
git clone [email protected]:alifeee/thermal-printer-pi.git /usr/alifeee/thermalprinter
# install python
python3 -m venv env
. env/bin/activate
pip install python-escpos[usb]
# add usb rules
echo 'SUBSYSTEM=="usb", ATTRS{idVendor}=="0416", ATTRS{idProduct}=="5011", MODE="0666", GROUP="dialout"' > /etc/udev/rules.d/99-escpos.rules
sudo systemctl restart udev
sudo udevadm control --reload-rules && sudo udevadm trigger
# add cgi scripts
mkdir -p /var/www/cgi/do/
sudo ln -s /usr/alifeee/thermalprinter/cgi/qr /var/www/cgi/do/qr
sudo ln -s /usr/alifeee/thermalprinter/cgi/qr.cgi /var/www/cgi/do/qr.cgi
```## Use
### Test printer
```bash
./env/bin/python test.py
```### Print QR code
```bash
./env/bin/python qr.py -t title -url "http://raspberrypi.local/do/qr"
```