Imagine that you just arrived home on a late dark night. Rather than searching for the light switches on the wall, would you like to turn on the light by simply clapping your hands? The demo shown below pretty much does what we described here – control your lights via hand claps.
In this demo, we have –
- Raspberry Pi Zero board as the end device.
- PIMORONI Blinkt! Light, a super slim line Raspberry Pi add-on board with eight super-bright RGB LED indicators. The light is mounted onto Raspberry Pi Zero board via GPIO pins.
- Mozilla Things Gateway. The gateway has a clap-sensing add-on that takes audio inputs, e.g. sound of hand claps in this case.
- Platform (a laptop PC or a Raspberry Pi 3) to run The Things Gateway framework.
The demo video is also available here if you are interested.
- Productivity: The language itself is pretty much platform and OS independent and there are a vast number of easy to use 3rd-party libraries available. These factors result in less time to introduce your products to markets.
On Constrained Device
In the demo, we have introduced JerryScript to the end device.
- JerryScript was created by Samsung from scratch in 2014.
- The JerryScript project is now under the umbrella of JS Foundation and was one of the JS Foundation’s very first sponsored projects.
Connect Device to Secure Gateway
For gateway, we have chosen The Things Gateway by Mozilla, an open gateway that anybody can now create with a Raspberry Pi to control Internet of Things devices. The Things Gateway has provided privacy and security features such as TLS encrypted tunneling service and third-party applications authorization using the de-facto authorization standard OAuth 2.0 etc. A more detailed discussion on these security features can be found in our previous blog here.
The backend of The Things Gateway uses the Web Things API from Mozilla IoT, to communicate with the front end. Web Things API is a proposal by Mozilla with “Web Thing Description” to describe things, “Web Thing REST API” and “Web Thing WebSocket API” to interact with ‘Things’.
In the demo, Blinkt! light is the “thing” for The Things Gateway and we need to describe Blinkt! Light following the “Web Things Description” format:
"Description": "A Blinkt! light",
"description": "Whether the Blinkt! light is turned on",
"description": "Turn the Blinkt! Light on and off"
My colleague, Phil Coval, has published “WebThing-IotJS“, an IoT.js implementation of WebThing API based on Mozilla-IoT’s webthing-node. It provides a baseline to add your own Web Thing on top of IoT.js. You can take Blinkt! Light Web Thing code as an example to try it out.
The Things Gateway has provided a rules engine. Through the rules engine, we can set rules between the clap-sensing add-on and Blinkt! Light webthing. In this demo, the Blinkt! Light state changes when the clap-sensing add-on detects an incoming hand-clapping sound.
There is a lot more you can do…