# Use Bluetooth to scan for devices as a presence detector?

**URL:** <https://discourse.nodered.org/t/use-bluetooth-to-scan-for-devices-as-a-presence-detector/52379>\
**Category:** General\
**Created:** [18 October 2021 20:52 UTC](https://discourse.nodered.org/t/use-bluetooth-to-scan-for-devices-as-a-presence-detector/52379 "2021-10-18T20:52:17Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![WhiteLion](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/whitelion/32/12266_2.png) [@WhiteLion](https://discourse.nodered.org/u/WhiteLion)\
**Post date:** [18 October 2021 20:52 UTC](https://discourse.nodered.org/t/use-bluetooth-to-scan-for-devices-as-a-presence-detector/52379/1 "2021-10-18T20:52:17Z")

</div>

Hiho,  
currently I am scanning the MAC addresses of my WiFi for devices (mobile phone)  
as a presence detection. This does not work fast enough and I wanted to try the kind of same thing with the Bluetooth scan. I ve NR running on a Raspberry Pi 4. But could not find a way to scan permanently for BT devices. Is there a way to do that ? Do I ve to pair the mobile phones with Raspberry BT or can they be detected if just BT is switched on?  
Thx!

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [18 October 2021 23:37 UTC](https://discourse.nodered.org/t/use-bluetooth-to-scan-for-devices-as-a-presence-detector/52379/2 "2021-10-18T23:37:02Z")

</div>

There are a few threads in the forum. Search **Bluetooth scan** - might give you some clues.

---

<div class="post-metadata">

**Author:** ![xx\_Nexus\_xx](https://avatars.discourse-cdn.com/v4/letter/x/54ee81/32.png) [@xx\_Nexus\_xx](https://discourse.nodered.org/u/xx_Nexus_xx)\
**Post date:** [19 October 2021 00:01 UTC](https://discourse.nodered.org/t/use-bluetooth-to-scan-for-devices-as-a-presence-detector/52379/3 "2021-10-19T00:01:04Z")

</div>

I have assigedn fix IP adresses to all my mobile phones. Than I'm using the [PING node](https://flows.nodered.org/node/node-red-node-ping) to check for the presence of the phone.

I tried the bluetooth approach erlier but have better experience with PING as WIFI is always on on the mobile phones 😉

---

<div class="post-metadata">

**Author:** ![edje11](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/edje11/32/572_2.png) [@edje11](https://discourse.nodered.org/u/edje11)\
**Post date:** [19 October 2021 08:26 UTC](https://discourse.nodered.org/t/use-bluetooth-to-scan-for-devices-as-a-presence-detector/52379/4 "2021-10-19T08:26:34Z")

</div>

> [@xx\_Nexus\_xx](#):
>
> as WIFI is always on on the mobile phone

Nop, modern phones will switch wifi off to preserve energy.  
Waking up ones in x minutes to check mail, whatsapp etc.  
So you will see that pings will give most of the time false

---

<div class="post-metadata">

**Author:** ![WhiteLion](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/whitelion/32/12266_2.png) [@WhiteLion](https://discourse.nodered.org/u/WhiteLion)\
**Post date:** [19 October 2021 08:58 UTC](https://discourse.nodered.org/t/use-bluetooth-to-scan-for-devices-as-a-presence-detector/52379/5 "2021-10-19T08:58:58Z")

</div>

Like written above I have a similar solution running and the problem is exactly what @edje11 said.  
All the Bluetooth based solutions I found by search where very hacky and some of them does not work on a raspy 4 or at all. Yesterday I even had to recover from backup because the node looked like a solution - if it would have worked. The working BLE beacon nodes I found wants fixed config bound devices instead of offering a scanner an look for my BT id.... But I am not so much into that to understand if there are reasons the scanner is not available as a node giving back BT ids of devices around.

---

<div class="post-metadata">

**Author:** ![davidz](https://avatars.discourse-cdn.com/v4/letter/d/a88e57/32.png) [@davidz](https://discourse.nodered.org/u/davidz)\
**Post date:** [19 October 2021 16:56 UTC](https://discourse.nodered.org/t/use-bluetooth-to-scan-for-devices-as-a-presence-detector/52379/6 "2021-10-19T16:56:33Z")

</div>

It is absolutely doable to let the BLE scan permanently with a dedicated BLE chip from some popular BLE providers such as Silicon Labs, Nordic Semi, TI or ST etc.

The BLE functions from RPI or ESP series are far from ideal. But it might be possible let them scan permanently too.

For reliable applications, I would recommend to use a dedicated BLE chip.

---

<div class="post-metadata">

**Author:** ![juanbal](https://avatars.discourse-cdn.com/v4/letter/j/e480ec/32.png) [@juanbal](https://discourse.nodered.org/u/juanbal)\
**Post date:** [19 October 2021 21:16 UTC](https://discourse.nodered.org/t/use-bluetooth-to-scan-for-devices-as-a-presence-detector/52379/7 "2021-10-19T21:16:03Z")

</div>

In my case, after unsuccessfully trying the BLE and the ping method, I discovered **[owrtwifi2mqtt](https://github.com/dersimn/owrtwifi2mqtt)**  
This is a simple script that runs on an openwrt router and publishes in MQTT the list of wifi connected devices.  
As long as your mobile connects to your wifi automatically when you enter home this will work.  
The only requirement is that you need a router running linux where you can install this.

---

<div class="post-metadata">

**Author:** ![WhiteLion](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/whitelion/32/12266_2.png) [@WhiteLion](https://discourse.nodered.org/u/WhiteLion)\
**Post date:** [19 October 2021 22:22 UTC](https://discourse.nodered.org/t/use-bluetooth-to-scan-for-devices-as-a-presence-detector/52379/8 "2021-10-19T22:22:56Z")

</div>

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/5/a53efbbfdd314a5fc2c8233b3bb0a79139563949.png)  
I ve done this myself using mac addresses and scanning ARP request. But I would like to test if the delay of logging into my wlan, when entering home is gone when using bluetooth a scanner , scanning for mobile devices.

---

<div class="post-metadata">

**Author:** ![xx\_Nexus\_xx](https://avatars.discourse-cdn.com/v4/letter/x/54ee81/32.png) [@xx\_Nexus\_xx](https://discourse.nodered.org/u/xx_Nexus_xx)\
**Post date:** [20 October 2021 00:17 UTC](https://discourse.nodered.org/t/use-bluetooth-to-scan-for-devices-as-a-presence-detector/52379/9 "2021-10-20T00:17:48Z")

</div>

Sorry, I should have said that my phones are set to always on 😉 .. due to the need of the presence detection.

For me it works better as any of the bluetooth solutions I tried

---

<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:** [20 October 2021 01:39 UTC](https://discourse.nodered.org/t/use-bluetooth-to-scan-for-devices-as-a-presence-detector/52379/10 "2021-10-20T01:39:17Z")

</div>

Have a look at Tasmota on ESP32 devices - this supports bluetooth presence detection and reports all the devices it finds via MQTT

Craig

---

<div class="post-metadata">

**Author:** ![WhiteLion](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/whitelion/32/12266_2.png) [@WhiteLion](https://discourse.nodered.org/u/WhiteLion)\
**Post date:** [20 October 2021 08:36 UTC](https://discourse.nodered.org/t/use-bluetooth-to-scan-for-devices-as-a-presence-detector/52379/11 "2021-10-20T08:36:35Z")

</div>

I should try that out. I hoped that I came around using another ESP in my household when the raspi´s bluetooth is unused 🙂 but who cares if there are 28 ESPs running or 29 ...

---

<div class="post-metadata">

**Author:** ![edje11](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/edje11/32/572_2.png) [@edje11](https://discourse.nodered.org/u/edje11)\
**Post date:** [20 October 2021 10:00 UTC](https://discourse.nodered.org/t/use-bluetooth-to-scan-for-devices-as-a-presence-detector/52379/12 "2021-10-20T10:00:37Z")

</div>

If you have a Fritzbox, take a look at this [node](https://flows.nodered.org/node/node-red-contrib-fritz).  
There's a sample for presence detection, this works fine for me without switching on the wifi all time on my phones.

---

<div class="post-metadata">

**Author:** ![xx\_Nexus\_xx](https://avatars.discourse-cdn.com/v4/letter/x/54ee81/32.png) [@xx\_Nexus\_xx](https://discourse.nodered.org/u/xx_Nexus_xx)\
**Post date:** [21 October 2021 01:12 UTC](https://discourse.nodered.org/t/use-bluetooth-to-scan-for-devices-as-a-presence-detector/52379/13 "2021-10-21T01:12:00Z")

</div>

Can you point me to the Tasmota project you have in mind? there are so many .. lol

thanks in advance

---

<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:** [21 October 2021 01:41 UTC](https://discourse.nodered.org/t/use-bluetooth-to-scan-for-devices-as-a-presence-detector/52379/14 "2021-10-21T01:41:08Z")

</div>

This projct is based on ESPhome and also works well

> **[ESP32 Bluetooth Low Energy Tracker Hub](https://esphome.io/components/esp32_ble_tracker.html)**
>
> Instructions for setting up ESP32 bluetooth low energy device trackers using ESPHome.

And here is the Tasmota ESP32 Build

[http://ota.tasmota.com/tasmota32/release/tasmota32-bluetooth.bin](http://ota.tasmota.com/tasmota32/release/tasmota32-bluetooth.bin)

Craig

---

<div class="post-metadata">

**Author:** ![xx\_Nexus\_xx](https://avatars.discourse-cdn.com/v4/letter/x/54ee81/32.png) [@xx\_Nexus\_xx](https://discourse.nodered.org/u/xx_Nexus_xx)\
**Post date:** [21 October 2021 02:17 UTC](https://discourse.nodered.org/t/use-bluetooth-to-scan-for-devices-as-a-presence-detector/52379/15 "2021-10-21T02:17:40Z")

</div>

Thats my next rainy weekend project 😉

---

<div class="post-metadata">

**Author:** ![krambriw](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/krambriw/32/5429_2.png) [@krambriw](https://discourse.nodered.org/u/krambriw)\
**Post date:** [21 October 2021 06:34 UTC](https://discourse.nodered.org/t/use-bluetooth-to-scan-for-devices-as-a-presence-detector/52379/16 "2021-10-21T06:34:25Z")

</div>

Might do for detecting beacons but forget if you are looking for detecting phones. You need a different method to detect them, 'name' queries triggered after receiving an anonymous advertisement

I'm since years using the solution provided by Andrew, it is working excellent detecting my iPhone succesfully and I use this as a presence detection system when I'm arriving or leaving home, see link below where you can read up. I'm running it on a RPi3 with an external BT dongle

> **[GitHub - andrewjfreyer/monitor: Distributed advertisement-based BTLE presence...](https://github.com/andrewjfreyer/monitor)**
>
> Distributed advertisement-based BTLE presence detection reported via mqtt - GitHub - andrewjfreyer/monitor: Distributed advertisement-based BTLE presence detection reported via mqtt

 ![Skärmavbild 2021-10-21 kl. 08.32.30](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/3/43c75afcc797ba15850d653020925a83da92aca1.jpeg)

---

<div class="post-metadata">

**Author:** ![WhiteLion](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/whitelion/32/12266_2.png) [@WhiteLion](https://discourse.nodered.org/u/WhiteLion)\
**Post date:** [21 October 2021 12:29 UTC](https://discourse.nodered.org/t/use-bluetooth-to-scan-for-devices-as-a-presence-detector/52379/17 "2021-10-21T12:29:37Z")

</div>

thanx. this looks good... I ve tried this but have some trouble getting it to work.  
There is simply no result when scanning ist running:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/9/49f66f407536d8885eb0538f353db4883ef23916.png)  
MQTT reports are empty too.

---

<div class="post-metadata">

**Author:** ![krambriw](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/krambriw/32/5429_2.png) [@krambriw](https://discourse.nodered.org/u/krambriw)\
**Post date:** [21 October 2021 12:48 UTC](https://discourse.nodered.org/t/use-bluetooth-to-scan-for-devices-as-a-presence-detector/52379/18 "2021-10-21T12:48:19Z")

</div>

Assuming you have followed the instructions to 100%.....

Have you entered the mac of your phone (iPhone or what)? If so, try to turn BT off in your phone and wait a while and see if it is getting detected as away. If that works, now turn it on again

Are you looking for detecting beacons or phones?

---

<div class="post-metadata">

**Author:** ![WhiteLion](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/whitelion/32/12266_2.png) [@WhiteLion](https://discourse.nodered.org/u/WhiteLion)\
**Post date:** [21 October 2021 12:58 UTC](https://discourse.nodered.org/t/use-bluetooth-to-scan-for-devices-as-a-presence-detector/52379/19 "2021-10-21T12:58:19Z")

</div>

ok, sorry I thought scanning works without having the addess putting to "known\_static\_addresses" .... When doing it, it works. Isn´t it possible to scann all devices around like scanning for WiFi SSID s ?

---

<div class="post-metadata">

**Author:** ![krambriw](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/krambriw/32/5429_2.png) [@krambriw](https://discourse.nodered.org/u/krambriw)\
**Post date:** [21 October 2021 13:09 UTC](https://discourse.nodered.org/t/use-bluetooth-to-scan-for-devices-as-a-presence-detector/52379/20 "2021-10-21T13:09:23Z")

</div>

Ask Andrew on github about such things, there are a lot of people asking all kind of questions there  
For me, I am only interested in scanning for specified phones, i.e. belonging to family. I think beacons will be seen if you have enabled scanning for those. Depends what you wanna do

> **[Issues · andrewjfreyer/monitor](https://github.com/andrewjfreyer/monitor/issues)**
>
> Distributed advertisement-based BTLE presence detection reported via mqtt - Issues · andrewjfreyer/monitor

[Next page](https://discourse.nodered.org/t/use-bluetooth-to-scan-for-devices-as-a-presence-detector/52379.md?page=2)
