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

Is anyone using RSSI for room detection, I can pair with my phone but then when I start monitor again I cant see any RSSI values and the bluetooth menu on my phone says not connected? Not sure if this is a silly question but can I use room assistant and monitor on the same pi?

Hi,
After a hiatus from this project I thought I’d try again.

I have 2 devices, an apple watch and a fitbit Ace 2

Running this I can see the fitbit device:

sudo hcitool lescan
AA:AA:AA:AA:AA:AA Ace 2

The Mac for my watch is DD:DD:DD:DD:DD:DD (found in its settings)

I have successfully added DD… to the known_static_addresses, and the confidence rises and falls with it’s presence. Fabulous

When adding AA to known_static_addresses I see this output (but no change in the topic)

===================================================

              *** BETA/DEV BRANCH ***

===================================================
> starting monitor.sh (v. 0.2.200)...
> removing web request caches
> warning: monitor.service not installed. Install service? (y/n)
n
> AA:AA:AA:AA:AA:AA confidence topic: monitor/pi/fitbit (has not previously connected to hci0)
> DD:DD:DD:DD:DD:DD confidence topic: monitor/pi/apple_watch (has not previously connected to hci0)
[-] 0.2.200 21-08-2020 07:11:50 pm [CMD-MQTT]	monitor/pi/fitbit { ... confidence : 0 ... }
[-] 0.2.200 21-08-2020 07:11:56 pm [CMD-MQTT]	monitor/pi/apple_watch { ... confidence : 100 ... }
[-] 0.2.200 21-08-2020 07:11:57 pm [CMD-NAME]	DD:DD:DD:DD:DD:DD Ace 2  Unknown
[-] 0.2.200 21-08-2020 07:11:58 pm [CMD-NAME]	AA:AA:AA:AA:AA:AA Apple Watch  Apple Inc
[-] 0.2.200 21-08-2020 07:12:30 pm [CMD-NAME]	DD:DD:DD:DD:DD:DD Ace 2  Unknown

When adding AA to known_beacon_addresses I see this output (but no change in the topic)

===================================================

              *** BETA/DEV BRANCH ***

===================================================
> starting monitor.sh (v. 0.2.200)...
> removing web request caches
> warning: monitor.service not installed. Install service? (y/n)
n
> DD:DD:DD:DD:DD:DD confidence topic: monitor/officebt/phill_watch (has not previously connected to hci0)
> known beacon: AA:AA:AA:AA:AA:AA publishes to: monitor/pi/fitbit
[-] 0.2.200 21-08-2020 07:14:16 pm [CMD-MQTT]	monitor/pi/apple_watch { ... confidence : 100 ... }
...
[-] 0.2.200 21-08-2020 07:19:40 pm [CMD-MQTT]	monitor/pi/apple_watch { ... confidence : 100 ... }
[-] 0.2.200 21-08-2020 07:19:42 pm [CMD-NAME]	DD:DD:DD:DD:DD:DD Phillip’s Apple Watch  Apple Inc
[-] 0.2.200 21-08-2020 07:19:43 pm [CMD-MQTT]	monitor/pi/apple_watch { ... confidence : 100 ... }
[-] 0.2.200 21-08-2020 07:19:44 pm [CMD-NAME]	DD:DD:DD:DD:DD:DD Apple Watch  Apple Inc
[-] 0.2.200 21-08-2020 07:20:09 pm [CMD-RSSI]	PUBL AA:AA:AA:AA:AA:AA RSSI: -73 dBm (initial reading | 127 dBm)

Any ideas?

I’m having trouble seeing any RSSI readings for my iPhone. I’ve paired with monitor and the phone works fine for presence but I can’t see any rssi readings? Whenever I pair it says connected and then shows as disconnected in the Bluetooth menu in my phone?

If I start this script with monitor.sh -tdr -a -b and later I reboot the raspberry pi, does the service automatically start on reboot with these options I last had? (ie. -tdr -a -b)

No, you need to update the service file you create.

hi guys,
I have a little annoyance. My wife has an iPhone I have a Samsung s10. Monitor always detects the iPhone faster than the Samsung, is there anything I can do to speed up the samsung detection?

(Aside from buying an iphone)

Buy a cool android phone with a real android like a Pixel? :crazy_face: :laughing: Sorry, couldn’t resist. :grin:

In what situations do you experience that behaviour? Normally you should run an arrival/departure-scan, triggered for example by a motion sensor or door contact. This should bring up both devices, as soon as they answer the request from monitor.sh. How long it takes the phone to answer this request is entirely dependent on the phone… :wink:

Maybe there is something you can change with your setup, but that would need a little more information to be answered. :slight_smile:

Hello gang! I’ve got monitor installed and running on two PIZWs. These are clean installs per the installation instructions in read.me and updated to latest on all packages. They work well, but the issue I’ve got is each will intermittently stop sending data. If I try to ssh into one that is not sending data, I’m unable to connect, though my router still shows it on the network.

However, the interesting part is that it will send a monitor/[location]/status offline message when it goes offline, so it’s obviously something monitor.sh itself sees. Has anyone seen this before or does anyone know what would trigger the send of the offline payload for the status topic?

Thank you very much for the help!

I’ve had that happen too, which is why I moved off the Raspberry Pi Zero to the Orange Pi Zero LTS. That’s been rock solid.

Thanks for the tip! I ordered one, but until it shows up I’ve been trying to do some troubleshooting, without much luck. I tried to turn off the RSSI monitoring/reporting to see if that makes a difference, but I’m not sure how to do that. I tried running monitor.sh -u to reset the flags, but it’s still reporting RSSI.

Is there a way to remove that functionality after one has already paired with the PiZero? Are logs stored on the unit? It definitely seems to be dying hard (I can’t even ping it) when it goes down, so I don’t have much to go on.

When i looked at the specs for the Orange Pi Zero LTS I couldn’t find Bluetooth. Was it a different Orange Pi that you use?

It has Bluetooth apparently (from some forum threads, part of the WiFi module), but getting it to work is fiddly. I have some CSR Bluetooth dongles from previous tinkering and stuck one of those on a USB extension cable to get it where I wanted.

Hi, I’ve decided to have a go at using monitor for presence detection. I’m configuring monitor with the Monitor-App and slowly trying to understand the various errors that I’m encountering.

It mostly seems to be working ok with the one monitor device I have at the moment, but for some reason it keeps detecting devices that aren’t in my known_static_addresses file, and publishing confidence levels for these via MQTT. (known_static_addresses is populated via Monitor-App)

My three devices in known_static_addresses are:

xx:xx:xx:xx:xx:9E mine
xx:xx:xx:xx:xx:15 wife
xx:xx:xx:xx:xx:53 daughter

Looking at the logs via journalctl -u monitor.service it shows the following for one of the unknown devices (it detects around 10 altogether):

[CMD-PUBL]        xx:xx:xx:xx:xx:40 SHIELD Unknown -100 dBm
[CMD-MQTT]        monitor/hallway/xx:xx:xx:xx:xx:40 { ... confidence : 100 ... }
[CMD-MQTT]        monitor/hallway/xx:xx:xx:xx:xx:40 { ... confidence : 48 ... }
[CMD-MQTT]        monitor/hallway/xx:xx:xx:xx:xx:40 { ... confidence : 43 ... }
[CMD-MQTT]        monitor/hallway/xx:xx:xx:xx:xx:40 { ... confidence : 26 ... }
[CMD-MQTT]        monitor/hallway/xx:xx:xx:xx:xx:40 { ... confidence : 0 ... }
[DEL-PUBL]        PUBL xx:xx:xx:xx:xx:40 expired after 257 seconds
[CMD-MQTT]        monitor/hallway/xx:xx:xx:xx:xx:40 { ... confidence : 0 ... }

My monitor options are:
monitor.sh -tdr -a -b

I suspect it’s the -b beacon option, so i’ll remove that for now and see how it goes.

Thanks.

My script currently crashes with the following message:

monitor.sh: line 955: Xiaomi Inc.: syntax error: invalid arithmetic operator (error token is “.”)

Is this a known issue?

I’m not super familiar with the script, but when it starts via systemd at bootup, does it write out a log to disk? If not, can someone point me to where it’s called so I can try to get it to write out logs to disk? I’d really like to try to help debug this if I can.

Thanks!
-Peter

journalctl is the command you need to get logs from anything running under systemd. For example:

journalctl -n 50 -u monitor

journalctl --since '06:00' -u monitor

man journalctl for more

Hi, all.

I’ve got monitor configured as sevice in a Raspberry Pi 4. In my house there’re 3 phones and a smart band (configured as beacon) and all of them are saved as known_static_addresses and known_static_beacons.

In my home assistant instalation there’s an automation that sends a scan/depart and scan/arrive based on a door sensor state. I’ve noticed that everyday the mosquitto topic number is growing (see image below).

Monitor command arguments:

-x -b -tdr

Result:

MQTT_Explorer_1HBf004GEe

Is that normal? How can I remove MAC addresses that don’t affect me? Any idea?

Thanks in advance.

@andrewjfreyer, I am in need of your’s or somebody else’s help again.

I have a well-working setup with Monitor running on 5 nodes (2xRPi0W, 1xRPi 2, 1xTinkerboard, 1xNUC) running with ‘-tadr -b’. It generally works for iPhones, but I have some oddity on beacons, which are initially detected fine, but never expires.

It’s some cheap RDL51822s, detected as GENERIC_BEACON_PUBLIC, but they stay with confidence=100 even though I remove the battery and wait for hours. I have PREF_BEACON_EXPIRATION=240 and would expect it to expire after 4 mins. Triggering DEPART scans via mqtt doesn’t seem to change anything either.

Any good advice on what to try next ?

Thanks in advance!

Where can I find those scripts? I stopped the service and disabled it. I also removed the folder but somehow my system is trying to activate the service again after rebooting my system.