Nocturnal Parakeet Monitor
Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

generic-sensors-lite

0.0.5 • Public • Published

GENERIC-SENSORS-LITE

GitHub forks license NPM Build Status dependencies Status FOSSA Status

NPM

INTRODUCTION:

Lightweight implementation of W3C spec, targeting constrained devices.

Several JavaScript runtimes are supported (node.js, IoT.js using JerryScript)

Presentation

USAGE:

Following sensors can be plugged on pins of your favorite single board computer:

  • BH1650: for measuring illuminance (i2c=0x23)
  • BMPx80: for measuring temperature, or any compatible sensor (ie: BMP180, i2c=0x77)

SETUP:

Privileged access to hardware resources is also required too (setup or use sudo).

For instance on Raspbian:

sudo raspi-config # Enable I2C
ls -l /dev/i2c* || sudo reboot
sudo apt-get install i2c-tools
/usr/sbin/i2cdetect -y 1

     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- 23 -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- 77

USING NODE.JS:

git clone --recursive https://github.com/rzr/generic-sensors-lite
cd generic-sensors-lite
npm install
npm test
(...)
log: temperature: 28.1
log: ambientlight: 51
log: temperature: 28.1
log: temperature: 28.1
log: ambientlight: 51
(...)

USING IOT.JS

For constrained environments:

make runtime=iotjs run
# (...)
# iotjs example/index.js 
# log: temperature: 31.8
# log: ambientlight: 16.666666666666668
# (...)

Note: It has been verified on GNU/Linux not TizenRT yet (TODO).

DEMO:

web-of-things-agriculture-20180712rzr.webm

An extra example is provided to show integration in Mozilla's Thing project. Sensors are powered by webthing-iotjs and monitored on dashboard as progressive web app (PWA).

Usage:

make runtime=iotjs run
make -C example/webthing runtime=iotjs run
# (...) 
# log: AmbientLight: AmbientLight: change: 28.333333333333336 
# log: Temperature: Temperature: change: 33 
# (...) 

Respectively node could be supported too, just adapt to webthing-node API instead of webthing-iotjs (TODO):

make -C example/webthing runtime=node run
# (...) 

RESOURCES:

LICENSE:

FOSSA Status

install

npm i generic-sensors-lite

Downloadsweekly downloads

78

version

0.0.5

license

Apache-2.0

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability