Wireless Printing Using a Raspberry Pi

Matt Kmety
The KickStarter
Published in
8 min readJul 9, 2020

How to turn your old printer into a network printer using a Raspberry Pi as a print server.

Image by Darwin Laganzon from Pixabay

I’ve had my Brother HL-2170W printer for over 10 years. The built-in wireless printing feature is what made this printer great.

Sadly, the wireless card and NIC bit the dust quite some time ago. Printing from a USB cable was still an option, but it was an inconvenience to plug in my laptop or desktop each time I needed to print. I knew there had to be a better way.

I recently stumbled upon CUPS (Common Unix Printing System) developed by Apple. My Raspberry Pi was the perfect candidate to be a print server on top of the other things it already does today.

Sure enough, we can install CUPS, connect the printer to the Raspberry Pi, and print from our devices on our local network. Simple setup, low maintenance, and highly convenient.

Requirements

  • Raspberry Pi (Any model should work)
  • Raspberry Pi OS (Any Linux Distro should work)
  • Printer
  • USB AB Cable (standard printer USB cable)
  • Internet
  • Optional — Windows 10 system

Step 1 — Install CUPS

Open a terminal on your Raspberry Pi and run the following command to install CUPS.

pi@raspberrypi:~ $ sudo apt install cups -y

Note: The download is ~62 MB.

Several packages are downloaded and installed. Installation time will vary based on your internet speed and Raspberry Pi specs. On average, it should only take a couple of minutes to download and install.

You can verify that CUPS has been installed by checking if CUPS is running any processes. Run the following command to verify CUPS is running.

pi@raspberrypi:~ $ ps ax | grep cups
1867 ? Ss 0:00 /usr/sbin/cupsd -l
1918 ? Ssl 0:00 /usr/sbin/cups-browsed
3930 pts/1 S+ 0:00 grep --color=auto cups

You should see 2 processes running as shown above.

Step 2 — Add account to lpadmin group

The lpadmin group is used by CUPS to determine who is authorized to administer the printers. We will need to add our account to this group.

Note: The default account on Raspberry Pi OS is named ‘pi’. You will need to substitute the name of your account in the commands below if you are using a different account.

Run the following command to add your account to the lpadmin group.

pi@raspberrypi:~ $ sudo usermod -a -G lpadmin pi

The -a flag appends the user in the command to the specified group in the command.

The -G flag is used to name the group in which the account will be added.

We can validate our account has been added to the lpadmin group by running the following command.

pi@raspberrypi:~ $ groups pi
pi : pi adm dialout cdrom sudo audio video plugdev games users input netdev spi i2c gpio lpadmin

Our account is now part of the lpadmin group.

You can close the terminal window. It won’t be used anymore throughout this guide.

Step 3 — Connect your printer

You now need to connect your printer to your Raspberry Pi via a USB cable.

Make sure your printer is powered on and connected.

Photo by Clint Patterson on Unsplash

Step 4 — Adding a Printer

Launch a browser on your Raspberry Pi and type the following into the address bar.

https://localhost:631

You will be prompted with a warning stating your connection is not private. You can click ‘Advanced’ and then click Proceed to localhost.

Click Administration at the top of the page.

Note: You may be prompted to authenticate with the username and password of your account. If so, enter your username and password when prompted.

The default username is ‘pi’ and the default password is ‘raspberry’. Hopefully, you changed the default password.

Click Add Printer.

Several options may be displayed. There may be several options per printer. If there is more than one option for your printer you may need to repeat this process to figure out which one works best.

Add Printer

I am using a Brother HL-2170W series printer which shows in our list as a local printer. Fortunately, there is only one option for me to select.

Select your printer and then click Continue.

The next screen shows information about your printer. You can customize this any way you want the information to be displayed. I added ‘Home’ as the location.

You want to select ‘Share This Printer’ so that other devices on your network can send print jobs to your printer.

Printer Information

Select Continue.

The next screen will ask you to select the Model of your printer.

Printer Model

Unfortunately, the Brother HL-2170W printer is not an option to select. There is a workaround for these types of situations.

I had to look up the specifications of my printer and look for the emulation type.

My printer uses PCL6.

I had to click ‘Select Another Make/Manufacturer’ and choose ‘Generic’ from the Make list. I then selected Continue.

Note: You only need to choose the Generic make if your printer is not available in the list. You will need to do research on which emulation your printer utilizes. You may have to try a few different drivers to find the right one.

Make/Model

I then selected the ‘Generic PCL 6/PCL XL Printer — CUPS+Gutenprint v5.3.1’ Model.

Select Model

Click Add Printer.

You are now presented with the Default Options for the printer. If you have preferences you can make the changes here. Changing these is optional but realize that you will need to select Letter under the Media Size for 8.5x11 inches — only if you use standard US Letter paper.

Set Default Options

Select Set Default Options.

You’ll be shown a screen letting you know your settings have been saved.

Default Options Confirmation

You will then be redirected to the print queue.

Print Queue

Congrats! Your printer is now installed!

Step 5 — Test printing locally

Since we are already connected to our Raspberry Pi, I recommend we test printing to our newly configured printer. There may be a chance that the driver we installed is incorrect.

Launch LibreOffice and type in some sample text.

Click File and select Print.

File > Print

You should now see your printer as an option.

Select your printer and click OK.

LibreOffice

Your document should have printed.

Note: If your document is showing symbols that means the incorrect driver has been installed. You need to go back and update the driver. This can be done by either selecting Administration > Modify Printer and going back through the pages or you can delete the printer and recreate it.

The following steps will walk through how to share your printer, add it to a Windows machine, and test printing over WiFi.

Step 6 — Share Printers

We now need to ensure the printer is being shared on our network.

Click on Administration and select ‘Share printers connected to this system’.

Share Printers

Select Change Settings.

The CUPS server will be restarted. This only takes a few moments.

Server Restarting

Your printer should now be shared and available on your network for devices to add as a printer.

Step 7 — Adding a printer to Windows 10

In this step, we will add the printer to our Windows 10 system.

Click the Start menu and type ‘printers’.

Start Menu

Select Printers & Scanners.

Select ‘Add a printer or scanner’.

Add a printer or scanner

Your printer should show up as an option.

Note: If it doesn’t, you may need to click ‘The printer I want isn’t listed’ and troubleshoot the problem.

You can also add printers using the URL http://[raspberry_pi_server_IP:631/printers/[name_of_printer] but that is beyond the scope of this guide.

Printer

Select your printer and click Add Device.

Add device

The printer will be added as a device and available for use.

Printer Available

Step 8 — Test printing from Windows 10 system over WiFi

Launch a text editor program, such as Microsoft Word, and type in some sample text.

Click File and select Print.

You should now see your printer as an option.

Select your printer and click Print.

Your document should have printed.

Wrapping Up

Using CUPS and a Raspberry Pi we were able to bring new life to an old printer. We no longer have to connect a USB cable to our printer every time we need to print something and I no longer have to spend $199 on a new wireless printer.

There are advanced features in CUPS that were not covered in this guide. Be on the lookout for a guide that allows you to print from your iOS devices using AirPrint.

If you have any questions feel free to Tweet or PM me @mrkmety

--

--

Matt Kmety
The KickStarter

Cybersecurity Enthusiast | Cloud Security & Information Protection @ Boeing | Trying to pass on knowledge to others | www.thecyberblog.com