Node-RED Node

Hi!

I copypasted this to Node-Red, but it seems that I can’t get any MQTT messages. I did setcaps command and everyting seems OK.

pi@raspberrypi:~ $ sudo systemctl status nodered.service
● nodered.service - Node-RED graphical event wiring tool
   Loaded: loaded (/lib/systemd/system/nodered.service; enabled; vendor preset: enabled)
   Active: active (running) since Fri 2019-01-18 09:56:24 GMT; 3min 0s ago
     Docs: http://nodered.org/docs/hardware/raspberrypi.html
 Main PID: 314 (node-red)
   CGroup: /system.slice/nodered.service
           └─314 node-red

Jan 18 09:56:39 raspberrypi Node-RED[314]: your credentials.
Jan 18 09:56:39 raspberrypi Node-RED[314]: You should set your own key using the 'credentialSecret' option in
Jan 18 09:56:39 raspberrypi Node-RED[314]: your settings file. Node-RED will then re-encrypt your credentials
Jan 18 09:56:39 raspberrypi Node-RED[314]: file using your chosen key the next time you deploy a change.
Jan 18 09:56:39 raspberrypi Node-RED[314]: ---------------------------------------------------------------------
Jan 18 09:56:39 raspberrypi Node-RED[314]: 18 Jan 09:56:39 - [info] Starting flows
Jan 18 09:56:39 raspberrypi Node-RED[314]: 18 Jan 09:56:39 - [warn] [scan ble:2905abd3.fa5084] Unable to start BLE scan. Adapter state: unknown
Jan 18 09:56:39 raspberrypi Node-RED[314]: 18 Jan 09:56:39 - [info] Started flows
Jan 18 09:56:39 raspberrypi Node-RED[314]: 18 Jan 09:56:39 - [info] [scan ble:2905abd3.fa5084] Scanning for BLEs started. UUIDs:  - Duplicates allowed: false
Jan 18 09:56:40 raspberrypi Node-RED[314]: 18 Jan 09:56:40 - [info] [mqtt-broker:bcb91c28.92549] Connected to broker: mqtt://192.168.1.112:1883
pi@raspberrypi:~ $ hcitool dev
Devices:
        hci0    B8:27:EB:30:32:59
pi@raspberrypi:~ $

How to check what’s wrong?

On a quick glance the issue might be
Jan 18 09:56:39 raspberrypi Node-RED[314]: 18 Jan 09:56:39 - [info] [scan ble:2905abd3.fa5084] Scanning for BLEs started. UUIDs: - Duplicates allowed: false

You should allow duplicates, otherwise you’ll receive one transmission per mac address

I was able to get it to work.

What I have to do is:
pi@raspberrypi:~ $ sudo hciconfig hci0 down
pi@raspberrypi:~ $ sudo hciconfig hci0 up

Then stop flow in Node-RED and re-deploy. Why is that? And can I automate these commands somehow?

You get fed-up with the constantly struggle with hci0 restarts. One of the reason i gave up and now only use gateways (with watchdog ) and mqtt back to node red

I can’t get * scan ble node working at node red!?

There are some issues with Noble on NodeJS 10, you could try using NodeJS 8 with NVM

Sain toimimaan mutta nyt ruuvitag node asennus epäonnistuu, kun annan tämän
npm link node-red-contrib-ruuvitag
tulee tällainen
12 verbose cwd /home/pi/node-red
13 verbose Linux 4.14.79-v7+
14 verbose argv “/home/pi/.nvm/versions/node/v8.15.0/bin/node” “/home/pi/.nvm/ve rsions/node/v8.15.0/bin/npm” “link” “node-red-contrib-ruuvitag”
15 verbose node v8.15.0
16 verbose npm v6.4.1
17 error code E404
18 error 404 Not Found: node-red-contrib-ruuvitag@latest

It’s been a while since I took a view at the Ruuvi’s node, and the installation could be simplified by adding the node to npm repository (as far as I know).

I can’t promise any specific date, but I’ll take a look at the node at some point in near future to see if it could be made simpler to use

Hi Otso,
I have purchased 3 RuuviTags to connect them to my home automation. I don’t get the Noble node working. So that I can use them in Node-red, the heart of my Project. You wrote that there are problems with NodeJS10. Is there a prospect of a solution? Otherwise I would better return the RuuviTags.
Thanks for your answer, Rob

Hello,

I use NVM to run NodeJS8

Hy all,

just struggeling to get node-red-contrib-noble on Raspian Stretch lite. Current version of nodeJs (11.xx) seems to cause some trouble with the Bluetooth-hci-stack.

After installing the full raspian installation things went smoothly. It contains nodeJS 8.xx, which makes no trouble.

Just in case somebody has the same issues…

Best regards,
Eckehard

Following code can be used in a nodeRed function node to convert raw data directly:

var data={};
var buf = msg.advertisement.manufacturerData;
data.payload={};
data.payload.batt = buf.readUInt16BE(14)/1000.0+" V";
data.payload.temp = buf.readInt8(4)+buf.readUInt8(5)/100.0;
data.payload.hum = buf.readInt8(3)/2.0;
data.payload.accX = buf.readInt16BE(8)/1000.0;
data.payload.accY = buf.readInt16BE(10)/1000.0;
data.payload.accZ = buf.readInt16BE(12)/1000.0;
data.payload.press = buf.readUInt16BE(6)+50000+" Pa";
return data;

1 Like

Hi @etatto, I realize this is a really old post but could you explain why you do the start/stop nodes with the delay?

Hello Chuck and welcome, it just so that the Bluetooth are not constantly scanning. In this case its used for temperature reading, it do not change that fast. For constant reading of acceleration you would have to change that part.

PT

I get node-red to listen ruuvitag but only one, two other’s messages are not coming?

this is what comes to yggönen from debug nodes
{“payload”:{“peripheralUuid”:“d6198fe1e407”},“peripheralUuid”:“d6198fe1e407”,“detectedAt”:1576592794405,“detectedBy”:“raspberrypi”,“advertisement”:{“manufacturerData”:[153,4,3,76,21,52,195,143,0,3,255,249,3,228,10,195,0,0,0,0],“serviceData”:[],“serviceUuids”:[],“solicitationServiceUuids”:[],“serviceSolicitationUuids”:[]},“rssi”:-78,"_msgid":“2df84c33.4a1694”}
{“payload”:{“peripheralUuid”:“d6198fe1e407”},“peripheralUuid”:“d6198fe1e407”,“detectedAt”:1576592794405,“detectedBy”:“raspberrypi”,“advertisement”:{“manufacturerData”:[153,4,3,76,21,52,195,143,0,3,255,249,3,228,10,195,0,0,0,0],“serviceData”:[],“serviceUuids”:[],“solicitationServiceUuids”:[],“serviceSolicitationUuids”:[]},“rssi”:-78,"_msgid":“2df84c33.4a1694”}
{“payload”:"{“humidity”:38,“temperature”:21.52,“pressure”:100063,“accelerationX”:3,“accelerationY”:-7,“accelerationZ”:996,“battery”:2755,“mac”:“d6:19:8f:e1:e4:07”}",“peripheralUuid”:“d6198fe1e407”,“detectedAt”:1576592794405,“detectedBy”:“raspberrypi”,“advertisement”:{“manufacturerData”:[153,4,3,76,21,52,195,143,0,3,255,249,3,228,10,195,0,0,0,0],“serviceData”:[],“serviceUuids”:[],“solicitationServiceUuids”:[],“serviceSolicitationUuids”:[]},“rssi”:-78,"_msgid":“2df84c33.4a1694”}

This comes to gakkonen ja golmomen
{“payload”:{“peripheralUuid”:“dea76aa9e0db”},“peripheralUuid”:“dea76aa9e0db”,“detectedAt”:1576592794543,“detectedBy”:“raspberrypi”,“advertisement”:{“serviceData”:[{“uuid”:“feaa”,“data”:[16,249,3,114,117,117,46,118,105,47,35,66,69,103,87,65,77,79,48,45]}],“serviceUuids”:[“feaa”],“solicitationServiceUuids”:[],“serviceSolicitationUuids”:[]},“rssi”:-70,"_msgid":“78e5ce8c.57f7d”}
{“payload”:{“peripheralUuid”:“dea76aa9e0db”},“peripheralUuid”:“dea76aa9e0db”,“detectedAt”:1576592794543,“detectedBy”:“raspberrypi”,“advertisement”:{“serviceData”:[{“uuid”:“feaa”,“data”:[16,249,3,114,117,117,46,118,105,47,35,66,69,103,87,65,77,79,48,45]}],“serviceUuids”:[“feaa”],“solicitationServiceUuids”:[],“serviceSolicitationUuids”:[]},“rssi”:-70,"_msgid":“78e5ce8c.57f7d”}

{“payload”:{“peripheralUuid”:“e49b6a545510”},“peripheralUuid”:“e49b6a545510”,“detectedAt”:1576592794743,“detectedBy”:“raspberrypi”,“advertisement”:{“serviceData”:[{“uuid”:“feaa”,“data”:[16,249,3,114,117,117,46,118,105,47,35,66,70,65,86,65,77,79,48,115]}],“serviceUuids”:[“feaa”],“solicitationServiceUuids”:[],“serviceSolicitationUuids”:[]},“rssi”:-93,"_msgid":“4ced1da9.e67ba4”}
{“payload”:{“peripheralUuid”:“e49b6a545510”},“peripheralUuid”:“e49b6a545510”,“detectedAt”:1576592794743,“detectedBy”:“raspberrypi”,“advertisement”:{“serviceData”:[{“uuid”:“feaa”,“data”:[16,249,3,114,117,117,46,118,105,47,35,66,70,65,86,65,77,79,48,115]}],“serviceUuids”:[“feaa”],“solicitationServiceUuids”:[],“serviceSolicitationUuids”:[]},“rssi”:-93,"_msgid":“4ced1da9.e67ba4”}

here is my flow
[{“id”:“bcb1742c.d83488”,“type”:“tab”,“label”:“Flow 2”,“disabled”:false,“info”:""},{“id”:“924833ca.768”,“type”:“inject”,“z”:“bcb1742c.d83488”,“name”:“Start BLE scan every 10min”,“topic”:“startBLEScan”,“payload”:"{ “scan”: true }",“payloadType”:“json”,“repeat”:“4”,“crontab”:"",“once”:true,“onceDelay”:"",“x”:160,“y”:60,“wires”:[[“2f71398a.a49b16”]]},{“id”:“2f71398a.a49b16”,“type”:“scan ble”,“z”:“bcb1742c.d83488”,“uuids”:"",“duplicates”:false,“name”:"",“x”:310,“y”:160,“wires”:[[“b1b6e24c.b6ac”,“4c1bd6cc.053b58”]]},{“id”:“c25964fe.fe06e8”,“type”:“ruuvitag”,“z”:“bcb1742c.d83488”,“name”:"",“x”:620,“y”:200,“wires”:[[“541f6382.34bbbc”]]},{“id”:“38b0c5ab.f92c2a”,“type”:“inject”,“z”:“bcb1742c.d83488”,“name”:“Stop BLE scan every 10min”,“topic”:“stopBLEScan”,“payload”:"{ “scan”: false }",“payloadType”:“json”,“repeat”:“60”,“crontab”:"",“once”:true,“onceDelay”:"",“x”:160,“y”:320,“wires”:[[“f8e4b571.0b9f28”]]},{“id”:“f8e4b571.0b9f28”,“type”:“delay”,“z”:“bcb1742c.d83488”,“name”:"",“pauseType”:“delay”,“timeout”:“10”,“timeoutUnits”:“seconds”,“rate”:“1”,“nbRateUnits”:“1”,“rateUnits”:“second”,“randomFirst”:“1”,“randomLast”:“5”,“randomUnits”:“seconds”,“drop”:false,“x”:180,“y”:240,“wires”:[[“2f71398a.a49b16”]]},{“id”:“d41daaa8.8a8048”,“type”:“function”,“z”:“bcb1742c.d83488”,“name”:“Generate MQTT topic”,“func”:“var device = null;\n if (msg.peripheralUuid == “aaaaaaaaaaaa”) {\n device = “bedroom1”;\n} else if (msg.peripheralUuid == “bbbbbbbbbbbb”) { \n device = “livingroom”;\n} else if (msg.peripheralUuid == “cccccccccccc”) { \n device = “kitchen”;\n} else if (msg.peripheralUuid == “dddddddddddd”) { \n device = “bathroom”;\n} else if (msg.peripheralUuid == “eeeeeeeeeeee”) { \n device = “bedroom2”;\n} else if (msg.peripheralUuid == “ffffffffffff”) {\n device = “bedroom3”;\n}\nmsg.topic = device + “/measurements”;\nreturn msg;”,“outputs”:1,“noerr”:0,“x”:460,“y”:400,“wires”:[[“d19257fb.052a78”]]},{“id”:“d19257fb.052a78”,“type”:“mqtt out”,“z”:“bcb1742c.d83488”,“name”:"",“topic”:"",“qos”:"",“retain”:"",“broker”:“79d37982.b8c488”,“x”:650,“y”:400,“wires”:[]},{“id”:“da4e9308.5a60b”,“type”:“inject”,“z”:“bcb1742c.d83488”,“name”:"",“topic”:"",“payload”:"{ “scan”: true }",“payloadType”:“json”,“repeat”:"",“crontab”:"",“once”:false,“onceDelay”:0.1,“x”:110,“y”:160,“wires”:[[]]},{“id”:“b1b6e24c.b6ac”,“type”:“debug”,“z”:“bcb1742c.d83488”,“name”:“Raaka”,“active”:false,“tosidebar”:true,“console”:false,“tostatus”:false,“complete”:“true”,“targetType”:“full”,“x”:450,“y”:80,“wires”:[]},{“id”:“4c1bd6cc.053b58”,“type”:“switch”,“z”:“bcb1742c.d83488”,“name”:"",“property”:“payload.peripheralUuid”,“propertyType”:“msg”,“rules”:[{“t”:“eq”,“v”:“d6198fe1e407”,“vt”:“str”},{“t”:“eq”,“v”:“dea76aa9e0db”,“vt”:“str”},{“t”:“eq”,“v”:“e49b6a545510”,“vt”:“str”}],“checkall”:“true”,“repair”:false,“outputs”:3,“x”:490,“y”:140,“wires”:[[“4697ffb5.f0ec9”,“289d25b9.f99dfa”],[“56a24d42.903c74”,“6555ecb4.3a6ed4”],[“541f6382.34bbbc”,“c25964fe.fe06e8”]]},{“id”:“4697ffb5.f0ec9”,“type”:“debug”,“z”:“bcb1742c.d83488”,“name”:“Yggönen”,“active”:false,“tosidebar”:true,“console”:false,“tostatus”:false,“complete”:“true”,“targetType”:“full”,“x”:780,“y”:60,“wires”:[]},{“id”:“56a24d42.903c74”,“type”:“debug”,“z”:“bcb1742c.d83488”,“name”:“Golmonen”,“active”:false,“tosidebar”:true,“console”:false,“tostatus”:false,“complete”:“true”,“targetType”:“full”,“x”:850,“y”:120,“wires”:[]},{“id”:“541f6382.34bbbc”,“type”:“debug”,“z”:“bcb1742c.d83488”,“name”:“Gakkonen”,“active”:false,“tosidebar”:true,“console”:false,“tostatus”:false,“complete”:“true”,“targetType”:“full”,“x”:810,“y”:180,“wires”:[]},{“id”:“6555ecb4.3a6ed4”,“type”:“ruuvitag”,“z”:“bcb1742c.d83488”,“name”:"",“x”:640,“y”:100,“wires”:[[“56a24d42.903c74”]]},{“id”:“289d25b9.f99dfa”,“type”:“ruuvitag”,“z”:“bcb1742c.d83488”,“name”:"",“x”:620,“y”:40,“wires”:[[“4697ffb5.f0ec9”]]},{“id”:“78d61105.06c44”,“type”:“debug”,“z”:“bcb1742c.d83488”,“name”:“Ruuvi”,“active”:false,“tosidebar”:true,“console”:false,“tostatus”:false,“complete”:“payload”,“targetType”:“msg”,“x”:590,“y”:300,“wires”:[]},{“id”:“79d37982.b8c488”,“type”:“mqtt-broker”,“z”:"",“broker”:“localhost”,“port”:“1883”,“clientid”:"",“usetls”:false,“compatmode”:false,“keepalive”:“60”,“cleansession”:true,“birthTopic”:"",“birthQos”:“0”,“birthPayload”:"",“willTopic”:"",“willQos”:“0”,“willPayload”:""}]

Caught my eye, Maybe you’re running RuuviTags in URL mode? Try pressing button B until red led blinks on RuuviTag, or updating firmware to 2.5.9 as instructed in lab.ruuvi.com/dfu

Hi
I found this guide today, planning to try it later, nice and concise way to set up.

Hi,

just updated one of my ruuvi tags to 2.5.9 and I’m getting very weird values for temperature:

sometimes +100 sometimes -100.

batt: "5.313 V"
temp: -125.29
hum: 8.5
accX: 29.184
accY: 0
accZ: 8.196
press: "76553 Pa"

I’m using the following code on node red. Values arrive via mqtt from espruino hub, before the update it was fine:

var data={};
var buf = Buffer.from(msg.payload.manufacturerData,'hex');
data.payload={};
data.payload.batt = buf.readUInt16BE(14)/1000.0+" V";
data.payload.temp = buf.readInt8(4)+buf.readUInt8(5)/100.0;
data.payload.hum = buf.readInt8(3)/2.0;
data.payload.accX = buf.readInt16BE(8)/1000.0;
data.payload.accY = buf.readInt16BE(10)/1000.0;
data.payload.accZ = buf.readInt16BE(12)/1000.0;
data.payload.press = buf.readUInt16BE(6)+50000+" Pa";
return data;

Something changed for 2.5.9 to decode the values?

Regards

Stefan

Hello Stefan,

2.5.9 sends in RAWv2 format by default which has some new features that aren’t compatible with the previous version. You can press the button “B” twice to enter the previous data format, red led is blinking when you’re in the RAWv1 format.

If you want to get the new features, feel free to use this code in your parser: https://github.com/ojousima/node-red/blob/master/ruuvi-node/ruuvitag.js

1 Like

Hi, I am having the same issue. The best hint I found so far is https://github.com/nodejs/help/issues/1051#issuecomment-354811768 but I do not intend to change those settings.

Did you eventually came across a solution?