Giter Site home page Giter Site logo

node-ruuvitag's Introduction

node-ruuvitag

Node.js module for reading data from a Ruuvitag weather station.

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-ruuvitag

Usage example

const ruuvi = require('node-ruuvitag');

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

ruuvi.on('warning', message => {
  console.error(new Error(message));
});

Events

found

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

warning

Module relays noble's warning events (see below)

API

ruuvi.findTags()

Finds available ruuvitags. Returns a promise which is resolved with an array of ruuviTag 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.

ruuviTag 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
  • mac -- in data format 5

See data formats for info about RuuviTag sensor values.

node-ruuvitag's People

Contributors

akx avatar aprilsnows avatar balda avatar dependabot-preview[bot] avatar espesen avatar glenf avatar iler avatar io53 avatar okko avatar pakastin avatar pbfulmar avatar tspoeri avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

node-ruuvitag's Issues

Emit tag ID with updated tag data

Hi, would it be possible to emit tag ID with updated tag data as well?

id attribute should be added in emitted event data in the following location: https://github.com/Espesen/node-ruuvitag/blob/5fb169467c4b238c035ad26709b713eb7c4f3972/ruuvi.js#L81

Specifically id: parsed.id in the following block of code:

            ruuviTag.emit('updated', {
              url: url,
              dataFormat: parsed.dataFormat,
              rssi: peripheral.rssi,
              humidity: parsed.humidity,
              temperature: parsed.temperature,
              pressure: parsed.pressure,
              id: parsed.id

EventEmitter memory leak

I have this problem when I use ruuvi.findTags() several times until it scans all of my beacons:

(node:27535) Warning: Possible EventEmitter memory leak detected. 11 discover listeners added. Use emitter.setMaxListeners() to increase limit

Is there anyways to remove evenEmiiter when it re-scan?

SyntaxError in README.md

Hi! Thanks for fixing the previous problem.

I found a syntax error in the README:
SyntaxError: missing ) after argument list

I sent a pull request to fix this.

Cheers,
Aprilsnows

Having trouble with discovering Ruuvi Tags

Hey there. Just wanted say that I really like the app for simple BLE scanning. My issue is that when I run the program via ruuvi-iothub, the program quite often will never discover my tags and start reporting them into Azure IoT Hub. What I have found is that if place plastic between the battery and the tag power terminal, start the program on my rpi, then remove the plastic, the program will discover the ruuvi tag. My goal is for it to always find tags without having to power cycle them. Any insight would be great.

EAFNOSUPPORT, Address family not supported by protocol

Hi, I'm getting the below error when I'm trying to run your sample code

Error: EAFNOSUPPORT, Address family not supported by protocol
at new Hci (/home/fady/ruuvi/node_modules/@abandonware/noble/lib/hci-socket/hci.js:74:18)
at new NobleBindings (/home/fady/ruuvi/node_modules/@abandonware/noble/lib/hci-socket/bindings.js:25:15)
at Object. (/home/fady/ruuvi/node_modules/@abandonware/noble/lib/hci-socket/bindings.js:546:18)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)

a copy of the sample code used


const ruuvi = require('node-ruuvitag');

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

ruuvi.on('warning', message => {
  console.error(new Error(message));
});

Stops receiving data

For the past week (started 05-05-2020), node-ruuvitag intermittently stops receiving data from the tags. It runs fine for minutes or hours, then nothing. I have logging on updated event handler, and it just stops getting called. There are no exceptions or errors detected and the node app is running.

    tag.on('updated', data => {
        log.info('Got data ', data);

Is there a way to dig out some noble related logs to find out what is going on in the background?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.