This tutorial will show you how to turn a USB printer into a wireless, AirPrint enabled printer using a Raspberry Pi. The shared printer will be accessible from Windows, Mac and of course, Linux devices.
Printers are one of the few bits of tech that haven’t really changed much in the last few decades. The only real change has been that they are increasingly locked down, they are expensive to re-fill, detecting generic cartridges and refusing to print unless an expensive name-brand cartridge is purchased. Some even force you to sign up for online accounts and undertake other invasive procedures just to print a document.
Older printers don’t suffer from all of these great user friendly ‘features’, and are often cheaper to buy ink and toner for. So, if you’ve got an old, reliable USB printer you want to keep around (and make usable from your laptops, phones and tablets), read on!
What You’ll Need
The ingredients for this recipe are pretty simple:
- A printer
- A Raspberry Pi
- A computer with an SD card slot (or an adapter) for writing the Raspberry Pi OS Image
- The Raspberry Pi Imager installed on that computer
- A keyboard/mouse/monitor for the initial Pi setup
- A network connection (of course)
Basically, you’ll be installing a Linux OS on your Pi, which is running software to easily share and manage printers on the network, you’ll then be able to connect the the printer via your Pi (wirelessly or wired).
Setting up the Hardware for Printer Sharing
Getting the hardware set up is also trivial.
- Plug your printer into the USB Pi’s USB port
- Temporarily connect keyboard/mouse/monitor to the Pi for initial setup
…All too easy.
Making a USB Printer Wireless Using Raspberry Pi – The Software
Raspberry Pi OS is a Linux-based operating system, with access to a huge number of software packages through the
apt package manager. It includes everything you need to set up a shared network printer. But first, you’ll need to install the OS itself.
Installing Raspberry Pi OS
First, you’ll need to install the Raspberry Pi OS. Insert the SD card from your Raspberry Pi into your computer, and run the Raspberry Pi Imager.
Click ‘Choose OS’ and select ‘Raspberry Pi OS (other), and choose ‘Raspberry Pi OS Lite (64-bit)’ if you have a Raspberry Pi 4, or ‘Raspberry Pi OS Lite (32-bit)’ if you are using any other Pi. We only need the lite version as no desktop applications are required to host a print server, but you can of course follow these steps on the Desktop version if you want to.
Next, select your SD card as the storage the OS should be written to (make sure you have the right one selected – everything will be overwritten!).
When you’re ready, click the ‘WRITE’ button and wait for the image to be written and verified.
When it’s done, take the SD card from your computer, and install it in your Raspberry Pi. Boot your Pi when you’re ready for the next step.
Installing Required Packages
Once you’ve configured you Pi by selecting a keyboard layout and adding a username/password, you need to get your Pi connected to your network. If you’re connecting via ethernet cable, just plug in. To configure WiFi, run the Raspberry Pi Configuration tool:
System Options and then
Wireless LAN , select your country, and enter the details for your wireless network.
After entering your WiFi credentials, select
Interface Options and then
SSH and enable the SSH server so that the Pi can be administered remotely (meaning we can remove the pesky keyboard/mouse/monitor and tuck the Pi behind the printer, out of sight).
Once that’s done, Select
To test that you are connected to the network, run:
To ping Google’s public DNS servers – if you’re online, you’ll see success messages that look like this:
64 bytes from 126.96.36.199: icmp_seq=0 ttl=116 time=49.180 ms 64 bytes from 188.8.131.52: icmp_seq=1 ttl=116 time=13.590 ms
If you see timeouts or other failures:
Request timeout for icmp_seq 0 Request timeout for icmp_seq 1
…follow the above steps again as you may have mis-entered your Wifi network name or password.
Now that you’re online, get the software on your Pi up-to-date by running:
sudo apt update sudo apt upgrade -y
Note: Make sure that you choose a secure username and password. We’ll be enabling SSH remote access on the Pi later on, so you don’t want anything that’s too easy to guess.
Detecting Your Printer
You can make sure that your USB printer has been detected by Linux by running:
Look through the list of devices and make sure your printer is present – mine looks like this:
Bus 001 Device 004: ID 0000:0000 Brother Industries, Ltd HL-121W series
Raspberry Pi OS comes with a number of built-in printer drivers, but if you find your printer is not working out of the box, you’ll need to consult with the manufacturers website to see if they provide their own Linux drivers.
Installing SAMBA and CUPS
Samba provides Windows file and printer sharing services from linux, and we’ll use it to share any printers connected to the Raspberry pi.
CUPS is the Common Unix Printer Service – the program that will manage and share your printer.
Install both by running:
sudo apt install samba cups -y
Next, add the user you configured earlier to the print admin group (if you do not do this, you will not be able to update the CUPS configuration from the web interface):
sudo usermod -a -G lpadmin USERNAME
Replace USERNAME with the username you set while initially setting up your Raspberry Pi.
Configure CUPS to accept external network connections from any source:
sudo cupsctl --remote-any
Getting the IP of your Pi
To connect to your Raspberry Pi remotely, you’ll need to know it’s IP address on the network. This can be found by running:
To make it easier to connect in future, I suggest setting a static IP address.
Reboot to apply any pending configuration changes:
Remotely Connecting to CUPS
Now that your Pi is on the network and CUPS is running, you can view the CUPS admin panel by navigating to
From a web browser on your computer. Click on the ‘Administration’ tab and you will see the following:
Add Printer and enter the username and password for your Raspberry Pi as set earlier. Then, select your printer and click
Then, set the printer name as your desired, check
Share this printer and click
Next, select your printer driver from the list of installed drivers. If your printer is not listed and a Linux driver is not made available, you have two options:
Rawto let the device that is printing via the Pi handle the driver (so, if you’re printing from a Windows device, drivers installed on that device will be used)
- If you want to try using generic drivers, select
Generic PostScript Printeror
Generic PCL Laser Printer(standards that many printers are compatible with)
Which one you select will depend on your printer and devices, so you may need to come back to this later and pick a different driver if things don’t work.
When you’ve selected a driver, click the
Add Printer button.
Configuring SAMBA for Windows Devices
Back on the Pi (Or via SSH as it’s now on the network), update the file
/etc/samba/smb.conf by running:
sudo nano /etc/samba/smb.conf
… and add the following lines to enable printing for windows devices:
# Provides a share for Windows clients to download printer drivers
comment = Print Drivers path = /usr/share/cups/drivers browseable = yes read only = yes guest ok = no workgroup = WORKGROUP wins support = yes
You may need to change the
WORKGROUP option if you use a different workgroup name. Save and exit by pressing
CTRL + X and reboot to make sure all changes are applied:
And we’re done! As you can see, the printer is now shared – here I’m adding it via my WiFi network from MacOS.
You can now connect from Windows, Mac, and Linux devices. Depending on how you configured the drivers above, you may not even need to source drivers for the device you are printing from.
If you’re looking to print from iOS devices (iPads, iPhones), check out our AirPrint article here.