New Raspberry Pi Project: Cloud Printing!

Previously, I made a Polaroid camera using Raspberry Pi and shared it in the Guokr WeChat group. Guokr invited me to write a tutorial. Since the Polaroid camera is currently under confidentiality and cannot be open-sourced, the tutorial for Guokr has not been completed, which makes me quite anxious. Therefore, I’m using this tutorial to compensate for it. Those with high technical skills can also create a Polaroid camera based on the tutorial.

This time, the cloud printing thermal receipt printer made based on Raspberry Pi deploys programs on the Raspberry Pi, receives printing signals from the local area network, and then prints them out.

Materials Needed

Raspberry Pi 2 1 piece

8G TF card 1 piece

Card reader 1 piece

Network cable 1 piece

Thermal receipt printer head 1 piece

Thermal printer paper 1 roll

Li-ion battery 7.4V 1 piece

Wires several

PS: Everyone knows Raspberry Pi, please use the thermal printer head like the one below.

New Raspberry Pi Project: Cloud Printing!

New Raspberry Pi Project: Cloud Printing!

Production Process

Before starting, let me introduce CUPS, which is a universal Linux printing system and an open-source printing system. Its most important aspect is that it can reconstruct the data of print jobs between formats. For example, rasterized PDF data can also be printed through this. (If you don’t understand what is said above, just consider it nonsense; actually, I need to use this open-source library CUPS ᕙ(⇀‸↼‵‵)ᕗ.)

New Raspberry Pi Project: Cloud Printing!

Precautions:

TTL printers do not support Raspberry Pi 3, only Raspberry Pi 2 or earlier versions can be used. If you are using a TTL printer (not USB), please do not connect it to the Raspberry Pi for now! Otherwise, it will spit out paper like crazy!!!! This is a sour experience, only those who use it know.

1
Download the Program

Download the latest version of Raspbian Jessie system, which can be downloaded from the Raspberry Pi official website (Note that you need to download the complete version of Raspbian Jessie, do not download the Lite version, as some installation programs require a graphical interface).

2
Preparation Work

Write the system to the 8GB SD card, insert it into the Raspberry Pi, and then plug in the power. After booting for a minute, you will see the Raspberry Pi desktop. Set up the Raspberry Pi through the graphical interface or open the terminal window, and then run raspi-config to perform basic system settings.

New Raspberry Pi Project: Cloud Printing!

3
Specific Settings

You need to set the following:

· Expand the file system

· Since you are using a TTL printer, in the Interfaces tab, Serial must be Disabled (the serial port under the interfaces tab must be turned off)

After setting, click OK, then restart. After restarting, connect the network cable to the router, or you can use wireless.

New Raspberry Pi Project: Cloud Printing!

New Raspberry Pi Project: Cloud Printing!

4
Recommended Settings

The following settings are not mandatory, but it is recommended to set:

· Change the hostname to distinguish it from other Raspberry Pis on the network

· Change the default password

· Disable overscan

· Under the “Localization” option, set the time zone, location, keyboard, etc.

5
Connect and Set Up the Printer

· Connect the printer and Raspberry Pi. See the wiring diagram below. Connect the GND of the Raspberry Pi to the GND of the printer, connect the TXD of the Raspberry Pi to the RX of the printer, and connect the RXD of the Raspberry Pi to the TX of the printer.

New Raspberry Pi Project: Cloud Printing!

New Raspberry Pi Project: Cloud Printing!

· Then connect the positive and negative terminals of the printer to the positive and negative terminals of the lithium battery (positive to positive, negative to negative)

Note: At this point, if the Raspberry Pi is powered on, the receipt printer prints a bunch of garbage code, it means your serial port has not been disabled, please reconfigure the serial port to disable it.

Next, we need to find the baud rate for serial communication of the printer. Press and hold the button on the back of the printer while powering it on, and the printer will print a bunch of random data. Don’t worry, just find the baud rate at the bottom, which is usually 9600 or 19200.

New Raspberry Pi Project: Cloud Printing!

Now we can power on the printer and Raspberry Pi, then open the terminal window and enter the code.

stty -F /dev/ttyAMA0 19200

echo -e “This is a test.\n\n\n”>/dev/ttyAMA0

If your printer outputs garbage at this point, please check if the baud rate is correct and modify it. Sometimes the first line may be garbled, but the rest will be fine, which is not a problem, as it is due to the residual data in the serial port buffer after booting.

6
Install the Main Program

The above is just a test. If the above content test is completed, the following is the actual program installation.

First, make sure the Linux database is up to date, and then install a few packages.

Enter the following in the terminal:

sudo apt-get update

sudo apt-get install libcups2-dev libcupsimage2-dev git build-essential cups system-config-printer

Although the program is not large (75M), it depends on your network speed. Generally, it takes about 30 minutes to download and install the CUPS driver for the thermal printer.

git clone https://github.com/klirichek/zj-58.git

cd zj-58/

make

sudo ./install

Now we switch to the desktop system, from the PI’s menu, select Preferences→Print Settings.

New Raspberry Pi Project: Cloud Printing!

If the Print Settings option is not available, check the steps above and reset them.

If there is still no printer, you can click the Add button to add a printer.

New Raspberry Pi Project: Cloud Printing!

In the Devices section, select“Enter URI” and then enter“serial:/dev/ttyAMA0?baud=19200” (or 9600).

New Raspberry Pi Project: Cloud Printing!

Then click Forward, proceed to the next step, select“Select printer from database,” then choose “Zijiang”

New Raspberry Pi Project: Cloud Printing!

Then click “Forward” in the next step, select“Zijiang ZJ-58” driver

New Raspberry Pi Project: Cloud Printing!Click“Forward”, then name your printer

New Raspberry Pi Project: Cloud Printing!

Finally, click“Apply” and you will see the ZJ-58 printer in the printer list.

New Raspberry Pi Project: Cloud Printing!

Click the ZJ-58 icon, then select “Properties” from the “Printer” menu:

New Raspberry Pi Project: Cloud Printing!

Set the “Feed distance after print” to “feed 12mm,” then clickOK.

After clicking OK, the printer will be able to work.

Now let’s test it. Open the terminal window,

echo “This is a test.”| lpr

The printer should print“This is a test.”

Then try printing an image

lpr -o fit-to-page

/usr/share/raspberrypi-artwork/raspberry-pi-logo.png

“-o fit-to-page” is very important, it makes the image fit the page.

7
Network Printing Setup

We need to set it up so that we can use this printer to print things on the local area network.

From the Pi menu, select Preferences→Print Settings.

New Raspberry Pi Project: Cloud Printing!

Double-click the ZJ-58 printer, or click the ZJ-58 printer then select Printer→Properties:

New Raspberry Pi Project: Cloud Printing!

In the “Policies” tab, ensure that “Shared” is selected, then clickOK

New Raspberry Pi Project: Cloud Printing!

Return to the main window of the print settings, then select Server→Settings…

New Raspberry Pi Project: Cloud Printing!

Check the box in front of “Publish shared printers connected to this system.” Then clickOK

New Raspberry Pi Project: Cloud Printing!

Now the printer can be used.

For example, on a Mac, select “Printers and Scanners” to add the ZJ-58 printer.

New Raspberry Pi Project: Cloud Printing!

Then you can use the thermal printer in the local area network with your computer or mobile phone.

New Raspberry Pi Project: Cloud Printing!New Raspberry Pi Project: Cloud Printing!New Raspberry Pi Project: Cloud Printing!New Raspberry Pi Project: Cloud Printing!

Haha, the effect is pretty good~

This is a production post generously contributed by Li Wai, thank you very much! Li Wai WeChat ID: gcds2008. Friends interested in this post are welcome to add me as a friend to exchange ideas!

The maker’s production posts are still being collected. Share your creations, meet more makers, and you may receive surprise gifts. Threefold impact awaits you! Submission email: [email protected]

If you have good posts but keep them hidden, the incubator will be angry! ( ̄ε(# ̄)☆╰╮o( ̄皿 ̄///)

New Raspberry Pi Project: Cloud Printing!

Guokr Space and Guokr Lab have joined forces to form the Guokr Double Innovation Space! Here, entrepreneurial teams can enjoy evaluation reports provided by Guokr Lab and receive suggestions from makers; makers can also provide your creative ideas here, and we will realize them together! In addition, there are more interesting online and offline activities waiting for your participation, exciting content, jointly presented.

Leave a Comment