My wife has a shopify account where she takes orders for her online business (MyPaperdot.com). Because sometimes she’s knee deep into work, kids, etc, there are times where she won’t see an order come in until an hour or so after it comes in.
I used a generic pcb, a couple of resistors (330 ohm, I believe), a raspberry pi zero and case as well as a 3 digit 7 segment display.
There are 7 connectors for the digits (that’s where the name 7-segment display) comes from. Each of the connectors needs to be connected to a GPIO pin on the Pi through a resistor.
There are also 3 other leads that will be connected directly to a GPIO pin (no resistor). Whichever is activated will make that digit turn on.
This is what the connectors look like:
You can choose any pin to connect the leads to so long as it is a GPIO pin. For reference, you can look here: https://pinout.xyz/
I have terrible soldering skills, but I tried my best to make it as tidy as possible. I used a proto-pcb and soldered the leads so that they would align to the GPIO pins when mated to the Pi.
This is how I test fitted the connections:
I then proceeded to solder the cables and resistors on the back (between the Pi and the PCB.
The next step was to put the Pi in the case, connect the PCB and finish soldering the connections.
Here is the code: https://github.com/robtrevino/piOrderCounter/blob/master/alerting.py
The Pi needs to know where you connected each of the leads of the display. You can see those in lines 18 and 27.
You also need to specify which segments are on and which are off for each number. You can see that being setup in lines 33 through 43
Shopify provides a very simple Restful API to read orders. I used the Requests package to make calls to the API, parse the results and then light up the proper segments to show the number. You can see these calls on lines 63 through 65.
Once we know what number we want to display, we need to tell the Pi to:
- Turn on those segments
- Turn it on only for that digit
The second part is tricky, because, for example, if you need to display the number 15, you need to turn on two digits, and you need to have different segments for each. The trick is to use something called persistence of vision to our advantage.
What this means in the code is that we will turn on and off each digit really fast. I found that 4 milliseconds gives a really good result (i.e. no flickering). You can see this being done in lines 53 through 59.
I hope you enjoy this project as much as I did and can find other cool useful ideas for the display!