Setting Up a Raspberry Pi 3 as a Print Server

Since the dawn of the digital age, man has been trapped in a never ending struggle with printers.  Total disaster.  I hate printers.  But this post isn’t about ranting about how terrible printers are in general – its about getting one to work wirelessly.  Since my wife and I switched exclusively to laptops, and I decommissioned (read – drive failed and its sat in various states of disassembly for 3 years) my last desktop that acted as a file and print server in our home office, we searched for a “wireless printer” that actually consistently works.  We’ve gone through several of various brands and while they “work” part of the time, we’ve never found one that was reliable and consistently stayed connected to our home network.  The latest, a Brother MFC-L2740DW multi-function laser, had the nasty habit of going “offline” to save power approximately every 24 hours.  Searches online yielded tons of posts with the same issue, and apparently there being no solution other than literally turning it off and turning it back on again.  Sure, you have to physically go to a printer to pick up what you printed, but wtf?  My thermostat can stay connected 24/7 but a several hundred dollar printer cant? Sorry, I said I wasn’t going to rant about this…

So the solution that I decided to try was to set up another dedicated print server to physically attach the printer to, hopefully keeping it “online” all the time and allowing the server to manage the wireless connectivity instead of the printer itself.  But I did not want to have to power and manage an entire desktop just so the printer is always at the ready.  Enter the Raspberry Pi.  For those unaware, Raspberry Pi is the name of a popular company that makes a series of small single board computers of the same name.  For this project I purchased a Raspberry Pi 3 Model B along with a kit containing a power supply, micro usb card pre-loaded with Raspbian (a Debian based Linux distribution for Raspberry Pi), a tiny little case, and even tiny little heatsinks.  The total cost for the kit was ~$50.  The Raspberry Pi 3 itself is about $35.

(Raspberry Pi 3 Model B)
This was my first project with a Raspberry Pi, and the first time I dabbled with Linux at all in a number of years.  So I had to fumble my way through getting it set up, connecting to it remotely from Windows, getting the printer working on the Pi, and finally getting our Windows machines to print through it.  Though in the end it was pretty simple, hopefully this post will help overcome some bumps I had along the road.
Pi Set Up
Getting the RPi up and running was simple enough.  The kit I got was from https://www.loverpi.com/ and it came with an 8GB Micro SD card preloaded with Raspbian as well as a bunch of software.  All I had to do was put in the SD card, dig up an old USB keyboard and mouse, hook it up via HDMI to a TV, and plug it in.  It booted right up to the GUI and was straightforward to connect the built in Wifi.

Enabling VNC
First order of business was getting VNC set up so I could stop using a terrible old USB keyboard while sitting on the floor in front of the TV.  From what I had read, Real VNC should have been included with the version of Raspbian that had come preloaded, and all I had to do was go to Menu > Preferences > Raspberry Pi Configuration, click on Interfaces, and Enable VNC.  But when I went to this screen, the VNC option wasn’t there.  So I figured I would try to update Raspbian to get the latest packages.  Again, its been a while since I’ve used Linux, and it was never very much, so I’ll show the terminal commands I used, but I’m not going to get into exactly what everything does here – because I probably don’t even really know.
sudo apt-get update
sudo apt-get upgrade

After updating Raspbian, which took a while because it downloaded a lot of updates, after I rebooted the RPi, the above VNC option WAS there for me to enable.  Then I just had to download the RealVNC viewer for Windows – https://www.realvnc.com/download/viewer/ –  on to my laptop and I was able to connect remotely to the RPi just by using the IP Address in the VNC Viewer address bar.

 Now I was able to safely put the RPi into its tiny little clear case, connect it to the printer via USB cable, and hide it away in the office.  I also attached an mSATA USB adapter for some extra storage with a spare mSATA drive, but that’s not required for this project.

Setting up CUPS

So next was to get the printer working locally with the RPi.  For that I turned to CUPS (Common UNIX Printing System), because that’s what the internet told me to use to set up a Linux system as a print server.  CUPS was already installed as part of the pre-loaded software on Raspbian, and I knew it was updated from earlier, so I should have just been able to go to its web interface and configure the printer.  Wrong.

To administer CUPS, you point your web browser (on the RPi) to http://localhost:631/ to get the admin screen shown below.

But clicking on “Adding Printers and Classes”, popped up a username/pw screen, which the instructions said to log into with your root user account, but even that yielded: “Unable to add printer: Forbidden”.

This was a spot where Linux knowledge would probably have helped.  Basically the CUPS software creates a user group called lpadmin on the machine, and a user must be a member of it to do anything via the web interface – but it doesn’t automatically add anyone to this group, not even the root user.  Though its a different Linux distrobution, I found the Ubuntu CUPS help page helpful https://help.ubuntu.com/lts/serverguide/cups.html

So as instructed in that link, I had to add the root user (in the case of the Rpi, root username Pi) to the lpadmin group.

sudo usermod -aG lpadmin username

NOW I was able to click on Adding Printers and Classes > Add Printer and select my already recognized printer.

You then have to select your make and model of printer to pick the correct driver.  The Brother MFC-L2740 was not listed.  I was able to find a Debian printer driver for this model on Brother’s support page, and although it installed on Raspbian, it is built for a different architecture and would not print.  Many people online seemed to have luck selecting similar model printers, so I gave the Brother MFC-9600 – CUPS+Gutenprint v5.2.10 driver a shot, and amazingly it worked!

I was able to click the Maintenance drop-down and successfully print a test page.

Adding the Printer to Windows Machines

After getting the printer set up on the RPi, the last thing to do was be able to add the new network printer to our Windows laptops.  Viewing the Network tab on Windows did not list the RPi on the network.  What I needed to do was allow file and print services to be shared from the RPi to Windows.  To do this, I needed to install Samba which is explained simply enough here – http://www.deviceplus.com/how-tos/raspberrypi-guide/raspberrypi_entry_006/

Install Samba:

sudo apt-get install samba

Edit Samba config file with nano text editor to set your Work Group and enable WINS support:

sudo nano /etc/samba/smb.conf

rasp06_img04

Scroll down through the config file and set the below attributes, then press CTRL+O to “WriteOut” aka Save the changes.

workgroup = your_workgroup_name
wins support = yes
 After making these changes we need to restart Samba.
service smbd restart
Now when we go to the Network screen in Windows, we can see the RPi on the network!

And within the RPi on the network we can find, and add, our printer!

In order to properly add the printer to Windows, the Windows machines should have the necessary printer drivers installed so you can select them when you Right Click > Connect on the printer you want.

Summary

After following the above steps, you should be up and running with a Raspberry Pi print server that you can connect to wirelessly with a Windows machine.  With this set up, the printer and the print server should be able to remain on and ready for use while only consuming a very small amount of power.  I have not yet tried to set up and use the scanning functions of the multi-function printer, but by now having Samba set up, I should be able to easily share files and folders as well and be able to scan directly to the RPi and access the files from any other machine on the network.  Along the same lines, the mSATA adapter pictured above can be used as shared storage via the RPi as a file share.

Leave a Reply

Your email address will not be published.