Today sees the launch of “Collections” – eBay’s newest feature that allows its members to curate products around certain themes or ideas – and Web of Things are proud to have helped EVRYTHNG contribute 12 Internet of Things Collections as part of the initial launch campaign.
We trust the IoT Collections will be well received in the existing hacker / coder / maker communities 😉 but we are also keen to encourage more people to get involved in this exciting space! In conjunction with EVRYTHNG we will therefore be releasing a series of “recipe” blogs to accompany the Collections, giving step-by-step guidance on how to build useful, interesting and fun connected products.
First up, Smart Lamps – change lamp colors and patterns based on real-world events!
As any respected IoT start-up does, EVRYTHNG try and run regular internal hackathons and the theme of the last one was “Pimp My Office” with the ultimate goal of producing a number of cool and useful IoT projects for the London office. The Pizzas were on order, devices and APIs were at the ready – the scene was set for a perfect hackathon! Eight or so hours later the Smart Lamps were born.
Amongst the IoT toys on the table for this hackathon were three Hue lamps. The concept behind the Hues is pretty simple: what if devices as dumb as light bulbs could become really smart? “As in controlling them with my phone?” I hear you say. Well, not only. Actually Philips went the extra mile to make them not only smart but also APIyfied. The result is a set of Zigbee lamps with a base-station that offers access to all the lamps have to offer through a… REST API. The lamps worked out-of-the box, the API is sound and RESTful, and the whole system is pretty fast. They definitely deserve the “Web of Things approved” sticker! 😉 After about 5 minutes of unboxing and setup we had three lamps and could change the mood colour through the Hue Android app.
Obviously our final goal wasn’t simply to use the lamps to reflect the mood in the office but to do something slightly smarter with them: enter Raspberry Pi. As surprising as it might be, we didn’t have much experience with the Pi for IoT projects. I guess a part of us still thinks in 8 bits and is more used to lower-power-lower-feature-more-hardcore kind of devices such as the Open Picus, the mBed or the Arduinos.
Ultimately we wanted to create a very visual and simple dashboard of how well EVRYTHNG’s infrastructure and software was doing at any point in time – statHues (status + Hues = statHues anybody, no?!).***
The concept is quite simple, on the one hand-side you have a couple of APIs giving you status data (inputs), a Raspberry Pi in the middle in charge of polling the different services on a regular basis and translating this into lamp colors and patterns, and finally the three Hue lamps (outputs) on the other side – and there you have your visual feedback system!
Although we used the system to monitor the status of EVRYTHNG’s infrastructure we wanted it to be usable for any other use-case you can think of such as monitoring the stock market or maybe even the weather – not necessarily utterly useful in London…! 😉
All the ingredients you need can be found in the EVRYTHNG Smart Lamps eBay Collection then simply follow the following steps and you should be good to go!
– We’ll skip the part about installing the Hue Lamps as this step is so beautifully easy. The only thing you need to make sure is that you have a developer account setup for your lamps.
– Then, you’ll need an SD card for your Pi ideally with Rasbian on it. So far so good?
– Next step is to get Node.js installed on your Pi, which I shall remind, runs on an ARM architecture CPU and hence isn’t really like any other laptop/desktop out there. There are a few routes to achieve this:
- Get the source and compile Node directly on, and hence for, your Pi (Gentoo anyone?) – this is by far the geekiest but won’t impress your girlfriend/husband/kids. Trust us.
- Get the ARM compiled binaries. You can find them directly in the Node dist folder (for some reason at the time of writing only up to Node 10.0.24) or in a debian package.
– Done? Good, next up is getting statHues from GIT and configuring it for the monitoring services you want to use. (DISCLAIMER: this code was written in a day after numerous slices of pizza, we might give it some love sometime in the future but until then please make sure you are wearing your anti-bugs-and-unclean-code glasses when looking at it…)
So that should be it (other than a shout out to the EVRYTHNG “Pimp My Office” hackathon team: Colin, Ben, Kieran, Vlad, Jean and Dom!).
Turn the lamps on, start the Node.js statHues server on your Pi and your lamps should show nice colors depending on the current state of your infrastructure or whatever you decided to monitor.
As far as the EVRYTHNG statHues office monitor is concerned:
Lamp 1 shows integration tests passing (green yes, red no – using Jenkins)
Lamp 2 shows if are we currently running builds of our main components (flashing orange means we are, green means the build has executed successfully – using Jenkins)
Lamp 3 shows all our external APIs are up and running (green yes, red nooooo – using Pingdom)
statHues currently supports Pingdom and Jenkins as inputs and Hue lamps as an output but you can easily extend it with additional input and output modules. The other week for example, we created an additional input to make a lamp blink whenever a vote was cast for EVRYTHNG in the Postscapes IoT Startup of the Year Awards – which we won btw! 😉
Watch this space for the next in the recipe blog series – EMF Smog Box – which will be live in the next couple of weeks, in the meantime, go and check out the rest of EVRTHNG’s eBay Collections.
*** No lamps were hurt in the writing of this blog. 😉