Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including sensorjs with all npm packages installed. Try it out:

var sensorjs = require("sensorjs")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

sensorjs v0.0.6

sensor framework and beyond for internt of things

sensorjs

This module handles all about sensor with powerful and familiar techs. In other words this sensorjs is not only sensor driver module but also framework like express.

And it's working on linux boards such as the BeagleBone or Raspberry Pi.

gateway

Here is currently available sensors.

Installation

$ npm install sensorjs 

sensor.js URL scheme

sensorjs://[{gateway}]/{sensor network}[:{bus id}]/{address}/{sensor model}/{sensor id}

  • example
    • sensorjs:///ble/000A3A58F310/dht22/22-000003a7f590
    • sensorjs:///i2c:1/33/dht33/22-000003a7f590
    • sensorjs:///gpio/22/singleled/r222

Example

var connect = require('sensorjs'),
   sensorDriver = connect.sensor;

var app = connect().
  use(connect.filter({$between: [-50, 50]})). // filter: passing between -50 and 50
  use(connect.average(20 /*duration*/)).     // reduce: values to an average every 20 sec.
  use(function (data, next) {                // custom middleware
    if (Math.max.apply(null, data.queue) < data.value) {
      console.log('new record', data.value);
    } 
    next();
  }).
  use(connect.queue(100)).                   // buffering max # of 100.
  use('/w1/*/ds18b20', function (data, next) {
    if (data.value > 20) {
      console.log('getting hot:', data.value);
    }
    next();
  }).
  use('/gpio/*/dht11', function (data, next) {
    if (data.value < 30) {
      console.log('getting dry:', data.value);
    }
    next();
  });
  // transport(mqtt, localStorage, websocket and etc)
  //use(connect.websocket('http://yourhost.com', 'temperature/{id}'/*topic*/));

More examples are here.

Contributor

https://github.com/daliworks/sensorjs/graphs/contributors

License

(The MIT License)

Copyright (c) 2013 Daliworks Inc

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

@sensorjs

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free