We’ve always celebrated geekiness and when it comes to personal geeky projects, these are often a great learning ground too! We take a look at Chief Geek Jason’s latest creation…
I don’t know where the inspiration for this came from, maybe it was seeing my biscuit tin disappear upstairs most evenings with one of the kids looking decidedly shifty with a biscuit tin shaped bulge under their jumpers.
Either way as a software developer, I’ve always been curious about the link between software and hardware with hardware always being something of a mystery to me.
That all changed when I bought a Raspberry Pi, a well known low cost computer running an ARM chip that offers a simple IO (Input/Output) interface allowing you to plug in custom hardware that could be controlled by simple scripts.
It was probably a slightly drunken conversation with a fellow developer at Wagama’s then, that planted the seed. What if you could take a random household item and make it “smart” by connecting it to the internet? The “smart” biscuit tin was born, as let’s face it, everyone loves biscuits right?
So….after a tonne of Googling, here’s what I found:
Raspberry Pi, connected to something called a HX711 Load Cell (the thing that measures weight), some wires, some jack plugs and that was the hardware sorted.
How about the software?
To measure the biscuit weight, I needed to write a small controller script to run on the Rasberry Pi. The script would take a measure of the Load cell every couple of seconds.
What I quickly realised is that even when static, the weight reads varied, so I had to build in a tolerance of +/- n grams. Normally at FL1 we used PHP, so time to quickly learn Python!
Next, was picking up notable changes. I bought a Sainsburys variety pack of biscuits, just so I could weigh them, and I can tell you now, the average biscuit weight is 9g! So we have nominal weight. Then I built in thresholds. The thresholds would be used to guess if “one biscuit has been removed”, “a few biscuits have been removed” or “good god, someone‘s cleaned you out!”. So with 3 thresholds and a simple 10% tolerance, we’re good to go….and it worked!
So what next?
Well, I guess you need to tell someone right?
I did what any web developer would do and built a simple API using PHP.
Simply put, the Raspberry takes a reading, if it’s out of tolerance, it posts it to the API.
The API decides based on the reading whether it’s a biscuit, a few biscuits or a massive biscuit raid, then sends a notification via email.
Great, so now my inbox is full of my kids’ biscuit tin raids…that’s not enough, we can’t stop there!
Next, an App….because, well, why not!
Being from an old skool C# background, I figured why try out Xamarin? Xamarin is Microsoft’s last Mobile application framework for .NET.
So after a few weeks, voila, now I can monitor every movement of my biscuit tin, every addition, removal and I get push notifications in real-time!
So…was it worth it?
YES! I learnt soooo much, and got to build my first mobile app too! Not only that, my biscuit is now full again, since that little wire has been hanging out of the back, my little biscuit lovers won’t go near it 😉