Linux Format

Pi Zero print server...............

Les Pounder shows how you can make use of an old printer using Wi-Fi and a Raspberry Pi Zero W to connect it to your home network.

-

Les Pounder shows us how to reuse our old printer using a Pi to connect it to our network.

Typically the Raspberry Pi Zero W is used to build embedded projects, robots and so forth. This is chiefly down to its small size and wireless package. But how can we use these features to reduce e-waste?

Well, remember that printer, the really good one that you’ve got stuck up in the loft? The one which doesn’t have Wi-Fi printing? In this tutorial we shall use a Raspberry Pi Zero W as a CUPS printer server to which we can print from our Linux (Ubuntu) laptop. The Pi Zero W will have our printer connected and will serve the print requests to the printer.

Setting up the Pi Zero W

Our first task is to install Raspbian Lite onto the microSD card. Raspbian Lite is a leaner version of Raspbian that doesn’t come with a desktop environmen­t, and it can be installed on SD cards as small as 2GB. The best tool to flash Raspbian Lite to an SD card is Etcher ( https://etcher.io) because it’s an easy-to-use GUI for this tricky task.

Once the card has been created, insert it into the Raspberry Pi Zero W, then connect your HDMI and keyboard. Finally, insert the power: your Pi will take a few moments to boot up and it’ll leave you at the login prompt. The username and password are the standard “pi” and “raspberry”. Once logged in take the time to change the password, because there are security issues that need to be addressed when using the Pi over a network.

In the terminal type the following, then when prompted enter your current password, followed by a new password. You’ll be asked to confirm the password is correct. $ passwd

Our Pi is still not on the network, nor the Internet. To do that we need to setup Wi-Fi. In the terminal we shall edit our wpa_supplicant configurat­ion – this will enable the Pi Zero W to talk to our router. Type the following: sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

We’re now using the nano text editor. Scroll to the bottom of the file using the arrow keys.

Add the following lines and change the “YOUR WIFI SSID” and “YOUR WIFI PASSWORD” to match your setup. network={ ssid="YOUR WIFI SSID” psk="YOUR WIFI PASSWORD” } Now press Ctrl+X then answer “Y” followed by Enter to save and exit. It’s also be a good time to reboot to ensure our changes have been made correctly. So type the following. $ sudo reboot Then, once the Pi has rebooted, log back in. With a connection to the Internet, let’s update the software on our Pi. Raspbian Lite, as its name suggests, is based on Debian. The package management tool is called apt (Advanced Packaging Tool) and we’ll first update the list of installabl­e software. In the terminal type. $ sudo apt update

Then we’ll upgrade the software installed to our Pi. The switch instructs the Pi to automatica­lly install the software $ sudo apt upgrade -y

Our final step with apt is to install the CUPS (Common Unix Print System) printing system. CUPS is developed as an open source technology by Apple, though was originally an independen­t project. To install CUPS, type the following into the terminal. $ sudo apt install cups

After CUPS has installed, we now need to ensure that our default user “pi” is in the correct group to print using CUPS. We’ll use usermod to modify the user, and will add ( -a ) the user to the group ( -G ) lpadmin. $ sudo usermod -a -G lpadmin pi

The next step is to set a static IP address for our Pi. This will help us locate the Pi on our network. In the terminal type. $ sudo nano /etc/dhcpcd.conf

Scroll to the bottom of the file where we’ll now write a section that will set a static IP address for the wireless interface (wlan0) of our Raspberry Pi. You’ll need to change the values to match your network. In our case we changed the ip_address to 192.168.0.99. interface wlan0 static ip_address= 192.168.0.99/24 static routers=192.168.0.1 -y

static domain_ name_ servers =192.168.0.1

Press Ctrl+X then answer Y followed by Enter to save and exit. Now let’s use SSH to unshackle our keyboard from the Pi Zero W. We need to enable the SSH server using the Raspberry Pi Configurat­ion tool. In the terminal type. $ sudo raspi-config

Then using the arrow keys navigate to Interfacin­g Options and press Enter. In the new menu navigate to SSH and press Enter again. Enable SSH by selecting Yes and press Enter. You can now exit the menu by navigating back to the start and selecting Finish. We can now remotely control our Pi using SSH, so let’s reboot the Pi and test our new configurat­ion. $ sudo reboot

You can now remove the keyboard from the Pi Zero W, and then connect your printer to the spare USB port. Then power the printer to ensure that Pi Zero W can see it’s attached.

Connect your computer

We now move to another computer, one from which we would like to print. In this case we used an Ubuntu laptop. Using the terminal on your Linux computer, or an applicatio­n like PuTTY for Windows, SSH into your Pi, using the static IP address that you set earlier. $ ssh pi@192.168.0.99

Once logged in you can administra­te the system and run routine updates to keep your system secure, if necessary. You can now close the SSH client because we no longer need it.

On your Linux computer, open a web browser and navigate to the IP address of your Pi Zero W, followed by 631. So in our case it’s: 192.168.0.99:631

You’ll see the home page, which has tabs across the top of the screen, and three sections in the centre. Our first task with CUPS is to set up our connected printer. Click the Administra­tion tab and then on the next screen click Add Printer. On first use, if you get an Upgrade Required warning, don’t worry, just click the link that it suggests. This might trigger a ‘Your connection is not private’ error. If so click ADVANCED and then select ‘Proceed to IP ADDRESS’. Next, you’ll be asked to supply your username and password – these are the same as those we used earlier.

In the Add Printer screen, CUPS should be able to detect your printer, especially if you’re using an older printer, which is the purpose of this project. If the printer is found, press the radio button next to it and then click Continue.

In the next screen, give your printer a name, descriptio­n and location. Then tick the Sharing button. Click Continue to move on to the next screen. Here we set the model of printer, which should be automatica­lly detected, but if not then change to suit your device. Then click Add Printer.

Our next screen sets the default options for the printer. These are your personal preference and you may need to do a little tinkering to achieve the best quality print. When done click Set Default Options. Your printer is now ready to use. Click the hyperlink to open the printer’s settings, and under Maintenanc­e select Print Test Page. After a few moments you’ll have a freshly printed page on your new wireless printer!

You now have a wireless print server powered by a Raspberry Pi Zero W. You can print to it using any Linux, Windows or Apple computer. And you’ve also got a bit more space in the loft to put some of that junk that’s been lurking in the spare room ever since you moved in…

 ??  ?? Nothing to do with hot beverages, CUPS will enable you to print from your Pi Zero W to any old printer.
Nothing to do with hot beverages, CUPS will enable you to print from your Pi Zero W to any old printer.
 ??  ??
 ??  ?? Rescued from the loft and put back into service, this old Epson printer is doing what it did best (12 years ago).
Rescued from the loft and put back into service, this old Epson printer is doing what it did best (12 years ago).

Newspapers in English

Newspapers from Australia