Skip to content

Instantly share code, notes, and snippets.

@willquill
Created April 21, 2026 20:48
Show Gist options
  • Select an option

  • Save willquill/e47eb2c58e7662993f887382dc0f035e to your computer and use it in GitHub Desktop.

Select an option

Save willquill/e47eb2c58e7662993f887382dc0f035e to your computer and use it in GitHub Desktop.
PiScan

piscan

Connect a Raspberry Pi Zero W v1.1 to an Epson Perfection V550 USB scanner so that when you scan, it is uploaded to a Paperless NGX instance.

πŸ”§ Requirements Breakdown

  • Scan Trigger (Button Press)
  • Scanner Support (Epson V550)
  • Automatic Upload to Paperless-ngx
  • Minimal system footprint (headless, CLI-only)

End Goals

Button Action Description
Scan One-shot 300 DPI scan β†’ PDF β†’ scp
Email One-shot 1200 DPI scan β†’ TIFF β†’ scp
Copy Scan page at 300 DPI, append to a temp PDF
Start Finish and scp the multi-page PDF, clear temp state

Setup

Prepare Pi

brew install --cask raspberry-pi-imager

Use the imager to prepare the microSD card for your Raspberry Pi. I used bookworm slim, which does not have a desktop environment, and I pre-configured my wifi credentials and SSH authentication.

After booting up the Pi, SSH into it and execute:

sudo apt update && sudo apt upgrade -y && sudo apt install sane-utils scanbd curl libsane libsane-common -y

Add user to the scanner group

sudo usermod -aG scanner pi

Detect scanner:

sudo sane-find-scanner

Excerpt from output:

found possible USB scanner (vendor=0x04b8 [EPSON], product=0x013b [EPSON Scanner]) at libusb:001:002

Prepare scripts

Create your multipage_scan directory.

mkdir -p /tmp/multipage_scan

Create your scan script:

sudo mkdir -p /etc/scanbd/scripts/ &&\
sudo tee /etc/scanbd/scripts/piscan.conf > /dev/null <<EOF
#!/bin/bash

DATE=$(date +%Y%m%d_%H%M%S)
OUT="/tmp/piscan_$DATE.pdf"
scanimage --format=png --resolution 300 | convert - "$OUT"

# Move to remote consume folder
scp "$OUT" will@10.1.20.20:/tank/mounts/paperless-ngx/consume

To set up auto-authentication to that directory, you can generate a key.

This will let the Pi log in to will@10.1.20.21 without a password.

Keys are stored in ~/.ssh/id_ed25519 and authorized on the server in ~/.ssh/authorized_keys.

ssh-keygen -t ed25519 -C "scan-to-paperless"
ssh-copy-id will@10.1.20.20

Now test the password-less authentication:

echo "test" > testfile &&\
  scp testfile will@10.1.20.20:/tank/mounts/paperless-ngx/consume

Check your server to make sure the testfile exists. Then proceed to the next step.

Next, make the script run when you scan:

sudo tee /etc/scanbd/scanbd.conf > /dev/null <<'EOF'
action scan {
    filter = "^scan.*"
    desc   = "Scan document and upload"
    exec   = "/etc/scanbd/scripts/piscan.sh"
}
EOF

Now configure scanbd to run at boot:

sudo systemctl enable scanbd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment