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

Thank you. It works!

My Fitbit devices does not get recognized when scanned.

I use sudo bash monitor.sh -t -r -u and my fitbit devices are listed in file known_static_addresses

I switched my Pi Zeros over to micro USB / Ethernet adapters rather than WiFi and they do not seem to just stop any longer.

I donā€™t know about Fitbit, but my Mi Band 4 fitness tracker is BLE, so you need to have - b flag and the Mac in known beacons.

1 Like

I just found this project, apologies if this has already been discussed. Iā€™ve started reading the thread but itā€™s going to take some time to get through it all. Iā€™m looking for something that tracks users through rooms. I was thinking that if a known device is seen then trigger an arrival scan on all sensors, compare signal strength, and strongest signal is where that device is. Is this plausible? Any tips or guidance on configuration?

Right now I have a couple pi setup in different places with a default config and a topic path that identifies the pi. I have a script watching all mqtt traffic matching those paths that sends a notification to my phone when messages are received. I only seem to be getting notifications from one pi and even those donā€™t correspond to actual arrival/departures so I donā€™t have something right. I know I can scan arrival/departures but can I do that for a specific pi or how does that work?

Just changed to sudo bash monitor.sh -a -ta which, to my understanding, should broadcast all events and then trigger all other pi to collect as well. Am I accurate in my thinking? Is this what I want?

Update. I found the RSSI tracking section of the documentation. I stopped the service, ran sudo bash monitor.sh -c A0:A0:A0:A0:A0:A0, connected, and rebooted on each pi. Only 1 is reporting RSSI and itā€™s always -99 even when my phone is within inches of it. Iā€™m starting to think that Iā€™m trying to use this in a way itā€™s not designed to be used.

Very good Andrew!

Since Iā€™m a newbie at HA I need som help with how to configure it to use the Monitor service.

I have got the monitor service running om my Pi Zero and reporting to my MQTT server, so far so good.

But then I really need som help with the HA implementation with several persons/devices

The following code that I copied from the example:

  - platform: mqtt
    state_topic: 'monitor/first floor/martinss10'
    value_template: '{{ value_json.confidence }}'
    unit_of_measurement: '%'
    name: 'Futten'
  

  - platform: min_max
    name: "Home Occupancy Confidence"
    type: max
    round_digits: 0
    entity_ids:
      - sensor.futten

(I just have one monitor running but I will have several all over our property)

The code above tell my S10 named Futten ā€¦ but Futten is a house on our property.

How do I set up this properly with the familys 6 phones and iBeacons) so I can see if they are home and in what area they are. This I canā€™t understand.

Has someone this working and can help me set it up?

First of all. Awesome project! just what I have been looking for!

Iā€™m running on a Pi0W that I have formatted and tried installing twice but Iā€™m not having the best of luck with my devices. Itā€™s a Unihertz Atom (known to be plagued with BT issues). Strangely it works sometimes and but most of the times it doesnā€™t. Also my girlfriends iphone doesnā€™t seems to be doing great either. I havenā€™t had time to try my roommates S10 but will try once I get at least the iPhone working perfectly.

It seems to notice my phone with default script arguments(no door sensor) and then the confidence starts dropping after a seemingly arbitrary amount of time.

I have tried the methods of troubleshooting that I could find while combing through this massive thread. Iā€™ve tried connecting to my laptops wifi with the Atom but I donā€™t believe that the iPhone has connected to a bluetooth device yet so Iā€™ll have to give that a shot.

sudo bash monitor.sh -c <MY:ADDRESS>

Sometimes it connects to my phone but most of the time it canā€™t.

hcitool name <MY:ADDRESS>

Also works sometimes but mostly returns nothing.

Iā€™ve tired the hcitool & hcidump method but there are too many devices in my environment (apartment living) to make anything out of this.

Iā€™ve tried Beacon Simulator and the Advertiser function in NRF Connect but neither of them seem to keep my phone at 100% confidence. nRF Connect also shows that my phone does not support the advertisements.

Iā€™m not sure what to do next. Iā€™d really love to get this working but I may have to settle with a BTLE beacon or some other small keychain device.

Iā€™m having a weird issue where my Pixel 3 is getting detected properly when I first startup the monitor script, but after around 6-9 hours the confidence drops to 0 and never gets detected again unless I restart the script.

The script is still running and responds properly to a monitor/scan/echo request and does pick up my other bt devices. Iā€™ve tried tried monitor/scan/restart, restarting the bt on my phone, but nothing seems to work unless I restart the script.

Has anyone else experienced anything like this?

what flags are you running with? My pixel 3 works 99% of the time

I have it setup with -tr -b

admittedly, iā€™m not an expert with this, but i think running it in beacon mode changes things a bitā€¦ Iā€™m running 4 diff nodes all with -tdr and it is extremely reliable.

@masterkenobi @nickrout @Klagio @Mahko_Mahko If youā€™re using an ESP32 to do device tracking and want some more control, Iā€™ve been working on a project to do dedicated presence detection. Iā€™ve addressed the issue with Bluetooth/WiFi antenna sharing, so itā€™s stable. Thereā€™s no facility to trigger a scan on demand, but I can build that if the demand is there. (I.e. if you want it, submit a feature request).

9 Likes

Nice one. I was using esphome for ble tracking on an esp32, but wasnā€™t getting the arrival detection times I needed. Being able to do both scans on demand and track traditional bluetooth devices on an esp32 would be ideal.

I think this could improve by a component integrated redirect to hass, like the component to read temperature from BLE sensor

I think thatā€™s not needed, given it uses MQTT. However Iā€™m sure thereā€™s nothing stopping you writing such a component :wink:

Exactly what I was trying to figure out:)

cool, can this be flashed with ESPHome?

No, this is entirely separate from the esphome project.

I was reading this post for the same reason as you, did you make any progress?

I miss-read what component reads BLE values?

My setup was working just fine the first couple of weeks, but now it seems like the arrival scan is no longer triggered when I post the monitor/scan/arrive message in MQTT. Or rather, my BT devices arenā€™t found until much later.

Is there any way to see in the logs if/when a scan is started?