1.0.0 • Published 4 years ago

node-iotsensortag v1.0.0

Weekly downloads
4
License
BSD-3
Repository
github
Last release
4 years ago

node-iotsensortag

Node.js module for reading data from a Ruuvitag and IoTSensor .

Tested on Raspberry Pi 3. Depends on noble. See instructions on how to enable BLE on RasPi and how to run without root.

Installation

npm install node-iotsensortag

Usage example

const iotsensor = require('node-iotsensortag');

iotsensor.on('found', iotsensortag => {
  console.log('Found IoTSenorTag, id: ' + iotsensortag.id);
  iotsensortag.on('updated', data => {
    console.log('Got data from IoTSenorTag ' + iotsensortag.id + ':\n' +
      JSON.stringify(data, null, '\t'));
  });
});

Events

Module iotsensor emits a found event, when a new iotsensortag is discovered. Event's payload is a iotsensortag object (see below)

API

iotsensor.findTags()

Finds available iotsensortag. Returns a promise which is resolved with an array of iotsensortag objects or rejected with an error if no tags were found.

If you call findTags multiple times, it always returns all found RuuviTags this far.

iotsensortag object

Is an eventEmitter .

Properties:

  • id: id of beacon
  • address: address of beacon
  • addressType: addressType of address
  • connectable: flag if beacon is connectable

Events:

updated: emitted when weather station data is received. Object data has following properties (depending on data format):

  • url -- original broadcasted url if any
  • temperature
  • pressure
  • humidity
  • eddystoneId -- in data format 4
  • rssi
  • battery (battery voltage)
  • accelerationX
  • accelerationY
  • accelerationZ
  • txPower -- in data format 5
  • movementCounter -- in data format 5
  • measurementSequenceNumber -- in data format 5
  • sequence -- in data format 2
  • HRate -- in data format 2
  • SpO2 -- in data format 2

See data formats for info about iotsensortag sensor values.