Use a Raspberry PI Zero W as a Wi-fi Print S… | element14

Hello all !


Immediately, I will share a "hack" that I take advantage of in my work when a printer (Laser A4 or labels - Zebra printers) would not has community connectivity or a community wall socket shouldn't be accessible - however WIFI is current.

Utilizing a Raspberry PI Zero W I can share the printer with greater than 1 shopper . To today, I've 8 working with out a drawback and extra are but to come back.


It is a neat answer that solves lots of issues:

  • I haven't got to depend on a pc (Home windows) to be on on a regular basis for somebody to have the ability to print.
  • It is extra secure and dependable
  • Solely requires WIFI
  • Set up on Home windows is straightforward


After all, there are some downfalls as nicely:

  • Yet another pc to have (albeit being a low energy Raspberry PI W)
  • Not appropriate with applications/{hardware} that require a socket connection to a 900X port


However, it does present an answer that works for me in some ways and permits many computer systems to have the ability to print.



There's only some necessities wanted with a Raspberry PI Zero W

  • USB OTG cable - to attach the printer
  • Printer with USB interface (so, to not outdated printers)
  • Energy the RPI W with an influence adapter, not a pc USB port.



There are the steps we will take - easy and few

  1. We'll set up Raspbian OS Lite
  2. Configure CUPS and set up a printer
  3. Configure SAMBA


Every step is straightforward and the configurations are very simple and quick.


Raspberry PI

First, let's set up the Raspberry PI Zero W.

A 8GB SD CARD is sufficient. I take advantage of the Raspberry PI Imager. It is quick and there isn't any have to obtain the img file. Additionally, it downloads the newest model accessible.

Raspberry PI Imager

For this, the Raspberry PI OS Lite is sufficient.  Let's select it - Second possibility (Different) - Raspberry PI OS Lite

Raspberry PI imager choose OSRaspberry PI imager choose OS


Subsequent, you must insert the SD Card within the reader and select it.

REMEMBER: All that it is inside, will likely be destroyed !

Raspberry PI imager choose storageRaspberry PI imager warning


And subsequent, press WRITE and wait

Raspberry PI imager write

and accomplished.

Raspberry PI imager


Headless setup

We will now carry out a what's referred to as a headless setup. We do not want a mouse, keyboard or monitor to have the ability to remotely entry the Raspberry PI .

Utilizing Home windows, Mac or Linux, you now have a brand new partition (or drive letter) in your file supervisor - take away the SD card and insert it once more if nothing reveals up - it is the boot partition.

That is it on Home windows


We are going to now create two recordsdata right here: ssh and wpa_supplicant.conf .

If you're in Home windows, with Powershell simply execute New-Merchandise .



With Linux or Mac, simply use the contact command (assuming your present location is the boot partition)


contact ssh
contact wpa_supplicant.conf


The ssh file can stick with 0 bytes - when booting, the Raspberry PI OS will, if the file is current, allow the ssh service

For the wpa_supplicant, we have to create some configuration. Simply edit the file together with your favourite editor and put the next traces in it:


vi wpa_supplicant.conf


nation=<your nation 2 letter code>
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev



The traces above, within the community part, these traces are those wanted to hook up with a WPA/WPA2 community that is broadcasting the SSID.

It's good to change the <your nation 2 letter code>. With out it, WPA_SUPPLICANT will not work.

Unmount the SD Card and put it on the Raspberry PI.


I will assume you have got a DHCP server on the community and now the best way to discover the IP deal with of the Raspberry PI.

Pimoroni has a great tutorial on how to do that.


If it's essential to give a static IP deal with to the Raspberry PI, you then want a keyboard, mouse and monitor.

Raspberry PI documentation explains very well that step.


Software program

After the PI boots and you understand it is IP deal with, lets entry it utilizing ssh and replace the software program

ssh pi@<ip_of_rpiw>

The default password is raspberry. You SHOULD CHANGE IT :



sudo raspi-config


Choices 1 and S3



You possibly can, if you need, set a root password. As pi consumer, simply use sudo to launch a bash as root and set a brand new root password

sudo bash


and set a root password. You'll not lose the power to make use of sudo with the pi consumer, however may have root with an outlined password.



Let's replace the software program

sudo apt-get replace
sudo apt-get improve -y




After the reboot, let's set up cups and samba

sudo apt-get set up samba cups -y


Configure CUPS


First, let's configure CUPS to permit us to entry the Net Interface and use the DNS identify as an alternative of simply the IP deal with.

Observe: Make a backup of the file first, simply in case


sudo vi /and many others/cups/cupsd.conf


We simply want to vary a line and add 3 new ones

Substitute the next line:

Pay attention localhost:631


Port 631


This can enable us to entry CUPS internet Interface from one other pc.

Subsequent, simply earlier than the primary <Location /> tag, , add the next line:


ServerAlias *


This can enable us to additionally use DNS as an alternative of simply the IP deal with


Now, contained in the <Location /> and <Location /admin> blocks, add the next line, simply after Order enable, deny

Enable <your_computer_ip_address>


Or, if you wish to loosen up a bit, you should use a community vary or simply all:



Enable All


This can keep like:

<Location />
    Order enable,deny
<Location /admin>
    Order enable,deny


the place is my IP deal with


Let's add the PI consumer to the lpadmin group

sudo gpasswd -a pi lpadmin


Though gpasswd would require to login once more for the adjustments to take impact, we do not want it as a result of it is going to be the cups service that can get restarted and thus, we do not want the group within the present session . However be happy .


This can enable the pi consumer so as to add, take away and configure printers


Now, let's allow cups and begin it (or restart it)

sudo systemctl allow cups
Synchronizing state of cups.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install allow cups

sudo systemctl begin cups


Add a printer to cups

That is the traditional process - add a printer to cups on any Linux, utilizing the CUPS Net Interface.


Open your browser of alternative and head to:

https://<your_pi_address/identify>:631 and you'll land at CUPS internet


On CUPS Administration, press the "Add Printer" button

On the Printers record, we wish the Native Printers - linked to USB. Select the one you are connecting. In my case, a HP LajserJet 1022 - outdated, I do know.

Fill in all the main points. The identify is specifically vital, because it's by it we'll attain the printer. My recommendation is DO NOT USE SPACES.

Remember to tick the "Share This Printer" field.


On the subsequent display, select the drivers

To terminate, simply set the default choices for the printer and you're prepared. Choices could differ in keeping with printers and drivers.

Now that cups is ready, let's configure SAMBA to share the printer with Home windows.


Configure SAMBA

We'd like SAMBA to have the ability to add the printer on Home windows. We will configure samba in some ways, however for this to work, we simply want so as to add a line and alter one other.

IMPORTANT NOTE: That is the minimal method to enable Home windows to print to any printer configured on the Raspberry PI. There is not any safety in any way, which means that, any consumer will be capable to print to this printer - simply wants so as to add it to its Home windows S.O.

SAMBA can be utilized to share folders and even enable Linux customers to logon, with all the safety measures and insurance policies that SAMBA/Linux and Home windows Lively Listing will present.

With a minimal setup, we may do that and simply enable sure customers/computer systems to print to this printer, however that is past this tutorial.

There are lots of good ones on the market. You possibly can learn this one and this one. And, of couse, the official Samba Wiki.


Along with your editor, open up smb.conf

sudo vi /and many others/samba/smb.conf


You possibly can learn round and alter, by instance the Workgroup if you need.

On the [GLOBAL] part, add the next line simply earlier than the [homes] part


load printers = sure


And, within the [printers] (there's additionally a [print$] part - NOT THAT ONE) part, change the next line:

visitor okay = no


visitor okay = sure


Save the file and let's allow and begin samba

sudo systemctl allow smbd
Synchronizing state of smbd.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install allow smbd


Let's begin samba

sudo systemctl begin smbd

Let's add the printer to Home windows


Go to Management Panel -> Gadgets and Printers and press the "Add a printer" button.



Within the subsequent display you may see some printers accessible. Simply press "The printer that I need is not listed".

Within the subsequent display, we have now two choices so as to add the printer linked to the Raspberry PI.

We will use the third possibility - "Choose a shared printer by identify" or the final one - "Add a neighborhood printer or community printer with guide settings".


Each will likely be utilizing the identical parameters and the identical printer path, the previous with much less steps. The primary distinction between them is that, utilizing the third possibility - Choose a shared printer by identify - is not going to let you change the printer's identify.

When utilizing the third possibility, on the ultimate display - you may't change the printer's identify.

Let's proceed by selecting the final possibility.  Create a brand new port with Native Port as the kind of port

Now, enter the trail to the printer.

The trail is: <raspberry_pi_IP_OR_DNS><printer_name>


Subsequent, Home windows will ask you to pick out a driver for the printer.


On the subsequent display, select a reputation for the printer


Now you have got the choice to share the printer - you may shared it when you like or want.

Last display.

As you may see, all of the choices are the identical as if a neighborhood printer is put in.


And, similar to this, you may flip an outdated printer, a printer with out community or a networked printer with out community wall socket right into a shared printer with wifi !

Source link

Leave a Reply

Your email address will not be published. Required fields are marked *