Garry's SMART HOME ON THE CHEAP
What colour bin was it this week?
Our project this month is a little more technical than some but bear with us...
A few weeks back I committed the mortal sin of putting the wrong bin out. Like many UK households we have multiple colour bins for different types of waste. Here it is pretty simple a small food bin that can go out any week and then one week a Black Bin for non-recyclable waste and alternate weeks a brown bin for garden waste and a green bin for recyclables.
These bins normally go out on a Thursday but that can changed based on Holidays, Weather, Council Whim! The Council does have a website to tell you which colour bins are due to go out and when but that takes effort to view and I just want to know immediately what bin to put out (actually a bit of warning would also be nice so I can plan to empty all the inside bins outside) - Yes this is really the definition of a first world problem but one that became an interesting challenge.
The first thing was to think of something I would notice if it told me when the bins were due out. After some churnng of mental gears it struck me that I look at the kitchen clock everyday. This is a big and bold clock that makes it very easy to see the time across the room. I decided to try and produce something similar which would have the bonus of showing the bin colours and day.
Building the clock was fun but relatively easy (really easy if your soldering skills are better than mine)
I started with a couple of really cheap components a Wemos D1 ESP8266 as the controller and a MAX7219 matrix bar (this is actually 4 MAX7219 displays side by side giving a 32 by 8 display). I soon realised one MAX7219 wasn't going to be tall enough to replicate the clear display I wanted so I ended up stacking two bars on top of each other giving 32 x 16 to play with. I then found the excelent Open Source project from YouTube user CBM80Amiga here. His open source code formed an excellent basis for what I wanted. I had to tweak it a bit to connect to my home WiFi, get UK time rather than somewhere in europe and adjust properly for summer time but soon had a clock up and running.
The ESP8266 chip is an excellent chipset for wireless Smarthome/IOT style projects which is probably why Sonoff use a variety of it in their commercial Smart Home plugs and switches. One of the great advantages of useing the Wemos D1 version is that it has a Micro USB on board that can be used to power the board and tapped for a 5V power supply for the LED Matrices.
OK so I now had a clock and a nice bit of C code I could modify to add in internet calls but how to get the bin day data? This proved somewhat more challenging.
There is no standard for bin day information to be supplied so each council does its own thing. In my case a fairly wordy website which you enter your post code on and then get back a list of the next few week's bin days and colours. Now I know how to scrape information off a website so I set about writing code for the ESP8266 to parse the data from the site for my postcode.
Unfortunately I hit a dead end. There wasn't enough memory in the ESP8266 to handle this process no matter how I pruned it.
I finally gave up and decided I needed to move the heavy lifting somewhere else but where I didn't want to have to run, and more importantly pay for, a full blown server for such a minimal use case. Fortunately a lovely technology called Azure Functions came to my rescue (Amazon has somethng very similar called Lambdas which I could have used but I preferred the Azure C# support) These are serverless pieces of code that run on demand and you only pay for when run (the cost for running my clock for a month turns out to be pennies)
I knocked up an Azure function to do the heavy lifting of the page scrape which it only ran once a day and then cached the data. The clock calls an Azure Function that reads the cache and hey presto, with a little bent perspex to hold it, a clock that knows what day which colour bins go out. Only problem is I have no excuse if I get it wrong now.
Garry has an opinion on the recent FullyCharge Live Show
What day was it I am supposed to put out the bin
Making the Kitchen a healthier place
Scribbling on screens
Bluetooth calls on the move
Garry gets all foamy and steamy... with a milk frother from Melitta, prints small 3D things with the DaVinci Nano and zooms in a long way to summer with the camera from Kodak on our cover
|Back to the cover|