Lightweight implementation of W3C spec, targeting constrained devices.
Several JavaScript runtimes are supported (node.js, IoT.js using JerryScript)
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)
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
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
(...)
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).
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
# (...)
- https://www.npmjs.com/package/generic-sensors-lite
- https://github.com/rzr/generic-sensors-lite
- https://w3c.github.io/sensors/
- https://github.com/rzr/mozilla-iot-generic-sensors-adapter
- https://s-opensource.org/2018/04/25/mozilla-iot-generic-sensors/
- miroRucka/bh1750#17
- dbridges/bmp085-sensor#7
- https://github.com/samsung/iotjs/wiki
- https://github.com/samsung/iotjs
- http://www.iotjs.net/
- http://jerryscript.net/
- https://github.com/rzr/webthing-iotjs/wiki/IotJs
- https://github.com/rzr/webthing-iotjs/wiki/Sensor
- https://social.samsunginter.net/@rzr/100969945665369600