Categories
Device

How to turn a raspberry pi into a google cloud print server

How to turn a raspberry pi into a google cloud print server

Even an ancient laser or inkjet printer is probably good enough for most people, but if yours lacks Wi-Fi, using it can be a pain the butt. However, it’s easy enough to turn a Raspberry Pi into a wireless print server that will allow you to print to your wired printer from any computer on your network. Here’s how to make a Raspberry Pi print server.

What You Need to Make a Raspberry Pi Print Server

  • Raspberry Pi with Wi-Fi. A Pi Zero W is best suited for this project but any Pi with WiFi can be used. We used a spare
  • Raspberry Pi OS on an 8GB+ micro SD card. You may want to do a Raspberry Pi headless setup so you can perform this setup without a monitor, keyboard or mouse.
  • A USB adapter to connect the Pi to the printer. If this is a Raspberry Pi Zero W, you’ll want a USB OTG (micro USB male to USB Type-A female) wire. , to connect the printer if using a Pi Zero W.
  • A printer without network capabilities.

How to Set Up a Raspberry Pi Print Server

1. Open a terminal window on the Raspberry Pi or login via SSH.

2. Update the list of installable software.

3. Install the Common Unix Print System (CUPS) software.

4. Add the default user, pi to the group of users which can use printers.

5. Create a static IP address so that the Pi can always be located on the network.

6. Add a static IP address and details of the router, and DNS server to the bottom of the file. These details will be different depending on how your router is configured. When complete press CTRL + X, Y and then Enter to save and exit.

7. Configure CUPS so that it is accessible across the network.

8. Setup SSH remote access to the Pi if it’s not setup already. You do this by launching raspi-config (sudo raspi-config), enabling SSH under Intefacing Options->SSH, exiting and rebooting.

10. Navigate to the IP address of the Pi followed by :631 on another computer’s browser. In our example the IP address is 192.168.0.99.

You’ll see the CUPS web interface and from here we can administrate the printer server.

11. Click on the Administration tab and on the next screen click Add Printer.

12. Upgrade CUPs if you get an “Upgrade Requried” warning, followed by a link to download.

13. Select Advanced then Proceed if you receive a “Your connection is not private” warning.

14. Enter your user name and password, by default these are pi and raspberry.

15. Click on the radio button next to the name of your printer.

16. Select the model of your printer and then click Add Printer. Typically the first value returned should be correct.

17. Check the configuration of the printer before clicking on Set Default Options.

Go to Printers and then click on your printer. To open the configuration screen for that printer.

18. Click on Print Test Page, found in the Maintenance menu, to print a test page and to confirm that our printer is working properly.

Using the Raspberry Pi Print Server from a Windows device

Adding the printer to Windows 10 is really simple. Just make sure that your Windows device is on the same network as the print server.

1. From the Start Menu search for Printer, click on Printers & scanners.

2. Click on Add a printer or scanner

3. Click on the print server.

4. Click on Add Device and Windows will communicate with the print server.

5. Click on Manage to open the printer settings page.

6. Click on Print Test Page to test that Windows can successfully use the print server.

I’ve set up a Raspberry Pi to act as print server for a Dymo 330 Turbo LabelMaker (I did this some time ago using an article from a Dennis Sutanto Technology Blog, but the approach seems basically the same as in the current article.) This setup has been working beautifully for printing labels from a PC. Now, though, I would also like to print from a Debian-based Linux system (LinuxFX, specifically). I can’t seem to get this setup to work, and I’m not sure what the problem may be! Under Printer Properties I have:

Description: DYMO LabelWriter 330 Turbo

Device URI: http://192.168.2.64:631/printers/DYMO_LabelWriter_330_Turbo ==> this is exactly the same as used when setting up the printer on the PC

Make and Model: DYMO LabelWriter 330 Turbo,driverless,cups-filters 1.27.4

Printer state: Idle

When I try printing to the Dymo, I get a message saying “printer error” and I have to delete the document from the print queue.

I’m not sure if it needed or not, but I put the PPD for this LabelMaker in the /usr/share/cups/model directory and restarted the CUPS server.

Any thoughts on what is wrong would be greatly appreciated!

UPDATE: I notice that the printer error message includes the text:

Processing – File “/usr/lib/cups/filter/raster2dymolw” not available: No such file or directory

HOWEVER, this file IS present in the specified location! I guess the problem is not with the printer server after all, but something to do with the DYMO software. No idea what to try next!

UPDATE #3: With a fresh install of LinuxFX (based on Ubuntu 20.04) and the latest version of WINE I have been able to install the Dymo LabelMaker software 8.7.3 with (apparently) no errors. The program starts up fine but claims it cannot find the printer even though other programs (including ones running with Wine) can print perfectly well to it.

Does anyone know what is so “special” about Dymo printer requirements? Perhaps some CUPS configuration change is needed, or some special permissions set? Any suggestions at all would be greatly appreciated!

I am failing on step 14, username and password.

pi and raspberry, are not working. I am using this same pi to run a pihole, THAT login also doesn’t work.

Okay, solved my own problem. I ssh’d into it. It is a Pi 4, 4GB. I have more than one so the device name is simply “raspberrypi41”. When I changed the password in raspi-config back to “raspberry” the admin console let me in.

I wonder if this is fixable? The tutorials on installing a pihole mention to NOT have the default login.

Google Cloud Print has become a requirement for me – no more dealing with drivers, and I can print from anywhere using my phone. But, not all printers support the service (or support it adequately – I’m looking at you, Brother).

Here’s a simple procedure to turn a headless Raspberry Pi into a Google Cloud Print proxy, making your local printer(s) visible to Cloud Print. This is made possible using armoo’s cloudprint proxy software.

Before you start, you’ll need a Raspberry Pi 2 (Edit: maybe not – see Notes) or newer with:

  • Raspbian Jessie (Stretch is even better – see Notes)
  • A root partition that is bigger than the default 4G (16GB recommended)
  • Internet connectivity (possibly via Comitup)
  • Access to a printer via the network or USB

For the installation, you’ll also want another computer on the same network with an ssh client (like PuTTY) and a web browser logged in to your Google account. What you don’t need is a desktop environment on the Pi, or a connected keyboard/monitor/mouse. All interaction can be achieved via ssh and another browser connected to the network.

Step 1 – Install

Establish an ssh session with the Pi, and run the following commands to install the required software from the cloudprint repository.

Add the cloudprint repo to your apt environment.

Install the software. This will likely involve more than 40 packages.

Make the CUPS web page externally accessible.

At this point you should have the cups service running.

Step 2 – Configure

Use the CUPS web interface at http://:631/ to add a printer to your setup. Your browser may complain about unsafe connections for https links. Allow these connections. When it asks, use the pi user credentials.

From the command line on the Pi, establish Google Cloud Print authentication with:

The output of the cps_auth command will include a URL. Copy this URL to your browser, and use it to establish authentication.

Now restart the cloudprint service to use this account.

Consider disabling CUPS remote administration, to improve security. Also, make sure you have changed the default SSH credentials.

I show how to send temp sensor data from Rpi database to Google Cloud database.

Things used in this project

Hardware components

Software apps and online services

Story

On the Google Cloud site we have to log in to the account and, before using cloud, you have to give your credit card details. Some of the features are free to use like here we are using MySQL database which is free to use.

1. How to create a Google Cloud SQL instance

  • Go to Console, you will see a page like this.
  • Go to the Cloud SQL Instances page in the Google Cloud Platform Console.
  • Before creating instance you have to select project or create new one. Click Create instance.
  • Click Choose Second Generation.
  • Enter an ID for the instance. You do not need to prepend the project ID onto the instance ID.
  • If you want to configure the instance for high availability, select the Create failover replica check box.
  • If needed, set any of the other optional instance settings.
  • Click Create.
  • After the instance finishes initializing, select the instance to open it.
  • Click Access Control > Users.
  • Click Change root password and provide a password for the ‘root’@’%’ MySQL user.

2. Configure access to your Cloud SQL instance

  • Go to the Cloud SQL Instances page in the Google Cloud Platform Console.
  • Record the IP address of the instance.
  • Log in to the client machine where your MySQL client is installed.
  • Click What’s my IP to determine the IP address of the client machine.
  • In the Instances page in the Google Cloud Platform Console, click the instance to open its Overview page.
  • Click Access control > Authorization.
  • Under Authorized networks, click Add network and enter the IP address of the client machine where your MySQL client is installed.
  • Click Done, then click Save at the bottom of your page to save your changes.
  • Connect to your instance, either with SSL or without SSL.

To connect to your instance:

(This should be done on a RASPBERRY PI)

Start the MySQL client:

Enter the root password at the prompt. Verify your connection by listing the databases on the instance:

Using the MySQL client in the Google Cloud Shell

  • Go to the Google Cloud Platform Console.
  • Click the Cloud Shell icon towards the right in the tool bar. The Cloud Shell takes a few moments to initialize.
  • At the Cloud Shell prompt, use the built-in MySQL client to connect to your Cloud SQL instance:
  • Enter your root password.
  • Verify your connection by listing the databases on the instance:

Instance

Instance details

Using Cloud Shell

1. Raspberry Pi configuration for static IP

  • Go to directory:
  • Then open file by command sudo nano dhcpcd.conf and at last add these line and save it.
  • Go to directory:
  • Then open interfaces file by command, sudo nano interfaces and add these lines:
  • After that check whether IP is changed to static or not,if not then use this command. Flush the Raspberry Pi IP by using command:

2. MySQL Installation and Setup

To install MySQL

Once the installation begins, you will be asked to provide a master password for your MySQL installation. Ensure you choose a good secure password, and it’s a good idea to give MySQL a different password to the one you use to access your Raspberry Pi.

How to turn a raspberry pi into a google cloud print server

One day I was telling our new computer networks lecturer at the university of HELP that we have an entry-level web server that can be used by students to deploy their web apps (I was so happy), then he told me that anything can be a web server even the raspberry pi. Let’s discuss and see how this can be done.

From a hardware standpoint, any piece of hardware with a network connection can be a web server. Web serves are not about hardware, although certainly some hardware is better suited to run large applications at scale. Instead, a web server is just a piece of software that serves a web content. To serve web contents, a web server needs to listen on a port for a request that is sent via transport protocol and returns a response contains a requested resources.

Step 1: Install Raspberry Pi and Apache Web Server

As we mentioned before, we need some pieces of software as well as to do some configurations in order to have a working web server. So step 1 is to install Raspberry Pi. I already installed the Raspberry Pi OS 32-bit (you can do from here), all I need now is to install a web server. I prefer to use Apache, the world’s most popular web server (here’s a list of other web servers you can use). Install Apache by running the following commands.

If it is successfully installed, you should see like the following pic when you type localhost or 127.0.0.1 in your browser:

How to turn a raspberry pi into a google cloud print server

Step 2: Make the web server publicly accessible.

So far we have been serving our web page on local machine (both browser and server), now make it publicly accessible from anywhere. We should open up our router’s home page by typing the router’s IP address and logging in using the username and password (default is admin for both). Now go to the tab that says “Virtual Server” or “Port Forwarding”.

There will be a table-like form, and enter the following:

  • Service type: HTTP
  • External port: 80
  • Internal port: 80
  • Internal IP: The Raspberry Pi local IP (run ifconfig in the terminal)
  • Protocol: TCP

How to turn a raspberry pi into a google cloud print server

By doing this, we are actually telling our router to forward any incoming request on our public IP for port 80, to the Raspberry Pi. Let’s test this by checking our public IP and typing it in the web browser:

Network your printer with a Raspberry Pi and the CUPS print server.

How to turn a raspberry pi into a google cloud print server

Dwight Sipler on Flickr

Subscribe now

Get the highlights in your inbox every week.

I like to work on small projects at home, so this year I picked up a Raspberry Pi 3 Model B, a great model for home hobbyists like me. With built-in wireless on the Raspberry Pi 3 Model B, I can connect the Pi to my home network without a cable. This makes it really easy to put the Raspberry Pi to use right where it is needed.

At our house, my wife and I both have laptops, but we have just one printer: a slightly used HP Color LaserJet. Because our printer doesn’t have a wireless card and can’t connect to wireless networks, we usually leave the LaserJet connected to my laptop, since I do most of the printing. While that arrangement works most of the time, sometimes my wife would like to print something without having to go through me.

Basic setup

Setting up the Raspberry Pi is fairly straightforward. I downloaded the Raspbian image and wrote that to my microSD card. Then, I booted the Raspberry Pi with an HDMI display, a USB keyboard, and a USB mouse. With that, I was ready to go!

The Raspbian system automatically boots into a graphical desktop environment where I performed most of the basic setup: setting the keyboard language, connecting to my wireless network, setting the password for the regular user account ( pi ), and setting the password for the system administrator account ( root ).

I don’t plan to use the Raspberry Pi as a desktop system. I only want to use it remotely from my regular Linux computer. So, I also used Raspbian’s graphical administration tool to set the Raspberry Pi to boot into console mode, but not to automatically login as the pi user.

Once I rebooted the Raspberry Pi, I needed to make a few other system tweaks so I could use the Pi as a “server” on my network. I set the Dynamic Host Configuration Protocol (DHCP) client to use a static IP address; by default, the DHCP client might pick any available network address, which would make it tricky to know how to connect to the Raspberry Pi over the network. My home network uses a private class A network, so my router’s IP address is 10.0.0.1 and all my IP addresses are 10.0.0.x . In my case, IP addresses in the lower range are safe, so I set up a static IP address on the wireless network at 10.0.0.11 by adding these lines to the /etc/dhcpcd.conf file:

Before I rebooted again, I made sure that the secure shell daemon (SSHD) was running (you can set what services start at boot-up in Preferences). This allowed me to use a secure shell (SSH) client from my regular Linux system to connect to the Raspberry Pi over the network.

Print setup

Now that my Raspberry Pi was on the network, I did the rest of the setup remotely, using SSH, from my regular Linux desktop machine. Make sure your printer is connected to the Raspberry Pi before taking the following steps.

Setting up printing is fairly easy. The modern print server is called CUPS, which stands for the Common Unix Printing System. Any recent Unix system should be able to print through a CUPS print server. To set up CUPS on Raspberry Pi, you just need to enter a few commands to install the CUPS software, allow printing by other systems, and restart the print server with the new configuration:

Setting up a printer in CUPS is also straightforward and can be done through a web browser. CUPS listens on port 631, so just use your favorite web browser and surf to:

Your web browser may complain that it doesn’t recognize the web server’s https certificate; just accept it, and login as the system administrator. You should see the standard CUPS panel:

cups-1-home.png

How to turn a raspberry pi into a google cloud print server

From there, navigate to the Administration tab, and select Add Printer.

cups-2-administration.png

How to turn a raspberry pi into a google cloud print server

If your printer is already connected via USB, you should be able to easily select the printer’s make and model. Don’t forget to tick the Share This Printer box so others can use it, too. And now your printer should be set up in CUPS:

cups-3-printer.png

How to turn a raspberry pi into a google cloud print server

Client setup

Setting up a network printer from the Linux desktop should be quite simple. My desktop is GNOME, and you can add the network printer right from the GNOME Settings application. Just navigate to Devices and Printers and unlock the panel. Click on the Add button to add the printer.

On my system, GNOME Settings automatically discovered the network printer and added it. If that doesn’t happen for you, you may need to add the IP address for your Raspberry Pi to manually add the printer.

gnome-settings-printers.png

How to turn a raspberry pi into a google cloud print server

And that’s it! We are now able to print to the Color LaserJet over the wireless network from wherever we are in the house. I no longer need to be physically connected to the printer, and everyone in the family can print on their own.

Adding sensors to devices and sending that sensor data to a public cloud offers many advantages; data can be stored, processed and decisions made with relatively little outlay on initial infrastructure. Having multiple sensors connected to a gateway that process and transmit data to a cloud platform is an efficient architecture to implement an IoT system.

This document describes using a Raspberry Pi v3 B+ (896-8660) as a gateway device and illustrates how we used a Pi to process and transmit data from 10 different environmental sensors.

The UrsaLeo team chose the Raspberry Pi v3 as the gateway because it offers wired Ethernet, WiFi, and Bluetooth connectivity (BLE) with a reasonably powerful processor. The sensor board chosen was the Silicon Labs Thunderboard 2 (TB2), which offers a good mix of environmental sensors combined with a Gecko class processor that allows sensor data to be transmitted over Bluetooth to the Pi.

In our design, connection to the Google cloud can be done using either wired or wireless Ethernet. The overall architecture receives the sensor data over BLE, pre-processes the data, encrypts, it and then transmits it to the Google cloud over ethernet.

The sensors on the TB2 can monitor temperature, humidity, barometric pressure, magnetic field strength, gyroscopic orientation in space, CO2 and organic compound air quality, and ambient and UV light strength. There is also a microphone used to record ambient sound volume. Each of these sensors is sampled every six to eight seconds and the sensor data is then transmitted via BLE to the Pi.

The first step after receiving data from a sensor is to normalize the value to a standard range. For example, temperature sensors often output a value using a 16 bit ADC — so a number from 0 to 65,535 is transmitted. However, that number might represent two completely different temperature values from a 0 to 70-degree sensor compared to a -40 to 125-degree sensor. The received data point is converted to an actual temperature value (celsius or fahrenheit can be selected) on the gateway prior to transmission to the cloud.

After the data is normalised, it is put into a JavaScript Object Notation (JSON) format for transmission to the cloud. JSON is an open standard, human-readable, text-enabled way to transmit data and the most commonly used format for sending sensor data over the Internet. To keep the JSON message as short as possible, a short, unique identifier is used for each sensor in the system. On the cloud side, the identifier is expanded into a longer device address that allows users to easily select one sensor from thousands by location, type, or other defined parameters.

Before data is sent to the cloud for the first time, it is necessary to create a Google instance that is listening for the specific gateway. This is done using a unique identifier programmed into the gateway during the manufacturing process. — After the initial login process, the identifier is entered which creates the Google data node ready to receive sensor data from that gateway.

Powering up the gateway device causes a boot sequence which establishes an Internet connection, sets the clock on the Raspberry Pi, and then sends certificate information to the Google cloud. Once a connection is established, sensor data is immediately read over the BLE connection, normalized, converted to JSON, encrypted, and then transmitted using Google IoT core (MQTT or HTTPS protocols).

On the cloud side, a standard set of features is provided for displaying and processing the data. Once data is received, it is converted to an internal cloud message using a Publish/Subscribe (PUB/SUB) scheme that allows different cloud components to listen for messages from specific sources.

Dashboard

Sensor data is displayed in a customizable dashboard (below). Here both real-time and historical data can be displayed in a variety of user-defined formats selected from a library.

How to turn a raspberry pi into a google cloud print server

Event / Alerts

As data is received, it can be compared to pre-set conditions and alerts will be triggered if those conditions are met.

Note: The underlying algorithm is a pattern matching (Rete algorithm) scheme that allows for thousands of messages per second to be compared with thousands of possible events.

Events that might trigger an alert can include:

  • Data meets a trigger value (temperature is over 30 degrees)
  • Multiple data trigger points are met (temperature > x AND humidity > y)
  • Data has not been received for x period of time
  • Data has moved x standard deviations away from the long-term average
  • Data is behaving abnormally (stuck on one value or jumping around)

Many more event / alert conditions can be programmed into the cloud engine.

Today our cloud platform stores sensor data, allows users to create a custom dashboard, set and trigger alerts on complex conditions. Future iterations of the cloud platform will further extend data analytics and actions, we plan to add object recognition using AI, machine learning, and blockchain capability, to name a few.

Raspberry Pi can be used as a gateway to send sensor data to the Google cloud. There is no maximum limit on how much data can be transmitted by multiple Ps in a single system. Cloud side services are securely transmitted and accessible through a browser interface. Use of public cloud / standard platform makes these resources available with no IT infrastructure, staff, or investment.

You can purchase the UrsaLeo cloud-enabled Raspberry Pi based system from RS Components. RS stock number (175-0396)

How to turn a raspberry pi into a google cloud print server

Google Cloud Print là một cách tuyệt vời để liên kết máy in của bạn với đám mây và tận hưởng quyền truy cập in từ mọi nơi, nhưng vẫn có một nhược điểm. Nếu bạn không có một trong những máy in Cloud-Print-Ready gần đây, bạn cần bật máy tính để bật truy cập từ xa. Đọc tiếp khi chúng tôi định cấu hình Raspberry Pi nhỏ, nhấm nháp năng lượng cho nhiệm vụ.

Tại sao tôi muốn làm điều này?

Hiện tại có hai đường dẫn đến quyền truy cập Google Cloud Print tại nhà của bạn: bạn có thể mua máy in hỗ trợ Cloud Print tự liên kết trực tiếp với tài khoản Google và dịch vụ Cloud Print của bạn hoặc bạn có thể sử dụng PC (có quyền truy cập vào máy in bạn muốn thêm vào Cloud Print) để hoạt động như một máy chủ Cloud Print.

Tình huống đầu tiên là lý tưởng, vì máy in tự kết nối trực tiếp với đám mây và không cần trung gian. Tuy nhiên, việc ngăn chặn điều đó nên là mục tiêu của bạn để đảm bảo rằng bên trung gian đang lãng phí càng ít tài nguyên càng tốt. Rời khỏi máy tính để bàn 24/7 với mục đích duy nhất là hoạt động như một máy chủ Cloud Print là toàn bộ tài nguyên cho một công việc đòi hỏi rất ít mã lực.

Để cắt giảm tài nguyên bị lãng phí, chúng tôi đã chọn biến một thiết bị Raspberry Pi nhỏ bé, công suất thấp thành Máy chủ Cloud Print siêu nhẹ. Phần tốt nhất về thiết lập này là Raspberry Pi có thể tiếp tục thực hiện các vai trò khác. Ví dụ: Máy chủ in đám mây Raspberry Pi của chúng tôi cũng là thiết bị hoạt động giống như chỉ báo thời tiết Raspberry Pi của chúng tôi. Phải mất rất ít tài nguyên để thực hiện cả hai công việc (tăng tốc công việc in thường xuyên và chạy một tập lệnh đơn giản để kiểm tra thời tiết và chuyển đổi đèn LED) mà không có lý do gì để không xếp chồng các tác vụ và nhận thêm từ việc mua Raspberry Pi của chúng tôi. Dưới đây là một số dự án mà bạn có thể dễ dàng xếp chồng với Raspberry Pi Cloud Print Server:

  • Xây dựng đèn chỉ báo LED với Raspberry Pi (cho Email, thời tiết hoặc bất cứ điều gì)
  • Cách biến Raspberry Pi thành thiết bị lưu trữ mạng công suất thấp
  • Cách biến Raspberry Pi thành Hộp BitTorrent luôn bật
  • Cách cài đặt NZBGet cho Usenet nhẹ Tải xuống trên Raspberry Pi của bạn

Tôi cân nhưng gi?

Đối với hướng dẫn này, chúng tôi sẽ giả định rằng bạn đã có những điều sau đây:

  • Một Raspberry Pi được cài đặt Raspbian
  • Máy in có thể truy cập vào Pi
  • Tài khoản Google

Nếu bạn chưa định cấu hình Raspberry Pi với Raspbian hoặc đã thêm máy in vào đó, hãy kiểm tra hai liên kết ở trên để tăng tốc. Nó là chỉ trích mà bạn đã theo dõi cùng (hoặc ít nhất là kiểm tra ghi chú cài đặt máy in của riêng bạn) theo hướng dẫn máy in Raspberry Pi của chúng tôi. Nếu Pi của bạn không có quyền truy cập vào máy in (cục bộ hoặc kết nối mạng), bạn sẽ không có bất kỳ thành công nào với hướng dẫn này.

Ngoài ra, bạn có thể sẽ thấy hữu ích khi xem hướng dẫn của chúng tôi về Google Cloud Print để làm quen với hệ thống trong và ngoài hệ thống.

Cài đặt Chromium

Nước sốt bí mật trong mô hình Raspberry Pi dưới dạng Cloud Print Server của chúng tôi là trình duyệt mã nguồn mở Chromium. Một trong những cách chính thức để thêm khả năng Cloud Print cho PC là sử dụng trình duyệt web Chrome của Google làm máy chủ in. Thật không may, mặc dù đã có bản phát hành Chrome chính thức cho khá nhiều bản phân phối Linux, nhưng nó chỉ hỗ trợ kiến ​​trúc x86 / x64 chứ không phải kiến ​​trúc dựa trên ARM cung cấp năng lượng cho Raspberry Pi và Rasbian. Đây là nơi Chromium xuất hiện, vì chúng tôi vẫn có thể truy cập các tính năng có liên quan trong Chromium mà chúng tôi cần liên kết Raspberry Pi với hệ thống Máy in đám mây của Google.

Để bắt đầu, hãy mở thiết bị đầu cuối trên Raspberry Pi của bạn và nhập lệnh sau:

S udo apt-get cài đặt trình duyệt crom

Khi được nhắc, nhập Y và nhấn enter để tiếp tục cài đặt. Việc cài đặt không lớn, nhưng nó đủ lớn; một chuyến đi mười phút đến phòng nghỉ để lấy một tách cà phê chắc chắn là một cách hợp lý để giết thời gian cài đặt.

Khi Chromium được cài đặt, chúng tôi cần khởi chạy nó từ môi trường máy tính để bàn. Bạn có thể tìm thấy nó trong menu bắt đầu của Raspbian trong Internet -> Trình duyệt web Chromium:

How to turn a raspberry pi into a google cloud print server

Sau khi khởi chạy Chromium, hãy điều hướng đến biểu tượng menu ở góc trên bên phải, nhấp vào nó, sau đó chọn Cài đặt Cài đặt. Cuộn xuống trong cửa sổ Cài đặt cho đến khi bạn thấy Cài đặt Nâng cao, và sau đó nhấp vào đó, tiếp tục cuộn xuống qua các tùy chọn cài đặt mở rộng cho đến khi bạn thấy mục nhập cho Google Cloud Print:

How to turn a raspberry pi into a google cloud print server

Nhấp vào Thêm Add Máy in. Bạn sẽ được chuyển đến một trang ủy quyền như vậy:

How to turn a raspberry pi into a google cloud print server

Điền thông tin đăng nhập tài khoản Google của tài khoản bạn sử dụng để quản lý Máy in trên đám mây của mình. Hãy chắc chắn rằng Ở lại đã đăng ký trong Đăng nhập, vì đây sẽ là một máy chủ in độc lập mà chúng tôi không thường xuyên tương tác với.

How to turn a raspberry pi into a google cloud print server

Sau khi ủy quyền tài khoản của bạn, bạn sẽ thấy nút ấn Thêm máy in. Bất cứ máy in nào Raspberry Pi có quyền truy cập (có thể là cục bộ hoặc được nối mạng) sẽ được thêm vào tài khoản Google Cloud Print của bạn. Nếu các máy in đó trước đây được thêm bằng một số phương tiện khác, bạn sẽ muốn truy cập trang quản lý Cloud Print của mình để xóa các mục cũ hơn.

Sau khi nhấp vào nút Thêm, bạn sẽ thấy trang xác nhận cho biết rằng máy in đã được thêm và bạn đã sẵn sàng bắt đầu in. Bây giờ là thời điểm hoàn hảo để kích hoạt bản in thử:

How to turn a raspberry pi into a google cloud print server

Khoảng 10 giây hoặc lâu hơn sau khi chúng tôi thực hiện công việc in, nó đã tự động chạy trên máy in được nối mạng:

How to turn a raspberry pi into a google cloud print server

Mặc dù ban đầu chúng tôi lo ngại rằng quy trình làm việc của Cloud-to-Pi sẽ chậm (không phải tốc độ phồng rộp thực sự quan trọng trong hầu hết các tình huống in), những lo ngại đó chưa bao giờ được xác thực. Ngay cả với các tệp PDF lớn hơn, quá trình này chỉ dài hơn một chút so với thời gian chờ in-a-big-PDF thông thường của bạn.

Sau khi chạy bản in thử, bạn có thể đóng Chromium trên Pi vì máy chủ in sẽ tiếp tục chạy ở chế độ nền. Giờ đây, bạn có thể tận hưởng sự tiện lợi từ mọi nơi trong khoảng một phần tư tháng (Raspberry Pi tiêu thụ rất ít năng lượng đến mức chi phí vận hành trung bình hàng năm là khoảng 3 đô la).

The CUPS printing server installs a bunch of command-line tools (see Administering CUPS later in this guide) for interacting with the server and any connected printers.

You can send files to the printer using the lp command, such as: $ lp /docs/a_text_file.txt

If you have multiple printers, you can print to a specific printer by specifying its name, such as:

$ lp /docs/another-text.txt -d EPSON_LX-300

When you use the commands with a PDF or image file, CUPS converts the files using the printer drivers. You can also use Python to generate printer-friendly content.

This is best done by using the PyCups library, which provides Python bindings for the CUPS server. Install the library with:

$ sudo apt-get install python-cups

Then create an example.py Python script with:

import cups
conn = cups.Connection()
printers = conn.getPrinters ()
for printer in printers:
print printer, printers[printer][“device-uri”]

The script fetches details about all the printers managed by CUPS and prints their name and device address to the screen. When you execute the script, it produces an output similar to the following:

EPSON_LX-300 usb://EPSON/LX-300+?serial=L010209081
RICOH_Aficio_SP_100 usb://RICOH/
Aficio?serial=T382M977983

You can also print files from the Python script using the printFile function, by specifying them in the format:

$ printFile (name of the printer, filename to print, job title,
options)

Open the previous example.py script and add the following lines to it:

file = “/home/pi/testfile.txt”
printer_name=printers.keys()[0]
conn.printFile (printer_name, file, “Project Report”, <>)

The first line saves the name of the file you wish to print inside a variable named file. The second line fetches the list of printers and saves the first name, which is the default printer inside a variable named printer_name. The third line then uses the first two variables and prints the file in the specified format.

Converting from HTML to PDF

A more interesting way to convert HTML pages into PDF file is to use the wkHTMLtoPDF toolkit, which passes on the PDF to the printer from within a Python script.

Before you can install the toolkit, first install the required components and a set of fonts to process the web pages:

$ sudo apt-get install xvfb xfonts-100dpi xfonts-75dpi xfonts
scalable xfonts-cyrillic

Then install the tool with

sudo apt-get install wkhtmltopdf

before installing the Python wrapper with:

$ sudo pip install git+https://github.com/qoda/pythonwkhtmltopdf.git

You can now use the following to convert a web page into a PDF file:

from wkhtmltopdf import WKHtmlToPdf

wkhtmltopdf = WKHtmlToPdf (

url=’http://www.techradar.com’,

output_file=’/home/pi/docs/lxf.pdf’,

wkhtmltopdf.render()

When executed, the above code saves the main techradar into a PDF file under the /home/pi/docs directory.

Refer to the listing below to see how all the pieces fit together – wkHTMLtoPDF converts a page into a PDF and prints it out.

#!/usr/bin/env python
import cups
from wkhtmltopdf import WKHtmlToPdf
wkhtmltopdf = WKHtmlToPdf(

url=’http://www.techradar.com’,
output_file=’/home/pi/techradar.pdf’,
)
wkhtmltopdf.render()
conn = cups.Connection()
printers = conn.getPrinters()
for printer in printers:
print printer, printers[printer][“device-uri”]
file=”/home/pi/techradar.pdf”
printer_name=printers.keys()[0]
conn.printFile (printer_name, file, “PDF Print”, <>)

The script first converts the techradar home page into a PDF. It then connects to CUPS, prints a list of attached and configured printers on the screen, and uses the default printer to print the PDF. The PyCups library is chockfull of methods (https://pythonhosted.org/pycups) that you can use to control all aspects of the CUPS print server.

Administering CUPS

In addition to adding printers, the CUPS web interface provides access to various other useful settings. You can administer most of the printing tasks from the Administration tab, which houses settings under various different categories.

Under the Server section, for instance, you can find options to tweak the configuration of the server as well as view various types of access and error logs.

Using the ‘Manage Printers’ button under the Printer section, you can control the settings for individual printers. Every printer’s page has options rolled under two pull-down menus labelled Maintenance and Administration. From under the Maintenance menu, you can print a test page, a self-test page, clean print heads and manage print jobs.

To customise the behaviour of the printer, use the Administration menu to tweak its default options, set it as the default printer, restrict user access, modify its settings or delete it from the CUPS server altogether. Besides the Administration tab, there are a couple of other important tabs we should mention as well.

For starters, you need to switch to the Classes tab for printer class management. A class is a collection of several printers. When you send print job to a class, CUPS automatically assigns the job to the next available printer, instead of waiting for a specific printer. Then there’s the Jobs tab, which enables you to view and manage all print jobs that are currently in the print queue.

With almost two decades of writing and reporting on Linux, Mayank Sharma would like everyone to think he’s TechRadar Pro’s expert on the topic. Of course, he’s just as interested in other computing topics, particularly cybersecurity, cloud, containers, and coding.

How to turn a raspberry pi into a google cloud print server

Google Cloud Print – це чудовий спосіб поєднати свої принтери з хмарою та насолоджуватися доступом до друку з будь-якого місця, але є вловлювач. Якщо у вас немає одного з нещодавніх принтерів із підтримкою Cloud-Print-Ready, потрібно ввімкнути комп’ютер, щоб увімкнути віддалений доступ. Читайте далі, як ми налаштуємо крихітне енергетичне пиво Raspberry Pi для цього завдання.

Чому я хочу це робити?

Наразі у вашому будинку є два шляхи доступу до Google Cloud Print: ви можете придбати принтер із підтримкою Cloud Print, який посилається безпосередньо на ваш обліковий запис Google і службу Cloud Print, або ви можете використовувати комп’ютер (який має доступ до принтерів бажаєте додати до Cloud Print), щоб працювати як сервер Cloud Print.

Перша ситуація ідеальна, оскільки сам принтер підключається безпосередньо до хмари і немає необхідності в посереднику. Однак, якщо це не буде, ваша мета – переконатися, що посередник витрачає якомога менше ресурсів. Залишення настільного комп’ютера цілодобово 7 днів на тиждень з єдиною метою функціонування сервера Cloud Print – це багато ресурсів для роботи, яка вимагає дуже мало потужності.

Для того, щоб скоротити витрачені ресурси, ми вирішили перетворити маленьке, малопотужне пристрій Raspberry Pi на ультралегкий Cloud Print Server. Найкраща частина цієї установки полягає в тому, що Raspberry Pi може продовжувати виконувати інші ролі. Наприклад, наш Cloud Print Server Raspberry Pi також є тим самим пристроєм, що функціонує як наш індикатор погоди Raspberry Pi. Це займе так мало ресурсів для виконання обох завдань (виведіть випадкове завдання друку і запустіть простий скрипт, щоб перевірити погоду і переключити світлодіод), що немає ніяких причин не складати завдання і отримувати більше з нашої покупки Raspberry Pi. Ось деякі з проектів, які можна легко скласти з Cloud Print Server Raspberry Pi:

  • Створіть індикатор LED з Raspberry Pi (для електронної пошти, погоди або будь-якого іншого)
  • Як перетворити Raspberry Pi на малопотужний мережевий накопичувач
  • Як перетворити Raspberry Pi в Always-On BitTorrent Box
  • Як встановити NZBGet для легких Usenet Завантаження на Raspberry Pi

Що мені потрібно?

Для цього підручника ми припустимо, що у вас вже є наступне:

  • Raspberry Pi з Raspbian встановлено
  • Принтери, доступні для Pi
  • Обліковий запис Google

Якщо ви ще не налаштували Raspberry Pi з Raspbian або ще не додали до нього принтери, обов’язково ознайомтеся з цими двома посиланнями, щоб отримати швидкість. це є критичний що ви слідували разом з (або принаймні перевірили свої власні примітки щодо встановлення принтера) нашим керівництвом для принтера Raspberry Pi. Якщо ваш Pi не має доступу до принтерів (локальних чи мережних), ви не матимете жодного успіху в цьому посібнику.

Окрім того, вам, мабуть, буде корисно ознайомитися з нашим керівництвом до Google Cloud Print, щоб ознайомитися з входами та виходами системи.

Встановлення Chromium

Секретний соус в нашій Raspberry Pi як модель Cloud Print Server – це браузер з відкритим вихідним кодом Chromium. Одним із офіційних способів додавання можливостей Cloud Print до ПК є використання веб-переглядача Google Chrome як сервера друку. На жаль, навіть якщо є офіційний випуск Chrome для багатьох дистрибутивів Linux, він підтримує лише архітектуру x86 / x64, а не архітектуру ARM, яка керує Raspberry Pi і Rasbian. Саме тут входить Chromium, оскільки ми все ще можемо отримати доступ до відповідних функцій у Chromium, які нам потрібно, щоб прив’язати нашу Raspberry Pi до системи Cloud Cloud Printer.

Щоб розпочати роботу, відкрийте термінал на Raspberry Pi і введіть наступну команду:

s udo apt-get встановлює chromium-браузер

Коли з’явиться запит, введіть Y і натисніть enter, щоб продовжити інсталяцію. Установка не величезна, але вона досить велика; Десятиминутна поїздка до кімнати перерви, щоб схопити чашку кави, безумовно, є розумним способом убити час установки.

Після встановлення Chromium нам потрібно запустити його з середовища робочого столу. Ви можете знайти його в меню запуску Raspbian в Інтернеті -> Веб-браузер Chromium:

How to turn a raspberry pi into a google cloud print server

Після запуску Chromium перейдіть до піктограми меню у верхньому правому куті, натисніть його, а потім виберіть “Налаштування”. Прокрутіть у вікні “Налаштування” вниз, доки не з’явиться повідомлення “Додаткові налаштування”, а після натискання цієї кнопки продовжуйте прокручувати опції розширених налаштувань, доки не з’явиться запис для Google Cloud Print:

How to turn a raspberry pi into a google cloud print server

Натисніть “Додати принтери”. Ви перейдете на сторінку авторизації, наприклад, так:

How to turn a raspberry pi into a google cloud print server

Заповніть облікові дані облікового запису Google для облікового запису, який використовується для керування своїми Cloud Printers. Переконайтеся, що позначка “Залишатися ввімкненим”, оскільки це буде окремий сервер друку, з яким ми регулярно не взаємодіємо.

How to turn a raspberry pi into a google cloud print server

Після авторизації облікового запису ви побачите кнопку “Додати принтер (и)”. Які б принтери не мали доступ до Raspberry Pi (будь то місцеві або мережеві), буде додано до вашого облікового запису Google Cloud Print. Якщо раніше ці принтери були додані іншими способами, ви хочете відвідати сторінку керування Cloud Print, щоб видалити старі записи.

Натиснувши кнопку Додати, з’явиться сторінка підтвердження, що вказує, що принтери були додані, і ви готові почати друк. Тепер ідеальний час для вимкнення тестового друку:

How to turn a raspberry pi into a google cloud print server

Приблизно за 10 секунд або близько того після того, як ми випустили завдання друку, воно набуло сплит на мережевому принтері:

How to turn a raspberry pi into a google cloud print server

Хоча ми спочатку мали занепокоєння, що робочий процес від Cloud-to-Pi-to-Printer буде повільним (не те, що швидка швидкість дійсно є критичною в більшості ситуацій друку), ці проблеми ніколи не були перевірені. Навіть з великими файлами PDF процес триває трохи довше, ніж очікування типово довгого друку.

Після запуску тестового друку ви можете закрити Chromium на Pi, оскільки сервер друку продовжуватиме працювати у фоновому режимі. Тепер ви можете насолоджуватися зручністю друку з будь-якого місця приблизно за чверть місяця (Raspberry Pi споживає так мало енергії, що середня річна вартість експлуатації складає близько $ 3).