Raspberry Pi IoT ticket printer for online stores

  • Do you have an online store?
  • Are you a maker?
  • Do you want to optimize the selling process?

If you answer yes to all the questions, please keep reading because this is the instructable you are looking for. Also if you say no to one or more questions keep reading too, maybe you can print your email or make a secret organization mission printer. The posibilities and applications of this are endless.

The IoT is everywhere, now almost everything is conected to the internet and makes our lives easier. So I decided why not make a ticket printer machine that connects directly to an email account where all the orders made in my online store arrives and the print the tickets automatically for you.Raspberry Pi IoT ticket printer for online stores

But, how it works?

In any e-commerce platform when a client makes an order you receive an email. So this printer is conected via IMAP service to an email account that only receives this notification emails.

When the email arrives it contains some html code, so I used string functions to delete all the html code and only get the information that can be used. Then, I search for the data that I need to generate the ticket and after that I save it into different strings. When I have the data that I want, the ticket is printed.
Also the printer can detect if there is paper and only marks the email as “readed” if the ticket is successfully printed. And if you need to print it again, you only need to go to your inbox an mark that mail as “unread”.

Pretty simple, right?

I can not guarantee that my code is compatible with your specific e-commerce system, so in this Instructable I am only going to show you how to get the email and print the body. The transformation into a ticket going to be up to you, but dont worry is easy if you know how to work with strings.

Let's get started, shall we?

Step 1: Gathering all the parts

For this build you are going to need:

  • 1 x Raspberry Pi model B.
  • 1 x wifi miniature dongle.
  • 1x SD card with Raspbian installed.
  • 1 x Logic level shifter.
  • Some jumper wire (male to female and female to female).
  • 1 x Thermal receipt printer and extras.
  • 1 x Power supply (5v and al least 5A).
  • 1 x Panel mount DC barrel jack.
  • 1 x Pushbutton SPST.
  • 1 x Neopixel (WS2812B).
  • Enclosure and hardware.

You can get all the parts from Adafruit, and the files for laser-cutting the case can be found here: Acrilic Case

Also Adafruit offers a kit with almost everything to build this project, you can see it here.

Step 2: Making all the wiring and assembling the case

Now it's time to make the conections, I recommend you to assemble the case first but without the front plate (the one with the cloud). The wiring is as follows:

  • Raspberry pin 1 -> LV (low voltage) pin in the level shifter.
  • Raspberry pin 2 -> 5v from the barrel jack.
  • Raspberry pin 6 -> GND from the barrel jack.
  • Raspberry pin 8 -> Printer RX (yellow wire).
  • Raspberry pin 9 -> button common terminal.
  • Raspberry pin 10 -> level shifter RXO (rx output)
  • Raspberry pin 12 -> level shifter TXI (tx input)
  • Raspberry pin 14 -> Printer logic GND ( the gnd wire that is with rx and tx from the printer).
  • Raspberry pin 16 -> button normally open terminal.
  • Level shifter TXO -> Neopixel signal input.
  • Level shifter RXI -> Printer TX (green wire).
  • Level shifter HV -> 5v from the barrel jack.
  • Level shifter GND -> GND from the barrel jack.
  • Neopixel GND -> GND from the barrel jack.
  • Neopixel Vin -> 5v from the barrel jack.
  • Printer Vin -> 5v from the barrel jack.
  • Printer GND -> GND from the barrel jack.

And thats all, double check the connections and make sure everything is right. When you finish put the front plate of the printer and tight the screws. I glued a white acrilic at the back of the cloud and them the neopixel, so the entire cloud has a backlight powered by the neopixel.

Step 3: We have the hardware, it's time for the software

In this step I will assume that you already have installed Raspbian in the SD card and you have the wireless network up and running. A SSH link will be helpfull too. We will need to install some libraries and change a few settings, so let's begin:

Execute: “sudo raspi-config” and them go to Advanced options/serial and select “No” this will allow us to control, the serial port in the raspberry. We need it for controlling the thermal printer. After doing that run: “sudo reboot”

Now it's time for making the Neopixel works with the Raspberry, just follow the guide in this link and come back when you have the Neopixel up and running (stranstest), you don't need no rewire anything.

Now we will install all libraries and resources needed for our program, execute the following commands:

  • “sudo apt-get install python-pip”
  • “sudo pip install imapclient”
  • “sudo apt-get install python-serial python-imaging python-unidecode”
  • “sudo apt-get install git”
  • “git clone https://github.com/DAFRELECTRONICS/IoTprinter”

Now we are going to test the printer, run “cd IoTprinter” and then “sudo python printertest.py”. If your printer works you have made everything right. Now we almost finished, but we need to configure our email account, we will be using gmail.Raspberry Pi IoT ticket printer for online storesschematich

Step 4: Configuring Gmail account for the printer

The step number one is go into your gmail, then in in “My account” and after that in “Sign-in & security”. Search for “allow less secure apps” an turn it on.

And that all for a basic setup, but we are going to create an special folder with filtering. So we can guarantee that the printer only gets the desired emails.

To create our special folder we are going to click in the arrow in the search field of our inbox and define the parameters that we want. When you enter your parameters for the filter click in “Create filter with this search” at the botton.

In the next screen mark the options “skip inbox” and then “apply the label” and create a new label. This will be the folder name, I named it “Secret messages” but it can be anything. Just be sure that the name matches the one in the script in the raspberry pi. After that create the filter and you will see the new folder in your inbox, all the email with the parameters you defined will end in this folder. In my real aplication for my store th filter paramaters are the store email as sender and in subject is “new order”.

Ok, we are ready to configure our script in the raspberry.

 

 

For more detail: Raspberry Pi IoT ticket printer for online stores


About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top