Use Bluetooth to scan for devices as a presence detector?

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!

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

1 Like

I have assigedn fix IP adresses to all my mobile phones. Than I'm using the PING node 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 :wink:

3 Likes

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

1 Like

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.

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.

1 Like

In my case, after unsuccessfully trying the BLE and the ping method, I discovered 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.

2 Likes


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.

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

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

1 Like

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

Craig

1 Like

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

If you have a Fritzbox, take a look at this node.
There's a sample for presence detection, this works fine for me without switching on the wifi all time on my phones.

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

thanks in advance

1 Like

This projct is based on ESPhome and also works well

And here is the Tasmota ESP32 Build

http://ota.tasmota.com/tasmota32/release/tasmota32-bluetooth.bin

Craig

2 Likes

Thats my next rainy weekend project :wink:

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

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:


MQTT reports are empty too.

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?

1 Like

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 ?

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

1 Like