Python script to run the Raspberry Pi barcode scanner end of the BookFetch project
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

BookFetch Scanner

Python script to run the Raspberry Pi end of the BookFetch project.

The script ( will listen for input from a USB barcode scanner, queueing scanned codes by storing them in a local SQLite database. A second script ( will run simultaneously, checking for an internet connection and emptying the queue by POSTing the scans to the BookFetch website via the REST API.

This method means that the scanner can be operated offline and as soon as it finds an internet connection it will upload the scan data.


Clone this repo to the Raspberry Pi, placing it in a folder in your user's home directory (user is usually pi).

Rename user.example.json to user.json and edit the contents, populating the blank fields with the correct API URL, username and password.

Set the Raspberry Pi to boot up in text console with the pi user automatically logged in. To do this run sudo raspi-config, choose 3) Boot Options and then B2) Console Autologin

Configure the pi users account to automatically execute both the background queue worker script and the foreground listener script. To do this create a file called .bash_login in the users home directory with the following contents:

cd ~/bookfetch
python > /dev/null &

Note: The path on that first line will have to match the location that you cloned the repo into

You are now free to power on the Raspberry Pi with only the scanner attached and it should record scans.