# Filter Objects from BLE Beacon scanner

**URL:** https://discourse.nodered.org/t/filter-objects-from-ble-beacon-scanner/23149
**Category:** General
**Created:** [15 March 2020 19:11 UTC](https://discourse.nodered.org/t/filter-objects-from-ble-beacon-scanner/23149 "2020-03-15T19:11:49Z")
**Posts on this page:** 12
**Page:** 1

<div class="post-metadata">

### Author: ![MasterOfPuppets](https://avatars.discourse-cdn.com/v4/letter/m/e47c2d/32.png) [@MasterOfPuppets](https://discourse.nodered.org/u/MasterOfPuppets)
#### Post date: [15 March 2020 19:11 UTC](https://discourse.nodered.org/t/filter-objects-from-ble-beacon-scanner/23149/1 "2020-03-15T19:11:49Z")

</div>

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](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/5/45f0e506e6e3b587cd64bbff1a691bec76b73b94.png)

The output gives me many messages from many BLE devices in the debug window around me:  
 ![2020-03-15 19_54_30-Window](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/c/1c01d74aa3d101f1ea3700afe0a8a54b93d8c606.png)

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:

 ![2020-03-15 9_54_30-Window](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/0/70ae19277835d2179565d1f8a863dfa778eec8a9.png)

do you know, how i can do that?

best regards Pierre

---

<div class="post-metadata">

### Author: ![craigcurtin](https://avatars.discourse-cdn.com/v4/letter/c/94ad74/32.png) [@craigcurtin](https://discourse.nodered.org/u/craigcurtin)
#### Post date: [15 March 2020 20:57 UTC](https://discourse.nodered.org/t/filter-objects-from-ble-beacon-scanner/23149/2 "2020-03-15T20:57:51Z")

</div>

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

---

<div class="post-metadata">

### Author: ![MasterOfPuppets](https://avatars.discourse-cdn.com/v4/letter/m/e47c2d/32.png) [@MasterOfPuppets](https://discourse.nodered.org/u/MasterOfPuppets)
#### Post date: [15 March 2020 21:45 UTC](https://discourse.nodered.org/t/filter-objects-from-ble-beacon-scanner/23149/3 "2020-03-15T21:45:45Z")

</div>

Thank you very much craig!

That was easier than i thought =)  
 ![2020-03-15 22_41_56-Window](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/f/2f9b5074f533255209239d2be77d372b181a2f79.png)

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.... 😵

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)

 ![2020-03-15 23_02_43-Windowxxxxxxxxxxxxx](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/0/20400c2d2039032ebeb20ef9b95d7f375cacd703.png)

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

---

<div class="post-metadata">

### Author: ![PeteKnight](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/peteknight/32/18345_2.png) [@PeteKnight](https://discourse.nodered.org/u/PeteKnight)
#### Post date: [16 March 2020 00:04 UTC](https://discourse.nodered.org/t/filter-objects-from-ble-beacon-scanner/23149/4 "2020-03-16T00:04:51Z")

</div>

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

> <https://raspberrypi.stackexchange.com/questions/76959/how-to-decode-tpms-sensor-data-through-rpi3-bluetooth>

Pete.

---

<div class="post-metadata">

### Author: ![MasterOfPuppets](https://avatars.discourse-cdn.com/v4/letter/m/e47c2d/32.png) [@MasterOfPuppets](https://discourse.nodered.org/u/MasterOfPuppets)
#### Post date: [16 March 2020 02:11 UTC](https://discourse.nodered.org/t/filter-objects-from-ble-beacon-scanner/23149/5 "2020-03-16T02:11:37Z")

</div>

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

Pierre

---

<div class="post-metadata">

### Author: ![craigcurtin](https://avatars.discourse-cdn.com/v4/letter/c/94ad74/32.png) [@craigcurtin](https://discourse.nodered.org/u/craigcurtin)
#### Post date: [16 March 2020 05:40 UTC](https://discourse.nodered.org/t/filter-objects-from-ble-beacon-scanner/23149/6 "2020-03-16T05:40:19Z")

</div>

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

---

<div class="post-metadata">

### Author: ![PeteKnight](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/peteknight/32/18345_2.png) [@PeteKnight](https://discourse.nodered.org/u/PeteKnight)
#### Post date: [16 March 2020 08:43 UTC](https://discourse.nodered.org/t/filter-objects-from-ble-beacon-scanner/23149/7 "2020-03-16T08:43:59Z")

</div>

> [@MasterOfPuppets](#):
>
> he is at the same point than me, but without an answer.

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

Pete.

---

<div class="post-metadata">

### Author: ![MasterOfPuppets](https://avatars.discourse-cdn.com/v4/letter/m/e47c2d/32.png) [@MasterOfPuppets](https://discourse.nodered.org/u/MasterOfPuppets)
#### Post date: [16 March 2020 11:57 UTC](https://discourse.nodered.org/t/filter-objects-from-ble-beacon-scanner/23149/8 "2020-03-16T11:57:31Z")

</div>

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

---

<div class="post-metadata">

### Author: ![craigcurtin](https://avatars.discourse-cdn.com/v4/letter/c/94ad74/32.png) [@craigcurtin](https://discourse.nodered.org/u/craigcurtin)
#### Post date: [17 March 2020 00:52 UTC](https://discourse.nodered.org/t/filter-objects-from-ble-beacon-scanner/23149/9 "2020-03-17T00:52:25Z")

</div>

So show us what you have tried so far

---

<div class="post-metadata">

### Author: ![craigcurtin](https://avatars.discourse-cdn.com/v4/letter/c/94ad74/32.png) [@craigcurtin](https://discourse.nodered.org/u/craigcurtin)
#### Post date: [17 March 2020 06:37 UTC](https://discourse.nodered.org/t/filter-objects-from-ble-beacon-scanner/23149/10 "2020-03-17T06:37:27Z")

</div>

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](https://www.includehelp.com/code-snippets/convert-decimal-to-hexadecimal-and-vice-versa-in-javascript.aspx)

---

<div class="post-metadata">

### Author: ![MasterOfPuppets](https://avatars.discourse-cdn.com/v4/letter/m/e47c2d/32.png) [@MasterOfPuppets](https://discourse.nodered.org/u/MasterOfPuppets)
#### Post date: [17 March 2020 23:40 UTC](https://discourse.nodered.org/t/filter-objects-from-ble-beacon-scanner/23149/11 "2020-03-17T23:40:36Z")

</div>

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:

```auto
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):

```auto
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

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [31 March 2020 23:40 UTC](https://discourse.nodered.org/t/filter-objects-from-ble-beacon-scanner/23149/12 "2020-03-31T23:40:45Z")

</div>

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