Today’s challenge: Raspberry Pi print and scan server

raspberry-piEver since the Raspberry Pi came out I’ve wanted to try it out but couldn’t find a compelling reason to actually go and buy one. The other day my family needed to print some documents from an iPad, which got me thinking that a wireless print server might be a good mini-project.

A quick trip to Amazon ended up with a small pile of boxes arriving this morning:

I decided to run the Raspbian OS and set up an SD card using the method listed on the Raspberry Pi site.

After doing the basics and configuring networking I had a look around for some apps that could help manage the RasPi remotely. First up was the RaspCTL web interface and in addition a mobile app for my Android phone called RasPi Check Although the RasPi can be left on drawing minimal power I still want to shut it down when not in use; the lack of a power button means an app to send it into halt state is essential.

Setting up the print server

The first part of the setup was pretty straightforward, thanks to two excellent guides from The AirPrint support was pretty much the key selling point for trying out the RasPi approach and works seamlessly.


I did make a couple of changes in addition to the steps in the guide

  1. Run the remote admin command below to allow the CUPS web interface to be accessed from my desktop (as the Pi hasn’t been connected to a screen or any input devices at any point in its life so far)
    cupsctl --remote-admin
  2. Although adding the printer via the CUPS interface works fine I found that my specific device (HP PhotoSmart C4400) needed a slightly different method to get all its features working – more on that below

Network scanner

Although I was very pleased with the print server I also wanted to try and add scanning functionality as well. A quick search found another excellent guide:


Following the guide was going well until it came to running the scanimage -L command where I just got an error saying no scanners were identified. Not so good 😦 A bit of research suggested not all printers are compatible with SANE but a lot of HP ones are via the HPLIP driver library:


Fortunately my PhotoSmart was on the list so the mystery deepens.

Troubleshooting commands

It turns out HP include various tools and utilities in the HPLIP package that can help identify what’s being detected (or not as the case may have it)


Running hp-check suggested the printer hadn’t been set up using the HPLIP drivers so I removed the existing object and re-installed it using the hp-setup utility instead. Looking at CUPS after using the setup method showed a different connection string, clearly now using the HP drivers:

hplip cups
However even after this running any of the scanner tools still failed all pretty much saying they couldn’t see a scanner, including:

  • hp-scan
  • sane-find-scanner
  • scanimage -L

By chance I decided to try running scanimage -L as sudo (rather than just the pi user) and there it was, one scanner detected!


Permissions issues – solved

A quick Google search for sane only working as root threw up a few more clues as well a workaround.


However that did involve running saned as root, which would get around the sudo issue but felt a bit of a sledgehammer to crack a nut as well as being a poor choice from a security point of view. OK it’s only a print server but best to not get into bad habits!


A few more posts expanded on the permissions issue so I decided to check what was set on my RasPi’s USB devices. Firstly run

lsusb -v

to find where on the USB bus the printer resides:


then run

ls -alh /dev/bus/usb/001

to view permissions on all devices connected to USB Bus 001

ls dev bus usb

Now the problem becomes apparent; the 005 entry (aka our printer) only has write permissions for root and the lp group. Interestingly the SANE documentation says to add the saned user to a group called scanner but no mention about the lp group. Further reading suggests it’s a peculiarity that often occurs with HP all-in-one devices.

I then added the saned user to the lp group and checked membership

usermod -a -G lp saned
groups saned

groups saned

To be sure all changes took effect the RasPi was rebooted and I tried connecting through my SANE client again, this time the printer was listed correctly in the devices list and scans worked perfectly 😀

SANE clients

On Linux there’s plenty of SANE clients to choose from but not so much for Windows. Some guides suggest using SaneTwain but it kept crashing on exit so I looked around for something else.

A better option looks to be SANEWinDS, which although listed as an alpha product has been pretty stable, certainly more so than SaneTwain.

In terms of Android apps SANEDroid seems to be the best one I’ve seen so far so that gets my vote for mobile use.

CUPS admin

This morning I went to use the Pi for printing and nearly sent myself crazy trying to figure out why I wasn’t able to manage the printer. Instead of being able to Pause \ Resume \ Cancel \ Delete jobs I kept getting met with a “Job operation failed Forbidden” error.

The last part of led me to the answer; somewhere along the line I’d missed the -a argument when using usermod and deleted some of the original group memberships that the pi user was given. One of those was lpadmin which was the only entry in the cups-files config entry with ability to manage the CUPS system.

A quick tweak with usermod and I’ve got my admin powers back!

Whilst searching I also came across which is also a good introduction to managing CUPS and administrative permissions for it.

RasPi speaker and startup sound

Although I can tell roughly when the Pi has finished booting up based on the internal LEDs and Wi-Fi receiver activity I figured it’d be nice to have something a bit more obvious there as well. I figured it must be possible to quickly rig up an old PC speaker to the RasPi and sure enough there’s another guide for it:


Fortunately amongst my piles of old PC parts I had a piezo speaker and some spare pin header connectors so hooked it up as per the guide. Since I have a Model B+ there’s more pins than on the guide but the top half of the GPIO connector is the same across all models.

There’s a great image overlay showing all the pin-outs on this site but for some reason the image has been mirrored so unless you’re adept at reading back-to-front it’s best to download it and flip it back the right way around!

a small screwdriver or pick tool comes in very handy for releasing pin head connectors

a small screwdriver or pick tool comes in very handy for releasing pin header connectors

I’ve stuck with the Mario tune used in the example for the startup sounds as it fits pretty well, once compile to run it I’ve edited /etc/rc/local as per the instructions here. I’ve also added a small wait before the program starts as initially it was a bit laggy, as if another process hadn’t quite finished before handing over before rc.local ran.

(sleep 5;sudo /home/pi/wiringPi/examples/newTone)&

After restarting with sudo reboot the sound loaded as expected.


3 Responses to Today’s challenge: Raspberry Pi print and scan server

  1. Tobi says:

    Thanks for that comprehensive and useful guide!! I did the same and it works fine. Now I want to go one step further: Use the buttons of the HP to scan directly (without a PC) to my NAS. Would be great if there is a guide on how to do that, but I couldn’t find anything. “Scanbd” should do the trick, but I couldn’t find out, how to configure it on the Raspberry Pi to work with my HP.

  2. MrLevis says:

    Great tutorial, helped me get the Scanner working.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: