Monday, 17 July, 2017 UTC


Summary

Introduction to DeviceJS
DeviceJS is a Jquery for the IoT world. It’s built on top of NodeJS and already supports the most common protocols like Z-Wave, ZigBee, Bluetooth etc. It has the capability to easily connect to most of the IoT systems across the domain. It also helps in the rapid creation of NodeJS based web application which can scale to a huge extent.
DeviceJS has Numerous capabilities that it adds to the system:-
  • A distributed JSON database that updates live into DeviceJS runtime
  • An Object based API
  • Service hooks
  • Asynchronous JavaScript
Now as we have seen the different capability of DeviceJS. Let’s see how simple it is to just light up a LED in a JQuery way. Let’s see two use-cases of glowing a LED which is more like a JQuery like syntax.

Turing Lights in a certain Location Red

In order to turn the LED red at a certain location, the only thing you need to do is to call the functions in the manner shown below
dev$.byLocation("kitchen").setColor("red");
You can see how the chaining of the functions work and perform in order to get the change of the color of a LED as and where you require it. It’s a pretty small example but we can try out some more in order to see how it works. Let’s have a look.
dev$.byDeviceAlias('hallway-sensor').trigger('motion',function(){
    dev$.byLocation('hallway').setOn();
});
The code above will make you call events as well. If you look at this diligently you can see that the motion of an individual cause the lights to go live when some motion is being sensed in the hallway.
As you can see that DeviceJS has a great scope and getting started is also pretty easy with it. Most of the developers can get started by just using Arduino and Raspberry PI. So if you look into the detailed documentation of DeviceJS one can easily understand how to implement these into a system. This is a good tool to start with and one can get into the IoT ecosystem using this pretty well.
The post DeviceJS – JavaScript in Physical World appeared first on The Web Juice.