Liam Demafelix

Software Engineer, IT Consultant

Forcing My Printer and Scanner to be Wireless

TL;DR – source code for the stuff in this post can be found here.


I bought a new office desk for my home office. It’s a (really) long table, I wasn’t expecting it to occupy more than twice my original desk.

After pestering Ikea’s customer service because their deliverymen were extremely late (I selected “10 am to 1 pm” on the order page and they arrived at 6 pm), I managed to set the table up with only one finger injured. I bought a ton of stuff but it never crossed my mind to get a proper screwdriver, so that’s on me.

I managed to set it up and I converted my old office table to a pantry table, holding my mini fridge, coffee maker and water heater, plus the coffee, sugar, creamer, condiments – basically everything else I need to ignore the fact that I’m getting fatter by the day. You know, the stuff.

My new desk looked empty, so I thought of buying new stuff to make it seem like I’m such a hard worker. These purchases included:

  • a 4-tray document holder
  • a headset stand
  • a new printer and scanner

I’m a cheapskate who thinks I could probably twiggle some wires around the house so buying a printer that supported printing over WiFi wasn’t a requirement. I just needed something that could print, scan and fill up my desk. Also, I finally reserved a schedule to get a passport and I was almost late for my appointment at DFA because I kept putting off printing the documents and I couldn’t find a printing shop that would read my flash drive (or shops that were open). I’m a victim of I’ll just do this later, I can always get up early and print it before going. – no. I should’ve known better, I’m extremely lazy.

Lo and behold, the HP DeskJet 2320 All-in-One is only PHP 3,200.00 at Shopee. Perfect.

A few days later, the deliveryman knocked on the door carrying my newly-purchased sadboy splurge. It doesn’t exactly fit the ambiance of the desk (only it, my router and my network hub are the white stuff on the desk), but it was cheap enough that I stopped caring.

Great! Now, if only I remembered to buy paper.

The Problem

Because I was such a cheapskate, I didn’t get a printer and scanner that had wireless functionality. This means that if I wanted to print something, I would have to connect the device with the document. This means if I wanted to print a resume, I’d have to plug it in to my desktop PC. If I wanted to print a work document, I’d have to plug it in to the work laptop. If I wanted to print a meme and post it on the fridge so people would finally get the message of leaving me alone when I’m coding, I’d have to get a dongle and connect it to my phone (or just make it on the PC).

Clearly, this ain’t it.

I hate taking apart connected cables and reconnecting them to other devices all the damn time. Not to mention this may wear out the sockets of the machines this method would abuse.

The Solution

I have a Raspberry Pi lying around here acting as a NAS (I connected a 2TB External Hard Drive to it as an experiment and when that experiment failed I just kind of left it there). Since I can already access this Pi from the network (via \\raspberrypi, or if DNS wants to suddenly not work,, I could just run CUPS and use it as a network printer.


But what about scanning?

I have a solution for that too, but for now let’s talk about printing.

P.S. If you didn’t read the TL;DR above, the source code for these scripts can be found in my GitHub profile right here.

First off, I have to plug the printer to my Raspberry Pi. Easy enough, my old USB Type B cord I’m using for MIDI (I have an electric piano I’m not using because life is hard sometimes) works fine for this.

Running sudo lsusb gives me:

liam@raspberrypi:~ $ sudo lsusb
Bus 002 Device 003: ID 1058:2626 Western Digital Technologies, Inc. My Passport (WDBPKJ)
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 004: ID 03f0:3654 HP, Inc DeskJet 2300 series
Bus 001 Device 002: ID 2109:3431 VIA Labs, Inc. Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

It’s detected. Great! Can we try printing now?

Yep. All I need to do is add this to CUPS. So I installed cups (sudo apt install cups -y) and went to https://raspberrypi:631/ to reach the CUPS admin interface.

CUPS automatically detected the printer. Great! Can Windows too?

You bet. My Android phone, connected to the router, also detects it correctly:

Printing setup done! Now, for scanning.

Scanning is a little tricky. There’s the SANE Standard, which isn’t supported by anything modern (the Windows clients I’ve tried just crashes, they were built for older 32-bit versions of Windows and I have no idea why they won’t work on Windows 11, so I stopped caring). Also, even if this DID work, let’s try scanning. On the SSH session to the Pi:

liam@raspberrypi:~ $ scanimage --format=jpeg --resolution=600 > hello.jpg
Application transferred too few scanlines

Googling this error didn’t help, it seems like an error with ImageMagick, so I stopped caring.

Thankfully, HP has hplip, the HP Linux Imaging and Printing package. This allows me to sudo apt install hplip so I can use hp-scan. Great! Let’s try that:

It works! I can also access the output on the NAS, since /mnt/storage/liam is my NAS folder on the Pi. In my Windows PC, I can go to \\raspberrypi\liam\Scans and there it is:

Unfortunately, I can’t show the scanned photo for confidentiality. But it works!

Making Shortcuts

Of course, I’m not going to make this hard for myself. I could memorize the entire command:

/usr/bin/hp-scan --mode=color -r 600 --output=/mnt/storage/liam/Scans/Hello.jpgCode language: JavaScript (javascript)

…but why would I want to? Instead, I could just create an alias for this (Linux is great, isn’t it?). To do this, simply edit ~/.bash_aliases and put:

alias docscan='/usr/bin/hp-scan --mode=color -r 600'Code language: JavaScript (javascript)

By doing this, I could just type:

docscan --output=/mnt/storage/liam/Scans/MyFile.jpgCode language: JavaScript (javascript)

…and get the same result. It’s easier to remember.

For Windows

Does this mean that I have to log in to the Pi via SSH every time I want to scan a document?

I could, but I figured a batch file would probably work better so I can just call it from the Windows terminal, too.

@echo off
IF %1.==. GOTO NoFile
set filename=%1
plink -i "D:\Path\To\PPK\File" -batch user@raspberrypi "/usr/bin/hp-scan --mode=color -r 600 --output=/path/to/output-folder/%1"

  echo No filename specified.

:EndCode language: PHP (php)

I use plink to connect to my Pi via SSH and I’ve set up private key authentication so it doesn’t ask me for a password every time. Now, in the Windows terminal, I just type docscan myfile.jpg and I’ll have my scanned document in the NAS in a few short moments.

All-in-all, the printer was a great buy, and the Raspberry Pi saved me a lot of hassle. 10/10 would recommend not splurging for a higher-end model if you can do it yourself.