[Monitor] Reliable, Multi-User, Distributed BT Occupancy/Presence Detection

Tags: #<Tag:0x00007f47f8378498> #<Tag:0x00007f47f83782e0>


Im using android 8 and this doesn’t happen to me. Try to turn on discovery mode (even though you shouldnt have to) and see if you start getting the advertisements.


nope nothing at all… tried 2 android 8 phones and spare galaxy s5. Nothing for any of them. Going to install everything again on another Pi zero W. Thanks for all the help with this!


OK same issue on a new install. My phones do not advertise BLE by default. I installed an app called BLE tools and this can be used to start advertising, once I install this is works.

Strange that they don’t do it by default?

Now I get this in the logs when testing

> HCI Event: LE Meta Event (0x3e) plen 30
    LE Advertising Report
      ADV_IND - Connectable undirected advertising (0)
      bdaddr 5A:8E:F3:6A:22:6F (Random)
      Flags: 0x02
      Complete local name: 'Mark Phone'
      TX power level: 249
      RSSI: -45


When it locks up I cannot access via SSH in and any MQTT messages are ignored only fix is a hard reboot.


Hmm that’s interesting. I think that may be a first around here,. Maybe there is something in the developers settings you can take a look at.

Glad something is finally working for you. Hopefully it’s a setting that you can set and forget


Oh… That would be an issue :sweat_smile:
It sucks that you can’t ssh into it to take a look at some logs and see why it’s locking up.


You just Jinxed me!!!

I had one node that wasn’t working correctly but it ended up being the ChromeCast ethernet adapter that needed to be unplugged. Unfortunately I don’t think there is a way I can monitor for this.


Is there any chance this can run on the same Pi as Hassio? Buying other Pi devices isn’t as affordable for me. Or maybe a similar project running on an ESP32?


I assume that there must be blt on the monitor. A pi 0 w is not especially expensive


i think as long as it has bluetooth and bluetooth isnt being used by something else you should be fine.

FYI Pi zero’s are like 15 dollars MAX. If you have a micro center around they are 5 dollars…


Couldn’t set and forget, which was a pity! and noting in the developer settings.

not one of my phones broadcasts like people on here are saying, which is so annoying. I thought of a different way… since I have iBeacons already, I will use them to detect if I am home, similar to OwnTracks.

So I installed beacon radar, when ibeacons are detected, send an intent to tasker, which then runs a mqtt client with monitor/scan/arrive. Need to test this properly but only issue I can see, is every time the iBeacon is scans, it sends a arrive mqtt to monitor… monitor ignore most of them due to the settings that are set.

Any thoughts on this method please?


I’m trying to use monitor.sh but I have the following error using Home Assistant MQTT server:

Invalid connection from (client @=x.x.x.x:XXXX) : [MQTT-3.1.2-1] Incorrect protocol name: "MQIsdp"

I found out that mosquitto_pub has to use the following option -V mqttv311.

Would it be possible to have an option in the configuration file to add some parameters ?


Honestly if you are going to carry the beacon anyways I “think” that would trigger a random advertisement possibly. But either way your way with work too.

Do you have anything currently paired to your phone? If not try and pair something and see if it starts sending advertisements.


yeah I meant I have the beacons static at home and use the phone to detect them when I arrive… OR make the phone an ibeacon.

Tested the method above, it works well… IF the program is running in the foreground… back to square 1.
I’ve tried the pairing… it was already paired with my car and a BT speaker. I just don’t get it. Thanks for taking time to try to help.!


Where I live they cost about 35USD with shipping included. I admit it’s still not incredibly expensive but sadly it’ll need to wait until I have other expenses covered. By the way, 5 dollars? Seriously? I envy you guys a little.


Yeah they are NZ$25-30 plus $5 shipping in New Zealand. Its not a trivial purchase like $5 is. Coffee is $5. $25-30 is a very nice bottle of wine :wink:

Very annoying.


Hi there,

I’m using monitor on a RPI with MQTT and home assistant. When I use it as a systemctl service it never seems to update. If I run sudo bash monitor.sh, my sensor immediately gets a correct status.

Any way I can figure out why the service is not working but manually running monitor.sh is?



sudo systemctl status NAME_OF_YOUR_SERVICE


I don’t have android devices to test, but that definitely could be a possibility. Try connecting to a BTLE device - that may cause your phone to start advertising for connections to that device.


Another technique besides the one that @mf_social mentioned would be to check processes. You can do this by ps ax | grep monitor.sh or htop In either case, you’ll see anywhere from 7 - 16 monitor.sh forks.