[monitor] Reliable, Multi-User, Distributed Bluetooth Occupancy/Presence Detection

The developer made a lot of effort to program it in such a way that the wifi interference is reduced drastically for such kind of an application

1 Like

This is an awesome project, but unfortunately doesnā€™t work for me. For whatever reason, it creates a ton of interference like an older Bluetooth tracker project did with Raspberry Pi Zero Wā€™s. Its mostly noticeable on my Harmony remote hubs. Using the basic remote control they give you, anything that is IP controlled is extremely laggy. For example, watching Roku, navigation gets delayed by a few seconds at a time. If I shutdown the RPi running this script (which is in the basement directly below the area Iā€™m in), response time immediately gets better. Previously, I had one RPi in my detached garage and had similar degraded performance for two Ring cameras located out there. There is really no other good setup for this in my house to make this work and avoid the interference. I really do appreciate the hard work put into this project though.

EDIT: Just for clarification, I loaded a fresh version of Raspian Lite and installed this script per the instructions provided on the GitHub page. I placed it at least 15 feet from any wifi device too, facing out toward my driveway. Running an Ubiquiti EdgeRouter4 with 3 different UAPā€™s (1 on each of the house and 1 in the garage).

1 Like

im using a onePlus 3 and my phone has worked with this project without having to pair anything

really? I have a harmony hub and I am currently using 2 Piā€™s and my remote seems to work just fine.

What settings are you using? Maybe there are too many bluetooth advertisements around you. I things @andrewjfreyer added a way to blacklist some macs that may be in your environment that do not need to be detected.

Basically default settings other than MQTT server and a few phones in the known devices file. I had the same exact issue before with another python script that did the same thing (not nearly as involved though). I can ā€˜sudo systemctl stop monitorā€™ and see my responsiveness come back immediately on my Harmony. I have another that is within eye sight (downstairs, fairly close to the RPi) and when I run monitor (or equivalent), I can even see the light going green to red to green etc. as if its losing wifi temporarily. I have a lot of Google Homes, 3 phones (1 per person), and some laptops and tablets. I wouldnā€™t say Iā€™m an out of ordinary use case. I live in a single family home on 1/2 acre in a somewhat private street. House was built in the 60ā€™s, so older, but no metal walls or anything crazy. My Unifi wifi is all upstairs away from the RPiā€™s as well. Its very reproducible in my house, but could be related to the environment.

This thread (yes it is long!) has a number of other people saying the wifi interference is a real problem, others say not so much. It is hard to discern any pattern, but I havenā€™t paid as much attention as some others have. A read of the whole thread might prove useful. Itā€™s a bit of a slog though.

Is there anything you think that could be making a difference? Could it be the rpi zero malfunctioning? Mine on default settings doesnā€™t seem to catch any random advertisementsā€¦

Has anyone just for the test tried other hardware? Rpi3 or something. Perhaps the chip on pi zero is low quality, it is a very low priced device

yep I tried an RPI3, on wifi 2.4g network dies, change to LAN, it is back. I have the same problem is using hassio on a rpi3 and BT trackerā€¦ so it isnā€™t just Monitor that causes this issue

1 Like

No this is a hardware problem. Would be interesting if someone could test with another brand SBC

@yuran, @markRā€™s answer is correct - this is not an issue limited to monitor, or to any particular Bluetooth hardware. The spectrum used by 2.4Ghz Wi-Fi overlaps the spectrum used by Bluetooth v2.1. As a result, Bluetooth interferes with 2.4GHz Wi-Fi and vice versa. We notice Wi-Fi slowdowns because the data rate of Wi-Fi is substantially higher, meaning Wi-Fiā€™s tolerance to noise is much lower.

The interference caused by monitor, presence, and other similar scripts (like BT Tracker) is related to repeated Bluetooth name requests. These special requests do not require pairing, which is a huge advantage for these scripts. But, this ā€œfeatureā€ also means that a specified channel of communication (i.e., a specific allocation of 2.4GHz spectrum) is not previously negotiated between the Bluetooth hardware making the request and the target of the request. As a result, the hardware making the request has to iteratively scan different channels. In short, name requests take a large bandwidth.


TL;DR - Bluetooth interference will be caused by any bluetooth hardware because bluetooth and Wi-Fi spectrum overlap. To entirely mitigate the interference issue, reduce the frequency of name scans or switch to 5GHz Wi-Fi. Switching bluetooth hardware will not make a difference.

1 Like

Pity pi 0 only comes with 2.4 ghz

This could be a solution

Nice reply Andrew thanks. This is exactly the reason why I am buying another 5 port hub to cable a RPi3 and zero instead of wifi, so I can use the BT tracker, then use eventstream to the main HA host.

This way I can trigger Monitor to do arrival scansā€¦ I hope :smiley:

I did see much more interference running bluetooth tracker than I ever saw with Monitor alone, just a pity my phones donā€™t appear to advertiseā€¦ (I know old ground) :slight_smile:

2 Likes

be interested to hear your results. I have a spare Pi3 now I have moved over to Docker, so might have a play around with that wired instead of the two ZeroWā€™s I have at the moment.

I just had a wired mini usb dongle arrive for a pi zero as well. I have BT on the NUC passed through to the HA in a docker, which works perfectly as wellā€¦ until it just stops after an few hoursā€¦ might be Linux Mint, so need to investigate that as wellā€¦ this never ends :slight_smile:

I am thinking of tracking my Garmin smart watchā€™s BT for presence detection instead of relying on my phone. Should this approach work with monitor or is monitor only meant for iOS/Android/Beacon devices?

I am currently using monitor with an iPhone X and a Sony Android which is working well for both but I prefer using a watch since it is always on me while the phone might not.

1 Like

Should work fine if Garmin hasnā€™t done anything strange with their bluetooth implementation.

I will give it a shot then, thanks @andrewjfreyer

with your depart script, how are you calling it please?

and how are you cancelling the depart script before it runs? :slight_smile:
can you post the action of the automation?

Cheers
Mark