Filter Objects from BLE Beacon scanner

Hello Guys,

I use Node-Red on a Raspberry Pi 3 and i want to Read out Typrepressure Sensors via BLE.

So i decided to use the node "BLE Bacon Scanner":
2020-03-15 19_53_51-Window

The output gives me many messages from many BLE devices in the debug window around me:
2020-03-15 19_54_30-Window

Now i want to filter out only this object (marked yellow) and ignore all other messages for example with a function or whatever between the scanner and the debug node:

do you know, how i can do that?

best regards Pierre

Have a look at the switch node - it will let you route messages based on properties/values - looks for the Object ID you want and route that to the next stage of your flow

Craig

Thank you very much craig!

That was easier than i thought =)
2020-03-15 22_41_56-Window

now i get the messages only from my two sensors.

The hard part is coming yet.... decode the eighten hex values in decimal kPa and °C.... :dizzy_face:

till yet i know that buffer nr. 12&13 are Temperature in °C (divided by 100) -> for example:
12: 0x41
13: 0xa
= a41 (hex) -> 2625(decimal) -> 26.25°C (divided by 100)

and buffer nr. 8&9 are pressure in kPa (divided by 1000) -> for example:
8: 0xea
9: 0x23
=23ea (hex) -> 9194(decimal) -> 9.194 kPa (divided by 1000)

does anyone know how i can isolate/grab this hex values from the sensor and decode/convert it to display directly °C and kPa for example a gauge?

best regards
Pierre

You might find this helpful, or at least a starting point...

Pete.

Hello Pete, he is at the same point than me, but without an answer....

Pierre

OK So to grab the value - the easiest way is a 2nd switch node based on the property you are interested in - if you highlight the value in the debug window that you are interested in - there is a small popup to the right - this gives you 3 options - the first option lets you capture the full "path" to the object to insert into your switch

Then do a basic function node - and perform the maths as you have listed above - grab the hex value, multiply by 16 to get decimal and divide by 100

Craig

One of the people who responded had made some progress though, and he seemed to have some working code on his GitHub page.

Pete.

Hello Pete, ive seen that, but i have no idea, how to put that in my node-red flow....

@craigcurtin filter out the value ist not the problem, the problem for me is, to set hex value togheter before i convert it to decimal..... =(

how does the funktion look like to put buffer nr. 13 & 12 togehter like this:
13: 0xa and 12:0x41 ---> to: 0xa41?

best regards, Pierre

So show us what you have tried so far

here is a code snippet to give you an idea of how to do this in Js

https://www.includehelp.com/code-snippets/convert-decimal-to-hexadecimal-and-vice-versa-in-javascript.aspx

Thank you all for your perfect help, ich find the right maths for my problem:

to convert the 2 hex bytes in the right decimal value, i use the following formula in a function node:

For temperature in °C:

msg.payload = parseFloat((msg.payload.other[13] * 256 + msg.payload.other[12]) / 100.0).toFixed(1)
return msg;

For pressure in Bar (if u want it in kPa you habe to do only /1000.0):

msg.payload = parseFloat((msg.payload.other[9] * 256 + msg.payload.other[8]) / 100000.0).toFixed(1)
return msg;

thank you all very much!

best regards
Pierre

3 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.