DeviceJS is Javascript for the Physical World


DeviceJS lets you sense and control the physical world around you with Javascript.

Overview

DeviceJS is a JavaScript based development platform for reacting to sensors and controlling devices. It’s built on top of Google’s V8 JavaScript engine, Node.js and a real-time JSON database. A DeviceJS application can run on a single device, or across many devices in different locations. You can use it to build sensor networks which react to events, gather physical analytics and send them to other services or automate systems. DeviceJS is protocol agnostic from a developer’s stand point. It will include support for protocols such as 6loWPAN, ZigBee, Z-Wave, RS-232 communications, and all types of IP based protocols.

Why JavaScript?

JavaScript is by far the most widely used language in the open source community. It’s easy to write simple scripts and it’s powerful enough to do complex tasks. Most importantly, it’s very well known by many programmers.

One script, execute it everywhere

Real world, complex sensor networks and automated systems often span multiple locations. In traditional systems, this means maintaining multiple controllers and managing programs which run on these different systems, ensuring they can talk to one-another. DeviceJS let’s you write a single program and distribute it over multiple controllers in different locations transparently. This means from a developer’s or maintainer’s viewpoint, the system can be much simpler. DeviceJS can distribute a script across any relay capable of running the DeviceJS run-time.

More: How it works

Patterns you already know

DeviceJS aims to enable developers familiar with client side web development libraries to easily make things happen dynamically in the physical world.

Selectors

A simple example is the selector pattern, seen in frameworks like jQuery and d3.js.

Turn all paragraph text to red in jQuery:

$("p").css("color","red");

The same thing in d3.js:

d3.selectAll("p").style("color", "red");

A similar pattern in DeviceJS – turn all lighting in a location red:

dev$.byLocation("kitchen").setColor("red");

Events

In jQuery this would pop-up an alert dialog box on a ‘click’:

$('#foo').on('click', function() {
    alert($(this).text());
});

In the physical world, we could handle things similarly with DeviceJS:

dev$.byDeviceAlias('hallway-sensor').trigger('motion', function() {
    dev$.byLocation('hallway').setOn();
});

DeviceJS also allows trigger evaluation functions, which can help determine whether a sensor event is signficant.

More information will be available when DeviceJS is released on github and the API is published.

See also: Efficient Selectors, How it works