It’s time again for an eBay Internet of Things Collection recipe. This time we’ll be looking at a nice challenge we tackled at the last Web of Things Hackathon – the Smart Fussball Table!
This yearly hackathon (stay tuned for the next one – advertised soon) is always focusing on a challenge that involves real world objects and their connectivity not only to the the Internet but also to the Web. In short it is always about having things talking to each other and humans based on Web protocols and tools.
The 2013 editions’ theme was all about football: enhancing a Fussball Table with a number of sensors and actuators to make it a lot smarter.
First we wanted the goals to be automatically counted. We also wanted to display the score in real-time and have the ability to automatically share the score on social networks.
The Tech:
Rather than building monolithic applications the WoT Hackathons are usually about building different pieces with different IoT technologies and then making sure they all speak Web protocols to assemble the puzzle themselves in an almost spontaneous manner.
So the project comprised of four independent parts.
The Goals:
The first step was to instrument the goals. In the first goal we placed an Arduino Uno with a simple motion sensor, we then wrote a simple bit of code that could detect whether there was an object (i.e. a ball) nearby. This Arduino was then setup to communicate with the EVRYTHNG API where it was storing a goal counter using EVRYTHNG’s RESTful dynamic properties API.
Another team worked on the second goal which was equipped with an OpenPicus Flyport and a Grove Motion sensor. This embedded device was then connected to the COMPOSE platform where counter increments were sent over HTTP.
Basically we could have used any combination of embedded device + motion sensor + cloud platform to achieve this goal. The only requirement was for the device to support HTTP for notifying the cloud service. (FYI – a spare kit was was also developed using an ElectricImp and the EVRYTHNG API).
The Scoreboard:
It’s great to have a way of detecting when goals are scored but it’s only really useful if you have a place where you can display this information. For this we used an off-the-shelf Kindle e-reader. “What? You created a Kindle app just for this?” I hear you say. Well not exactly. One thing that most e-readers support is the ability to surf the Web, with just enough Javascript support. Hence all we had to do is to create a page with a tiny bit of Javascript that pulls from both goal counters – both the EVRYTHNG and the COMPOSE APIs – and displays them full-screen on a Web page. After implementing this on a Kindle we also tried it on the (cheaper and slightly more open!) Kobo reader and it worked just fine as well!
Here is what the code looks like for the EVRYTHNG API:
Link to the Code.
The Social Bit:
Last but not least, we wanted players to be able to “check into” the Fussball Table before starting a game with their Facebook account, so that we could share the score at the end of the game.
For this we used the EVRYTHNG API’s Facebook connector. With just a bit of code and the EVRYTHNG.js (beta) SDK you can create an app that allows a Facebook user (here the player) to check into an EVRYTHNG managed thng (here the Fussball Table).
The steps are pretty straight forward:
-
Create a new EVRYTHNG app from the EVRYTHNG dashboard.
-
Create a Thng corresponding to the Fussball Table and generate its QR code, redirecting to where you’ll put your final app.
-
Use the EVRYTHNG.js SDK to allow Facebook users scanning the QR code checking into the Fussball Table.
Here is what the code for this last step would look like:
Link to the Code.
It’s all about spontaneity…
Here comes the beautiful part. As I said before Web of Things Hackathons are all about unplanned interactions between people and things. Well this Fussball Table is a neat example of spontaneity:
- The embedded devices in the goals do not know of each other, furthermore they do not know they are goals. All they know is that if they detect an object (i.e., the ball) they have to update a property stored on the EVRYTHNG (respectively COMPOSE) API.
- Moreover, the scoreboard doesn’t know much about fussball or about the ongoing game, all it knows is a URL to get one counter from the EVRYTHNG API and one from the COMPOSE platform.
- Similarly, all the sharing page needs to know is the address of the Thng on the EVRYTHNG API corresponding to the object from which to extract the properties to push to Facebook.
Besides the fact that it was real fun building and testing it in a day I really like this prototype because it illustrates two important concepts for connecting things.
First it shows how the use of Web protocols and tools (here HTTP and Javascript) facilitate integration: the Flyport, the ElectricImp and the Arduino had no problems using HTTP to communicate with the EVRYTHG and COMPOSE APIs. Similarly, the Kobo and Kindle can easily fetch the data provided by the embedded devices based on Javascript.
Secondly, it also shows how IoT and WoT cloud platforms can be the mediators of relatively complex, sometimes unplanned, real-world workflows. Indeed, all the actors of the Smart Fussball Table use-case rely on the fact that the data is pushed to a universally accessible API in the cloud where it can reliably and easily retrieved by all interested parties without firewall, connectivity, availability or protocols incompatibilities issues.