WiFi Print Server: From a Raspberry Pi Zero W to Windows 10/11
by brighterfusion in Circuits > Raspberry Pi
11346 Views, 6 Favorites, 0 Comments
WiFi Print Server: From a Raspberry Pi Zero W to Windows 10/11
Make your USB printer into a WiFi connected printer which can been seen from Windows.
This is an updated guide for 2022 and will work where older guides may not due to changes in Windows protocols.
I've tried to make this guide as simple as possible. I found that it was more work to try to make the printer appear in the File Manager under Network than it was to add it using the command prompt.
[If you're really interested in making the print server and its printer appear while browsing the Network in Windows, look into putting WSDD on the RPi and possibly turning on SMB1.0 in Windows Features. SMB1.0 is a security hazard.]
Supplies
RPi Zero Wireless with a case.
- To buy a RPi board during the 2020+ shortage, look for used ones in a marketplace such as Craigslist or eBay, or sign up for availability notifications at pishop.us.
Fast, not-too-big MicroSD Card:
Cables:
- MicroUSB power supply. I plugged the RPi into my tower's USB out, but that will require the PC to be on for the printer to be available.
- MicroUSB OTG short cable:
- https://amzn.com/dp/B00N9S9Z0G
- Original USB cable for printer.
Prepare the MicroSD Card
Naming:
- For this guide, I'll be naming things as follows. Every time you see one of these names, replace it with your own.
- pi = username on the RPi
- print-server = the computer name of the RPi
- sam = the printer queue name of my Samsung Printer
- RPi is short for Raspberry Pi.
Download RPi Imager:
https://www.raspberrypi.com/software/
Launch. Select the desired OS image. (I chose RPi OS Lite, 32-bit, for the Zero.)
Click the gear icon to get to Advanced Options. Scroll to see all options.
- Turn on SSH.
- Hostname to "print-server".
- Set RPi un and pw. We are using "pi" for the username.
- Set Wifi, using 2.4 signal if you're using a Zero.
- Set locale.
"WRITE" OS to the card.
Go make coffee.
Initialize the RPi and Install Packages
Insert SD card into the RPi and power up. Give it a few minutes.
Find the IP address for printer-server on the router's LAN > DHCP page. Give it a fixed IP.
SSH into the RPi from Windows:
Open command prompt by typing: ⊞ Win+R > cmd > press Enter.
Copy and paste this command, replacing the username (pi) and server name (print-server) with your own:
ssh pi@print-server
Type in the password. Then you should be at the RPi's prompt.
For the rest of the guide, copy each of my example lines one by one and paste them into the SSH window. To paste inside the SSH environment, right-click and choose paste from the contextual menu.
Update and upgrade. You should go make some soup.
sudo apt update -y && sudo apt upgrade -y
Install the CUPS print server and SAMBA file sharing packages. This will take a several additional minutes.
sudo apt install -y cups samba
Config CUPS
Add an administrative user for the printer. Replace pi with your username.
sudo usermod -a -G lpadmin pi
Enable web-based admin pages.
sudo cupsctl --remote-any
Restart CUPS.
sudo systemctl restart cups
Config SAMBA
Edit config file:
sudo nano /etc/samba/smb.conf
Go to the bottom of the file. Ctl-V jumps you down one page at a time.
Under [printers]:
guest ok = yes
Under [print$]:
read only = no
Ctl-X, Y, Enter to save and exit nano.
Restart Samba service.
sudo systemctl restart smbd
On CUPS Config Web Site
- Shut down the RPi politely.
sudo shutdown now
- Plug the printer in with the USB OTG cable. Power up the print server. Turn on the printer.
- Go to the CUPS config web page: https://print-server:631/admin/
- Click through the warning about an insecure HTTPS connection.
- "Not Private" > Advanced > Proceed.
- Click the "Add Printer" button.
- Log in using your RPi un (pi) and pw.
- Select your printer from local printers. Continue.
- Fill out names as you prefer. I named my printer "sam". Check "Share This Printer". Continue.
- Find your Make. I uploaded a PPD file for a similar model Samsung printer (Samsung-M2022W-splix.ppd) which I dug up from a Google-cached version of a page on OpenPrinting.org. Continue.
- Set printer options. I kept defaults.
- Now you're under Printers menu. Administration pulldown > Set as server default.
- You're done here.
On the Windows PC
Enable the insecure guest logon:
- ⊞ Win+R > gpedit.msc
- Local Computer Policy > Computer Configuration > Administrative Templates > Network > Lanman Workstation > Enable insecure guest logons > Enabled > OK.
Use the Windows command line to add the new network printer. Remember to use your own names for the server (print-server) and printer (sam).
- Win-R, cmd, then:
rundll32 printui.dll PrintUIEntry /in /n \\print-server\sam
- Choose a print driver using the wizard.
- Set as the default printer in Windows. Print a test page.
- You're done! Good job.
Back Up Your New MicroSD Card
Now that you're finished with the installation and configuration, it's a wise idea to make a .img backup of the card. In Windows, use the "READ" function of Win32 Disk Imager. (I had to quit out of Google Drive before that app would open in Windows 11.)
For me, the writing process took a bit over one minute per GB to complete. (I recommend a 16GB card because a bigger card will only take longer to write the OS to and to back up, and will forever take up more storage space for the backup img.)
In case of need, you can use RPi Imager to burn that .img file to a new MicroSD card and you'll be back in business.
How to Label Your Tiny SD Cards
Wrap a 9mm label maker tape around the end and use it as a handle to remove the card.
Much Thanks To:
Similar guide to this one:
https://pimylifeup.com/raspberry-pi-print-server/
Another one:
https://www.tomshardware.com/how-to/raspberry-pi-print-server
gpedit fix:
https://forums.linuxmint.com/viewtopic.php?p=1878832#p1878832
Add network printer through the command line:
https://printerofflinehelp.com/add-network-printer-through-command-line/
Use tape to label microSD cards: