Categories
Allgemein

Raspberry Pi Printserver for HP CP1025nw

In 2014 I bought a HP CP1025nw color-laser printer for an incredibly cheap price. Now in 2019 I changed the first black cartridge and all the colors are still at 30% – so that’s how much I print 🙂 The printer itself comes with a USB-port, WiFi and a LAN port. So there should be plenty of options to connect it to any device or get it working with any device. The only missing feature is AirPrint, but that was a trade-off I made for the price.

It worked with High Sierra and Mojave

I’m using the printer mainly with my MacBook Pro and until macOS High Sierra everything worked fine. With the upgrade to macOS Mojave the problems started. Printing from Chrome or Preview did not work anymore – but I was able to print everything fine using Adobe Acrobat Reader. As converting nearly anything to PDF in macOS is very easy that was an acceptable workaround.

But it stopped working with Catalina

With macOS Catalina even the workaround did not work anymore and I was faced with the question, how do I get the printer to work again. A quick an easy option could have been to just buy a new one, but technically the printer is just fine – so I decided to give it a try and use one of my Raspberry Pi 3 B+ to setup a printserver. A little bit of research and I was confident that it would work and in addition I would get AirPrint capabilities, which I don’t necessarily need but a nice add-on.

Buster, CUPS and hplip – should work right?

So I started putting a Raspbian Buster image on the SD-card using ApplePi Baker 2 and started the Pi. Finally the usual steps bought after installing CUPS and hplip I was able to see the printer connected to USB (lsusb), but I was not able to find the printer using the CUPS web-ui. Also hp-setup was not able to find the printer. So I started investigating. Multiple sources mentioned to make sure the printer is not in sleep-mode others mentioned it will not work using hplip instead it would work using the foo2zjs driver. Setting permissions for CUPS and it’s usergroup to access the USB-port did not help.

I also tried different versions of hplip and tried to install the hplip-plugin in an older version to see if the printer was maybe not supported anymore in the latest version – but still no success. All did not work.

“Smart” but not so smart.

So what finally resolved my problem and also explained why it was not working was revealed by hp-health. But before we get to that a short comment on hp-check.

Everytime I ran hp-check, two points were empty. “Discovered USB devices” and “Permission”. First I thought it might be a permission problem, but after changing all kinds of permission on all kinds of groups to allow the access to the USB device – still no success.

Finally I ran hp-health – and this discovered that my printer had some feature activated called SmartDiscovery and hp-health explained that I would have to deactivate it to be able to install the printer correctly. I was not able to download the tool directly, but found a working version here. So I found this tool to deactive it and finally after running hp-health and hp-check again the Pi was able to “see” the printer in CUPS and hplip. Btw, I also tried to find it on the network using a LAN connection but that also did not work until I disabled this not-so-smart smart feature.

Just because you see me does not mean you can print 🙂

Now I tried to run the printer using CUPS with the hplip provided drivers and the necessary plugin – the document was added to the queue but not printed. Also trying to print a testpage from hplip did not work.

So as I had read multiple times that it would not work using hplip I removed everything and started investigating the CUPS and foo2zjs approach. And after some back and forth with the foo2zjs driver I tried to plain driver provided with CUPS – and it worked.

So what did I do?

Here now the steps I did to (hopefully) reproduce it 🙂

Download Raspbian Buster from 2019-09-26 and Apple Pi Baker 2 to prepare the micro SD-card.

Enable ssh and configure your WiFi or LAN

Connect to your Pi using ssh, for example on macOS:

ssh <user-on-RPi>@<IPv4-of-your-RPi>

Update and Upgrade packages

sudo apt-get update

sudo apt-get upgrade

Install CUPS – I’m running 2.2.10

sudo apt-get install cups

Configure CUPS

sudo nano /etc/cups/cupsd.conf

Replace line Listen localhost:631 with Port 631

Add new line BrowseAddress @LOCAL

Now add Allow @LOCAL in each of the blocks

# Restrict access to the server...
<Location />
Order allow,deny
Allow @LOCAL
</Location>

# Restrict access to the admin pages...
<Location /admin>
Order allow,deny
Allow @LOCAL
</Location>

# Restrict access to configuration files...
<Location /admin/conf>
AuthType Default
Require user @SYSTEM
Order allow,deny
Allow @LOCAL
</Location>

Save (CTRL+O) and close (CTRL+X)

Add the user to the lpadmin group (in this case user is default user “pi”, but if you created your own use that one instead)

sudo usermod -aG lpadmin pi

Now restart CUPS to apply all changes

sudo service cups restart

Now you can check at the CUPS web-ui if you can already see your printer. (Chrome might complain because of the SSL certificate, but Safari worked by simply accepting the risk 🙂

https://<IPv4-of-your-RPi>:631

Go to “Administration” -> “Add Printer”. If you see your printer there give it a try. Otherwise you might have to disable the smart stuff or just switch on your printer 🙂

Disable the smart stuff

wget http://hplipopensource.com/hplip-web/smartinstall/SmartInstallDisable-Tool.run

and run it

./SmartInstallDisable-Tool.run

In a perfect world you should now see you printer on the CUPS web-ui. I had to disconnect the printer from it’s power source and start again – but that might be related to the different approaches and testpages I tried to print 😉

On the CUPS web-ui I opened again “Administration” -> “Add Printer”. Then in the list of “Discovered Network Printers” I selected the “Hewlett-Packard HP LaserJet CP 1025nw (driverless) (Hewlett-Packard HP LaserJet CP 1025nw)”

Important here in my case was to select the “(driverless)” option. Then “Continue” and as I wanted to share the printer across all devices (including iOS devices in my network) I enabled the option “Share This Printer”. Press “Continue”.

Now in the “Model” list I selected the option “Hewlett-Packard HP LaserJet CP1025nw, driverless, cups-filters 1.21.6 (en)”. And finally confirmed the selection with “Add Printer”

In the final step it will ask for the the default settings, I just accepted the ones given (A4, Color, Quality: Normal, Optimization: Text and Graphics)

Now I was able to add it in macOS and Windows 10 as well as on my iPhone – and I couldn’t believe it, it worked!

Last words

So thanks if you read the whole text, while maybe only the last part was really necessary. I wanted to share the journey and maybe the more detailed explanation helps someone facing similar issues with a different printer. From my point of view if mankind solves the problem of getting printers and meetings with screensharing, audio and projector working with any device by one click on a button – we are one step closer to concentrate on the important things in life 😉

Resources which helped me on that journey

https://www.elektronik-kompendium.de/sites/raspberry-pi/2007081.htm

https://answers.launchpad.net/hplip/+question/662395

https://www.raspberrypi.org/forums/viewtopic.php?t=118732

Leave a Reply