Knowasiak

I constructed a receipt printer for GitHub concerns

I really have a bunch of side initiatives on GitHub. Some of them are roughly standard, and I are inclined to salvage concerns posted once quickly. The peril though is that in overall they roughly salvage misplaced within the combination of my emails, or I forget to struggle by plan of my repos and add novel objects to my todo list.

I’ve been once quickly writing novel concerns down on sticky notes at any time after I search for a notification for a peril, nonetheless I continuously wished an excuse to streamline the process a runt more. After seeing a receipt printer spitting out orders whereas grabbing some preserve terminate-out the diversified day, I wondered if I could use one to print out a impress on every occasion a peril became added to with out a doubt one of my repos.

Spoiler alert, it labored!

So for that reason I bought a receipt printer:

Whenever with out a doubt one of my GitHub repos will get a brand novel peril, I now salvage a physical impress printed out on my desk 🪄 pic.twitter.com/g6uYtGP9J7

— Andrew Schmelyun (@aschmelyun) March 24, 2022

So let’s dive in and I’m going to inform you exactly what I used, and how I set it Up!

Hardware list

In yelp to originate, I’m going to need a thermal receipt printer and a few technique to salvage data into it. I ended Up the use of:

  • Epson TM-T88IV
  • Raspberry Pi Zero W
  • Micro USB to USB adapter
  • USB Form-B cable

The reason that I went with an Epson thermal printer is that they use the ESC/POS inform set, for which there’s established libraries in a diversity of programming languages. Plus they’re aesthetic ubiquitous within the 2d-hand market, and I became in a design to determine one Up on Ebay alongside with some receipt paper for a aesthetic dazzling impress.

The diversified piece I need is some roughly hardware to connect from the internet to the printer, and facilitate the actual data sending. I could correct hook it as a lot as my PC, nonetheless I desire this to be a truly-contained unit that can perhaps correct be continuously on slothful sitting in a nook. I really have an former Raspberry Pi Zero W laying around that I am no longer the use of, so I’m going to amass that.

On myth of the RPi Zero has correct a single micro USB port, I’m going to use an adapter as properly as a USB Form-B cable to connect it to the receipt printer.

Sending data to the printer

Alright, so we now have the printer zigzag Up, the Raspberry Pi correct to fling, nonetheless now I need a technique to send data to the printer from the Raspberry Pi. This may perhaps occasionally perhaps without concerns be finished with Node or Python, nonetheless since I am a PHP developer and I like stretching the limitations of the language, I’m going to reach for that. Fortunately for me, there is a aesthetic solid library for working with ESC/POS commands on the market in PHP.

Forward of I write any code though, I must be clear the printer is supplied to this system I assemble. Since I am the use of Ubuntu on the Raspberry Pi, I must be in a design to access it through /dev/usb/lp0 (or one more lp#). But it no doubt could require a runt bit of prep work first.

First, I’m going to originate Up a terminal within the system that my printer is hooked as a lot as (for me, that is the Raspberry Pi). I’m going to urge the inform lsusb to salvage the Product ID and Vendor ID from the connection to your printer. It returns one thing love this:

Bus 002 Tool 001: ID 04b2: 0202 Epson TM-T888IV Tool Particulars

Subsequent, I assemble a udev rule to let customers belonging to the dialout team use the printer. I assemble the file /and so forth/udev/suggestions.d/99-escpos.suggestions and add the following to it:

SUBSYSTEM=="usb", ATTRS{idVendor}=="04b2", ATTRS{idProduct}=="0202", MODE="0664", GROUP="dialout"

Being sure to interchange the hex values for the seller and product ID’s with what I obtained returned abet from lsusb.

If my particular person(s) are no longer piece of the dialout team, I strive to add them to it now:

sudo usermod -a -G dialout pi && sudo usermod -a -G dialout root

After which within the extinguish, I really want to restart udev:

sudo provider udev restart

Now that I really have the connection ready, I will originate writing some code to envision this out. First, I’m going to require that library from earlier with Composer:

composer require mike42/escpos-php

After that is attach in, I want to write some code to send data to the printer. I’m going to assemble a file called index.php, and add the following:

textual speak material('Hello, world!');
$printer->feed(2);
$pri?php

require>

Read More

About the author: Vanic
“Simplicity, patience, compassion. These three are your greatest treasures. Simple in actions and thoughts, you return to the source of being. Patient with both friends and enemies, you accord with the way things are. Compassionate toward yourself, you reconcile all beings in the world.” ― Lao Tzu, Tao Te Ching

Get involved!

Get Connected!
One of the Biggest Social Platform for Entrepreneurs, College Students and all. Come and join our community. Expand your network and get to know new people!

Discussion(s)

No comments yet
Knowasiak We would like to show you notifications so you don't miss chats & status updates.
Dismiss
Allow Notifications