Node-RED Node

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?

Hi, for all of you having issues with the node-red-contrib-noble under Node 10,12,13 use this version:

2 Likes

Hi, I did the setup on a RPI3B+ running the latest Raspian following the instructions on https://github.com/ojousima/node-red.

The problem I came across was that after some days no more values were received and the Node-Red logs showed messages like Unable to start BLE scan. Adapter state: unknown.

The simple “fix” that worked for me was to create a bash script that does basically nothing else than execute the command
node-red-restart
once a day via crontab. Haven’t had issues after so far. So wanted to share this as it may be helpful for some of you.

I will put this here, because I had to reinstall Raspbian and struggled with this again.
This worked for me:

sudo setcap cap_net_raw,cap_net_admin+eip $(eval readlink -f `which node`)
sudo systemctl restart nodered

Hey!

Anyone having a problem with scan-loop working for a while and then just stops at “Started” state.

My flow looks like this:

It works flawlessly for usually few hours or might even go further but then always at some point the loop gets stuck on “Started” and never changes to stopped. Even if I try to inject the node myself from the inject-node button, it doesnt change.

Here’s my flow, has been running for years.

edit:
try this one is zipped.

flows.json.zip (1.0 KB)

Thanks for sharing but this flow seems to be faulty somehow. Cannot import to node-red for some reason! :smiley:

Hey! Thanks for the zip. This one can be imported without problems.

However, it also gets stuck the same way as my previous… So it seems like the problem is maybe in the Scan Ble node or some other part of the system.

What version of contrib-noble are you using on your working system?

My setup on pi zero w.
setup.zip (394 Bytes)

Hi, I have a same kind of problem. It does not stop suddenly, but it won’t start after reboot or restart. It stay “Started” state after reboot and start working only after redeploy the flow. Have you got fixed your system?

Hey! I didnt get it working even tho trying lots of things. I think the Scan BLE node is broken somehow in newer systems. It seems to be updated 4 years ago so I think it is not in the best shape.
I dumped the whole node-thingy and just made my own Python script for reading the data.