In early 2018, my friend Steve had an idea. His church supports missionaries, and for fundraisers, they sell lunches to the congregation. In the past, they had volunteers prepare and serve the food. It was a lot of effort, and Steve thought that it could be improved. He thought that having a restaurant make the food would allow them to charge a bit more for the food, and might draw more attention. He was right of course, and now he wanted a way to engage the participants even more. He wanted some kind of visual progress indicator. something that would get people excited about participating in supporting the cause.
“What if we had a big button that people could push when they buy a lunch, and then have a big display of how many lunches we’ve sold?”
That sounded like a cool idea to me. So, I set out to build just that.
I tried to make this as simple as possible. No, really I did! However, the constraints of the environment dictated otherwise. I thought the simplest thing would be to have a button attached to a Raspberry Pi, which would be attached to a screen via an HDMI cable. However, the display needed to be relatively far away from where people would be paying for lunch, and running a long HDMI cable was not acceptable. Steve mentioned that they had an extra laptop that they could connect to the TV, so this seemed like a reasonable solution.
After some noodling, I decided that I’d have a big button box with a Raspberry Pi inside. The Pi would host a web server that publishes a page with the count on it. The laptop connected to the TV would access the web page and display it on the TV.
Is this the simplest design? Not by a long shot. Would it be fun to build? Absolutely! I also like the idea that this solution is self-contained. If the TV has a browser, then the laptop can be removed from the setup.
The Button Box Design
The hardest and most interesting part of this project to me was the button box. I’d been itching for a project to use the laser cutter at our makerspace, theLab.ms. While I could have just used a tool to generate the dimensions of the box with appropriate notches for assembly, I decided it would be fun to figure it out on my own. Here’s what I wound up with…
I made the first prototype with cardboard, which worked out perfectly!
Happy with the results, I moved on to the 2nd prototype, which was made out of MDF scraps at the makerspace (I think I also got some hardboard in there, too).
Since this button box would be operated by non-technical folks, I decided I should add a shutdown feature to prevent damage to the SD card. When the button is held for 2 seconds, a shutdown command is sent to the Pi. Of course, nothing stops the user from just disconnecting power, but at least the capability is there. Since the Pi doesn’t have any built-in capability to shutdown the OS, I added a momentary contact button to the bottom of the box to serve this purpose.
Everything was going great until I received my acrylic sheets. I thought I was getting 3mm acrylic sheets, but I actually ordered 2mm acrylic sheets. *sigh*. But thankfully, I made the material thickness a variable in my OpenSCAD model, so I just needed to change that variable from a 3 to a 2, and adjust the placement of the power connector hole (that took a bunch of trial and error).
After the adjustments, I re-cut the box from the spare sheet of acrylic (always a good idea to get more than you absolutely need in case you make a mistake!).
To keep the wiring nice and clean, I used a Perma-Proto hat from Adafruit. I’ve used them in a few projects now and I’m hooked. For the relatively small circuits I’m making, they’re perfect, and don’t add much to the footprint of the project.
The RESTful Web App
I really enjoy projects that involve physical builds as well as software. In the spirit of over-engineering things, I decided to make my counter a RESTful Web Service. You can find the source code on bitbucket. When the big button is pressed, python code sends an HTTP request to the web server, incrementing the stored count. The web page showing the count updates every 1/2 second. For the shutdown, holding the button on the bottom of the box sends another request that executes a graceful shutdown of the web server and the Raspberry Pi.
Here is the whole thing in action!
- Test it out in the target environment
- I’d like to make the typeface fixed-width
- There is code to set a target number. I’d like to add some animation that is triggered when the goal is reached