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

Or you can run it with the Retain flag, so it keeps the settings in the MQTT server for you, so HA will always read them on restart too,

monitor -x  retain mqtt status messages

I just wanted to point out that Google home is able to track rssi values from iPhone.
I was just wondering if we can do something to get rssi working on Monitor as well, that way it can also function as a room-presence detection platform.

I’ve been reading this thread for the past hour now and I’m confused about using mosquitto and multiple rpi-zeros and HA. Do I run mosquitto on each pi-zero as well as the instance I have running on the HA server? Or do I just need the one on the HA server? My HA is running on a rpi3b+ with rasbian and HA in venv. Mosquitto also runs on the same pi.

Another question. Can I run monitor on the HA server as a slave? I have a big house that would need a monitor node at both the front and back of the house. Since my HA pi is at the back of the house I wondered if I could run monitor there as the slave.

One mqtt server.

Yes I can’t see why you can’t run as slave

Thanks for the quick reply/answer.

One more question if I may. What type of range are people seeing with the pi-zero? I know walls and such limit the range but I would like to detect presence when my wife or I pull up to the house.

Maybe a stupid question, but would Monitor create any wifi interference during scans? Is it purely passive? Asking because I used a similar program like this in the past and wifi in the area of my RPiZeroW suffered, although I’m not sure why.

1 Like

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