Skip to content

Print SeedSigner seeds using the Brother QL-700 label printer attached to a Raspberry Pi

License

Notifications You must be signed in to change notification settings

lispmeister/seedsigner-qr-code-printer

Repository files navigation

Print Example QR-code

This project is a simple prototype that intends to show how to print aSeedSigner seed and its QR-code on a Brother QL-700 label printer using only Python and the brother_ql library.

The project is really just a proof of concept and would need integration with the main SeedSigner code to become useful.

Example Seed

The image of the seed we will to print: Example seed image

The actual printout: Example seed printout

Requirements

This project assumes that the QL-700 (or compatible) printer is attached to a Raspberry Pi running Raspbian.

Update and Upgrade

sudo apt-get update && sudo apt-get upgrade

Install pipenv

sudo apt-get install pipenv

Create pipenv Environment

All our dependencies are defined in the Pipfile but we need to create an environment first.

pipenv --python 3.7

Install libraries into environment.

pipenv install

Start a shell in the environment

pipenv shell

Install Libraries

sudo apt-get install -y libusb-1.0-0 libopenjp2-7 libtiff5

Change permissions

Once we switch on the printer it will automatically show up as /dev/usb/lp0 in our device tree. Default permissions don't allow the pi user access. Let's change that.

sudo chmod o+rw /dev/usb/lp0

Print

Print our example seed horizontally:

#!/bin/sh
export BROTHER_QL_PRINTER=file:///dev/usb/lp0
export BROTHER_QL_MODEL=QL-700
brother_ql print -l 62 example-seedsigner-qr-code.png

Print our example seed vertically:

#!/bin/sh
export BROTHER_QL_PRINTER=file:///dev/usb/lp0
export BROTHER_QL_MODEL=QL-700
brother_ql print -r 90 -l 62 example-seedsigner-qr-code.png

Fix USB Permissions Permanently

The chmod command above is only a temporary fix for the access permissions to the lp0 device. Every time the printer goes offline (manually or due to power safe mode) the permissions revert to the default.

Check permissions after power was off:

ls -la /dev/usb/lp0

Result:

crw-rw---- 1 root lp 180, 0 Nov 26 08:10 /dev/usb/lp0

List our device tree:

lsusb -vvv

Result (excerpt):

Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            0
  bDeviceSubClass         0
  bDeviceProtocol         0
  bMaxPacketSize0        64
  idVendor           0x04f9 Brother Industries, Ltd
  idProduct          0x2042

We create a new file 50-usb-printer-rules:

sudo vi /etc/udev/rules.d/50-usb-printer.rules

The file has only one line and references our vendor and product ids but without the leading 0x to mark them as hexadecimal values:

SUBSYSTEMS=="usb", ATTRS{idVendor}=="04f9", ATTRS{idProduct}=="2042", GROUP="users", MODE="0666"

You will need to reboot for these changes to take effect.

sudo reboot

Once we're logged in again we check our permissions again to make sure they have changed to what we defined:

ls -la /dev/usb/lp0

Result:

crw-rw-rw- 1 root users 180, 0 Nov 26 08:46 /dev/usb/lp0

About

Print SeedSigner seeds using the Brother QL-700 label printer attached to a Raspberry Pi

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages