Welcome to the next tutorial of our Raspberry Pi programming course. Our previous tutorial taught us to how to tweet from Raspberry pi. We also discussed some methods used by the tweepy library to perform some API calls in our project. We will learn how to print from a Raspberry pi in this lesson.
Where To Buy? | ||||
---|---|---|---|---|
No. | Components | Distributor | Link To Buy | |
1 | Raspberry Pi 4 | Amazon | Buy Now |
Let us get started
There are several benefits of having a print server. Print servers may link numerous computers to one or multiple printers, either physically or wirelessly, allowing you to access the printer with various devices and send print instructions from all the other connected computers.
It is not easy to print from an Android smartphone to a cabled printer; however, a printer server makes it simple. A print server is useful in small workplaces where employees may print from any business printer. Another benefit is that we do not need to install drivers and software for the printer on your devices.
Requirements
- Raspberry Pi
- USB Printer
- Ethernet Cable
- Power Supply
CUPS
The Common Unix Printing System is a printing tool for machines running UNIX-like operating systems. It enables the machine installed to function as a printer server. A CUPS-enabled computer may take tasks from numerous devices, process them, and send them to the right printer for printing.
Setup Print Server Software CUPS
With our Raspberry terminal, we will configure the typical Unix printing system.
-
Update Pi
We need to ensure that our Pi runs the most recent software; thus, we will carry out the following command in the terminal.
Once the installation is finished, we will restart our raspberry pi.
-
Use Static IP
A few system changes are required before utilizing the Pi as a "server" on the network. We must configure the dynamic host configuration protocol client to use a static Ip; otherwise, the DHCP client may choose any accessible network address, making it difficult to access the RPi over the network.
We begin by modifying the DHCP configuration file.
If you choose to create a static Ip for the wired connection or a Wi-Fi connection, add either one of the below.
- Interface: This is the network connection for configuring the settings.
- the static Ip address is the Ip you'll use to configure your device. (Don't forget to include a /24 in the end.)
- static routers: It is the default gateway.
- Static domain_name_servers: Your DNS server's IP address is this.
Save your file by pressing Ctrl Plus X, then Yes, finally Enter key. Lastly, restart your Raspberry Pi.
Note that your network setup may differ in address category and Ip. This step must be done carefully; otherwise, your Pi will experience connection troubles. Run the following commands and look at the inet and subnet mask numbers to know what IP address you'll need:
-
Install CUPS
The next step is to set up CUPS. This will take some time, but it will install with other requirements such as Samba, Perl, and several other tools or packages.
-
Configure CUPS
We have to make adjustments to CUPs' config file. The following commands can be used to edit the configuration file:
To the config file, add the following. We will be able to communicate with CUPS panels due to these modifications.
If you wish to change the Ip port, locate and modify this line.
In addition, if we want to use the CUPS Interface, you must accept requests coming from that domain. Just before <location> tags, we add these lines.
Save your file by pressing Ctrl + X, then Yes, accompanied by the Enter key.
-
User & Network Access Settings
The Raspberry user is then added to the lpadmin group. This allows the RPi to conduct CUPS administration duties without being a superuser.
We must guarantee that CUPS is available throughout the network.
Lastly, reboot CUPS to apply the modifications.
-
Setup Samba
Samba is an industry-standard Microsoft interoperable package for Unix systems. It allows our Windows operating system to connect to our CUPS central server on the Raspberry Pi and transmit print instructions from the Windows system.
We have to change Samba's settings in the config file before we can proceed with the setup:
Scroll down to the print area and alter the guest's ok to yes.
Scroll down to the printer driver area and change the line shown below
Save the script by pressing Ctrl Plus X, then Yes, accompanied by the Enter key.
Lastly, reboot Samba to see the modifications take effect:
How do we set up our printer?
Install Printer Drivers
You may need to install printer drivers. You can look for the instructions for your specific printer brand on the internet, but we'll be using an HP printer for this lesson.
Install the following GUI if desired:
Then run the command below and download the displayed package from HP.
Adding Printer to CUPS
Link your computer to the network your Raspberry is in. Open the internet browser and navigate to the CUPS site by providing your Pi IP followed by port ":631," to which CUPS is connecting. If the internet browser displays the message "Connection not secure," select "Proceed Anyway."
You may find your Pi IP by running hostname -I on your Pi terminal. If all goes well, the website is:
Navigate to the Admin page and choose Add Printer. Ascertain that you turn the printer on and hook it to the Raspberry through USB. Follow the on-screen instructions to set up the printer. Check the "share this printer" checkbox before proceeding to the last stage. Lastly, print a sample page on the Printers tab to ensure that everything is working correctly.
Please remember that the printer might not be shown under "Local Printers." If this is the situation, you must configure the necessary printer drivers in your Raspberry Pi.
The last step is to transmit print instructions using any connected devices. After that, you can print wirelessly from Linux, Microsoft, Macintosh, Android, and apple. There is no need to install additional printer drivers for this.
Printing with the raspberry pi
This is the final and most straightforward step, in which we will wirelessly communicate print instructions to our printer. You must have CUPS installed on your Raspberry and print a sample page using the CUPS Web-based interface. Any gadget you would like to print from must be on the Pi network.
Windows
You must have Samba installed and set up on your Pi for this to function.
Navigate to Settings and select "Add a printer or scanner." This will automatically detect the network printer, and you may add it by clicking "Add Device."
Select "The printer that I want isn't displayed if it doesn't work."
The queue name, in this case, is like the printer's queue name in the Printers tab of the CUPS web-based interface.
Linux
You may add a wireless printer to a Linux desktop by going to GNOME Preferences- Devices and Printers. The procedure would be relatively similar in other Linux distributions.
The wireless printer will be discovered and added automatically. If that doesn't work, you might need to add the printers by entering the Ip of the Raspberry Pi.
macOS
At the bottom, press the Plus button. The printer will be detected automatically by Mac. Select and then click Add.
Android
The system includes a Print Function in Android. For previous versions, you must install the CUPS Print plugin. Then go to Settings -Devices Connected -Connectivity- Preference Printing and activate the CUPS Printing plugin. You may start the Print Capability in Oreo and later versions.
For printing a paper or file, open the files in a printing-compatible app. Go to Options Print, choose your printer, and press the print button.
There was an issue that occurred after installing a printer. The printer only printed a few jobs and ignored the rest. I had to reboot either the Raspberry Pi or the printers to resume printing. The command below resolved this issue:
Benefits of Wireless Printing
If you haven't yet experienced the pleasures of wireless connection printing, this project is a great place to start. But what's the point of wireless printing?
Mobility
Wireless connected printers enable users to work effectively on the go because there are no cables attaching the printer to a particular spot. This may be useful in various industries, from retail, where sales associates can construct more checkout stations during busy periods, to logistics, where haulage carriers must track the weights of their vehicles.
Organizations with mobile workers, such as health & security inspectors, may profit from wireless communication because employees can print their invoices, records, and results right away – instead of having to go back to their offices.
Accessibility
Instead of struggling to access your business services to download discs, these wireless printers work efficiently. The benefits of a wireless connection are limitless. It allows business employees to produce receipts, examination data, tickets, and labels with a single click and return to their job with minimal interruption.
Wireless printing can also eliminate the requirement for Wi-Fi using iOS and Android technologies, allowing mobile employees, public transportation drivers, and law enforcement officers to print files regardless of their place.
Multifunctional
Wi-Fi printers use infrared technologies to connect to other devices and quickly produce high-quality banners, receipts, and bar codes. The printer may increase doctor efficiency while drafting patient information if it is equipped with pre-cut labels and provide major benefits to CSI teams, who can now immediately manufacture evidence tags at crime scenes.
Depending on your company's needs, a single printer can serve various functions. While a shop manager may utilize a mini-printer for everyday receipt production, they could also opt to use the same printers to print tickets for exclusive launch events, therefore, lowering equipment expenses.
Convenience
Because the printer is small and portable, employees may set it wherever needed. The printers provide excellent space-saving solutions for better printing efficiency and the ability for many users to connect to a single printer to cut the cost of buying extra resources.
These printers are intended to reduce waste, which is very important for conferences and seminars. Workers may print on demand since the printer does not have to be supplied with pre-printed tickets, avoiding the possibility of an unneeded surplus.
Cost-effective
Wi-Fi printers are advantageous to small stores, like start-ups or pop-ups, since they are not well-established companies.
With a bit of investment in such a payment service and a portable printer, business owners may accept card payments at gatherings or establish temporary kiosks in existing businesses and cafés.
Despite their small size, Wi-Fi printers have a considerably longer battery storage life that may last weeks or even months on standby. This implies you won't have to pay a high electricity cost, and you won't have to resupply every day.
Wi-Fi printing makes printing more flexible, making it an excellent project for Raspberry Pis. The advantage of this approach is that it is compatible with Microsoft operating system, Macintosh, and other Linux distribution systems.
What Can We Do With Our Printer?
Greeting Cards
Decades ago, some individuals stopped sending these cards and letters. But there's nothing quite like receiving a handmade letter from someone. Your printer offers multiple options for printing in various sizes.
Print Your Artwork
You could even use an inkjet printer to print creative design work if you're a creative individual. Because inkjet ink offers a much more accurate and vibrant color representation than laser ink, we recommend utilizing them instead of laser printers.
Business Cards
There is no better method to share professional details with customers than offering them a professional card nowadays. Ordering these cards, on the other hand, is shockingly costly.
Custom Napkins
Are you preparing a great social event or party? Prepare your paper napkins by printing something unique on them. That's right: you can personalize your napkins with photos, graphics, initials, logos, and other details.
With this capability, you can elevate that special event or family dinner to a whole new level. Furthermore, if you own a modest business that offers personalized napkins, it is really a fantastic option to work from home.
Conclusion
In this tutorial, we learned how to print from Raspberry pi. We also learned some of the benefits of using a wireless printer. However, In the following tutorial, we will learn how to take a screenshot in our Raspberry pi.