October 30, 2023

RuuviTag and Node-Red

 Updated 2023-10-30 ! OK with Bookworm ! New simple install ! 

For a new project I needed a small wireless temperature sensor, there You don't have to change battery so often, and this gave the RuuviTag.


Having used Node-Red(NR) on Raspberry Pi before, the first application was this dashboard. 
Tested and works with with Node.js V18 !














Installing
Update OS
Always start updating with

sudo apt update && sudo apt full-upgrade -y && sudo apt clean

NodeRed install ?
Do a Node-red installation, if you are missing one, including the dashboard node-red-dashboard.

Check Bluetooth
Check the interface with

hciconfig

Installing necessary SW
Dependencies 
sudo apt install libbluetooth-dev libudev-dev
Grant the node binary "cap_net_raw" privileges, so it can start/stop BLE advertising, with command

sudo setcap cap_net_raw+eip $(eval readlink -f `which node`)

Install thenoble package from command line 
cd ~/.node-red
npm install @abandonware/noble

Via the NR GUI install node-red-contrib-ble-sense.

Restart NR!!! sudo systemctl restart noderedand check the installed Node via the NR GUI. It will appear in the Node list below "BLE Sense", named BLE Scanner.
Download, import and deploy the NR flow(RuuviTag.json) from Github and check it out.
Remarks
Received data
Please note that you can receive several broadcasts from the same sensor during the 5 seconds of scan. 
More than one Ruuvi Tag ?
The flow works for ONE tag ! If you want to receive several tags distinguish on the value mac which is the individual MAC id. A switch node could be one way to handle it ?!
Error
If you get, after for example an upgrade, "Unable to start BLE scan" in the RPi syslog run the "setcap" command mentioned above.
Check this post to get som more info at errors.
Ruuvi station app
With the iOS app you now can update the firmware in the Ruuvi TAG.
Format
The RuuviTags can output
several formats, but this one is in actual production. This
99040510604390c68c0034ffcc0418a1b6044230c9ea85c7aacb
is an output caught after the scan node. The 05 direct after 9904 is the code for the dataformat.

Old flow
Install dependencies

sudo apt install libbluetooth-dev libudev-dev git

Install thenoble package, the latest updated node-red-contrib-noble node and thenode-red-contrib-ruuvitagnode

cd ~/.node-red
npm install @abandonware/noble
npm install MatsA/node-red-contrib-noble
npm install ojousima/node-red

Restart NR,sudo systemctl restart nodered, and check the installed Nodes via the NR GUI. It will appear in the Node list below "advanced", named scan ble and ruuvitag.

The NR flow(RuuviTag_old.json), shown dashboard above, can be downloaded from GitHub.

7 comments:

  1. Hi,
    Nice tutorial. Do you know how this would work with Open-plotter v2 and embedded Node-red?

    ReplyDelete
    Replies
    1. ...think the best way is to use the SignalK Ruuvi plugin. https://www.npmjs.com/package/signalk-ruuvitag-plugin

      Delete
  2. Thank you for your quick reply. I have to try that next...

    ReplyDelete
  3. I have several Ruuvi tags and now installing this flow. But come to a problem in the last step for "The Node-Red flow, shown dashboard above, can be downloaded from GitHub. "
    How to make that last step? I don't have enough knowledge on how to do that step to get the visual interface loaded. Could you please give a bit help!

    ReplyDelete
    Replies
    1. OK. Click on the link which will take you to Github. Click on the file name "RuuviTag.json". Click on "Raw" and copy the displayed text. In NodeRed "Meny=>Import=>Clipboard" paste the flow. "Import to=>New flow". Enjoy !

      Delete
  4. Thanks for help.
    Managed to set up the dashboard, but how to include multiple tags?
    Now the dashboard randomly scans through all tags and shows some. But how to control the flow such that tags are identified and on the dashboard shown the tags name (based on mac or uuid...)? Listing long uuid's on ScanBLE node seems not to work. And then still the identification part....

    ReplyDelete
    Replies
    1. Nice you made it! As said above, use "peripheralUuid" to map to your own id like, fridge, dining room....

      Delete

Feel free to leave a comment ! ... but due to a lot of spam comments I have to moderate them. Will reply ASAP !