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

Have you gotten any clearer about this? My monitor service stops with these errors. Can’t get it to run a whole day, but sometimes it stops almost at once I restart it.

Couple things. Which version are you currently using?

I use monitor to auto unlock my front door and its about 10-15 feet from the elevator. I am in the 90 percent range of successful unlocks. So advertisement should work just fine.

try this. Turn your BT off and restart your Pi and wait for it to show zero confidence (BTW how are you looking at confidence? it recommend using some type of mqtt broker to see the messages.)

after it is off just read the status of the service using journalctl -f -u monitor.service
See if it is picking up random advertisements and doing scans. if you see that it if go ahead and turn bluetooth on (what phone are you using ?)

this should tell us if it is the monitor.service, the script, or the way your phone sends advertisements.

1 Like

he was talking about version 0.1.667 which had bugs that were fixed the next day witha new release.

what version are you currently running?

I will check later, might be a new version out. Thanks!

Thanks for the reply!

I am on the latest version

Starting monitor.sh (v. 0.1.675)… and I was checking confidence via the MQTT sensor in HA, which counts down when I run the exit script… but is now never auto discovered… output from journalctl below… Any idea please?

Oct 29 16:11:12 raspberrypi bash[19161]: }
Oct 29 16:11:13 raspberrypi bash[19161]: 0.1.675 04:11:13 pm [ERROR]        Correcting HCI error: Disable scan failed: Input/output error
Oct 29 16:11:15 raspberrypi bash[19161]: 0.1.675 04:11:15 pm monitor/downstairs/04:7xx1:82
Oct 29 16:11:15 raspberrypi bash[19161]: {
Oct 29 16:11:15 raspberrypi bash[19161]:         retain: true
Oct 29 16:11:15 raspberrypi bash[19161]:         version : 0.1.675
Oct 29 16:11:15 raspberrypi bash[19161]:         address : xxx
Oct 29 16:11:15 raspberrypi bash[19161]:         confidence : 0
Oct 29 16:11:15 raspberrypi bash[19161]:         name : Mark
Oct 29 16:11:15 raspberrypi bash[19161]:         timestamp : Mon Oct 29 2018 16:11:15 GMT+0000 (UTC)
Oct 29 16:11:15 raspberrypi bash[19161]:         manufacturer : HUAWEI TECHNOLOGIES CO.,LTD
Oct 29 16:11:15 raspberrypi bash[19161]:         type : KNOWN_MAC
Oct 29 16:11:15 raspberrypi bash[19161]: }
Oct 29 16:11:15 raspberrypi bash[19161]: 0.1.675 04:11:15 pm [CMD-INFO]        **** Completed departure scan. ****
Oct 29 16:11:24 raspberrypi bash[19161]: 0.1.675 04:11:24 pm [CMD-NAME]        04:79:70:14:71:82 Mark  HUAWEI TECHNOLOGIES CO.,LTD
Oct 29 16:11:24 raspberrypi bash[19161]: 0.1.675 04:11:24 pm [ERROR]        Correcting HCI error: Invalid device: Network is down
Oct 29 16:11:34 raspberrypi bash[19161]: [97B blob data]
Oct 29 16:11:45 raspberrypi bash[19161]: 0.1.675 04:11:45 pm [CMD-RSSI]        xxxxxUndiscoverable Device Name RAND RSSI: -87 dBm (Slow/No Motion, changed -12)
Oct 29 16:11:50 raspberrypi bash[19161]: 0.1.675 04:11:50 pm [ERROR]        Correcting HCI error: Disable scan failed: Input/output error
Oct 29 16:12:00 raspberrypi bash[19161]: 0.1.675 04:12:00 pm [ERROR]        Correcting HCI error: Invalid device: Network is down
Oct 29 16:12:10 raspberrypi bash[19161]: [97B blob data]
Oct 29 16:12:26 raspberrypi bash[19161]: 0.1.675 04:12:26 pm [ERROR]        Correcting HCI error: Disable scan failed: Input/output error
Oct 29 16:12:36 raspberrypi bash[19161]: 0.1.675 04:12:36 pm [ERROR]        Correcting HCI error: Invalid device: Network is down
Oct 29 16:12:47 raspberrypi bash[19161]: [97B blob data]
Oct 29 16:12:57 raspberrypi bash[19161]: 0.1.675 04:12:57 pm [CMD-RSSI]        51:C0:xxx:3A:0E Undiscoverable Device Name RAND RSSI: -62 dBm (Slow/No Motion, changed 19)
Oct 29 16:12:58 raspberrypi bash[19161]: 0.1.675 04:12:58 pm [CMD-RSSI]        51xxx0E
 Undiscoverable Device Name RAND RSSI: -76 dBm (Slow/No Motion, changed -14)
Oct 29 16:12:58 raspberrypi bash[19161]: 0.1.675 04:12:58 pm [CMD-RSSI]        40:98:42:F6:72:F4 Undiscoverable Device Name RAND RSSI: -100 dBm (Slow/No Motion, changed -12)
Oct 29 16:13:03 raspberrypi bash[19161]: 0.1.675 04:13:03 pm [ERROR]        Correcting HCI error: Disable scan failed: Input/output error

Thanks, that’s good to know as I thought it was just my environment causing the errors (I didn’t see @teachingbirds earlier reply), so haven’t used monitor since (been trying to convert to Lovelace UI in the meantime - as it happens using @teachingbirds examples on GitHub!) . Will update and try again.

this is frustrating me now… using 2 android 8 phones, advertising isn’t working… Mate 10 pro and galaxy s9, not a clue what I am doing wrong… I just want it to detect the phones on arrival :smiley:

thoughts pretty please?

I dont know if it was only iphone but there were a post about the phones did not advertise if the had not been paired once with a blt device

What options are you using and do they actually advertise through some beacon technology or just have Bluetooth on which means you’ll need to adjust arrival scan timing

both have been paired to other BT, like the car and speaker…

Ohh do I need to run something on the phone to make them advertise?? as I just have Bluetooth turned on!!

All you should need is bluetooth on.

the errors you are getting are HCItool errors

Are you using anything else bluetooth related on these pi’s?

also you may want to completely wipe one of the Pi’s and start completely over to see if it is something with the BLues installation.

In your known_static_addresses file are the mac’s lowercase or uppercase?

I see the same behavior … running monitor -b -g with no known_beacon_addresses entries … the iBeacon get detected with a confidence of 100 … but if i turn off the ibeacon … no new confidence level gets posted … and confidence remains at 100 … (however … the iBeacon BT Address confidence is lowering … and that status is updated through MQTT) …

Could this be a Bug ? … because for me it looks like iBeacons get detected… but not checked/monitored again for their presence ?

Any help would be very much appreciated !

Thanks, I’ve started again and added nothing to known devices and ran using -g
My phones MAC never shows up. I take it there isn’t much I can do? and MAC was all in caps

Starting monitor.sh (v. 0.1.675)...
> generic bluetooth beacon reporting mode enabled
> preference: delay between scans = 3
> preference: periodic arrive/depart check interval = 15
> preference: periodic arrive interval = 45
> preference: periodic depart interval = 90
> preference: database refresh interval = 35
> preference: max arrival scan attempts = 2
> preference: max depart scan attempts = 4
> preference: random advertisement expiration = 45
> preference: beacon rssi change required for reporting = 10
> preference: bluetooth environmental report frequency = 300
> preference: forced departure check interval = 240
> preference: interval until beacon is considered expired = 145
> preference: trigger a departure scan at other nodes below [x] confidence = 25
> preference: preferred HCI device = hci0
> preference: minimum time between the same type of scan = 15
> preference: mqtt scan start/end reporting = false
> mqtt trigger: monitor/scan/ARRIVE
> mqtt trigger: monitor/scan/DEPART
0.1.675 07:46:12 am [CMD-RSSI]  2E:8D:4C:43:6A:A6 Undiscoverable Device Name RAN                                                                                                                     D RSSI: -54 dBm (Fast Motion Departing, changed -54)
0.1.675 07:46:12 am [CMD-RAND]  2E:8D:4C:43:6A:A6 ADV_NONCONN_IND -54 dBm
0.1.675 07:46:12 am [CMD-RSSI]  0D:A5:DC:ED:B7:94 Undiscoverable Device Name RAN                                                                                                                     D RSSI: -58 dBm (Fast Motion Departing, changed -58)
0.1.675 07:46:13 am [CMD-RAND]  0D:A5:DC:ED:B7:94 ADV_NONCONN_IND -58 dBm
0.1.675 07:46:14 am [CMD-RSSI]  F9:2D:CC:DD:D8:F8 Undiscoverable Device Name RAN                                                                                                                     D RSSI: -91 dBm (Fast Motion Departing, changed -91)
0.1.675 07:46:14 am [CMD-RAND]  F9:2D:CC:DD:D8:F8 ADV_NONCONN_IND -91 dBm
0.1.675 07:47:22 am [CMD-RSSI]  64:7C:5E:D1:E1:A4 Undiscoverable Device Name RAN                                                                                                                     D RSSI: -100 dBm (Fast Motion Departing, changed -100)
0.1.675 07:47:22 am [CMD-RAND]  64:7C:5E:D1:E1:A4 ADV_IND -100 dBm
0.1.675 07:47:31 am [CMD-RSSI]  3C:01:78:CC:C5:BE Undiscoverable Device Name RAN                                                                                                                     D RSSI: -60 dBm (Fast Motion Departing, changed -60)
0.1.675 07:47:31 am [CMD-RAND]  3C:01:78:CC:C5:BE ADV_NONCONN_IND -60 dBm
0.1.675 07:48:11 am [CMD-RAND]  64:7C:5E:D1:E1:A4 ADV_IND -90 dBm
0.1.675 07:48:31 am [CHECK-DEL] 0D:A5:DC:ED:B7:94 expired after 75 seconds
0.1.675 07:49:06 am [CHECK-DEL] 64:7C:5E:D1:E1:A4 expired after 55 seconds
0.1.675 07:50:29 am [CMD-RSSI]  3C:01:78:CC:C5:BE Undiscoverable Device Name RAN                                                                                                                     D RSSI: -44 dBm (Slow/No Motion, changed 15)
0.1.675 07:51:01 am [CMD-RSSI]  3C:01:78:CC:C5:BE Undiscoverable Device Name RAN                                                                                                                     D RSSI: -58 dBm (Slow/No Motion, changed -14)
0.1.675 07:51:33 am [CMD-RSSI]  2E:8D:4C:43:6A:A6 Undiscoverable Device Name RAN                                                                                                                     D RSSI: -57 dBm (Slow/No Motion, changed -11)
0.1.675 07:52:07 am [CMD-RSSI]  F9:2D:CC:DD:D8:F8 Undiscoverable Device Name RAN                                                                                                                     D RSSI: -82 dBm (Slow/No Motion, changed 12)
0.1.675 07:53:42 am [CMD-RSSI]  3C:01:78:CC:C5:BE Undiscoverable Device Name RAN                                                                                                                     D RSSI: -44 dBm (Slow/No Motion, changed 16)
0.1.675 07:53:42 am [CMD-RSSI]  1A:22:B4:AD:B8:47 Undiscoverable Device Name RAN                                                                                                                     D RSSI: -64 dBm (Fast Motion Departing, changed -64)
0.1.675 07:53:43 am [CMD-RAND]  1A:22:B4:AD:B8:47 ADV_NONCONN_IND -64 dBm
0.1.675 07:54:14 am [CMD-RSSI]  3C:01:78:CC:C5:BE Undiscoverable Device Name RAN                                                                                                                     D RSSI: -62 dBm (Slow/No Motion, changed -18)
0.1.675 07:46:12 am [CMD-RSSI]  2E:8D:4C:43:6A:A6 Undiscoverable Device Name RAN                                                                                                                     D RSSI: -54 dBm (Fast Motion Departing, changed -54)
0.1.675 07:46:12 am [CMD-RAND]  2E:8D:4C:43:6A:A6 ADV_NONCONN_IND -54 dBm
0.1.675 07:46:12 am [CMD-RSSI]  0D:A5:DC:ED:B7:94 Undiscoverable Device Name RAN                                                                                                                     D RSSI: -58 dBm (Fast Motion Departing, changed -58)
0.1.675 07:46:13 am [CMD-RAND]  0D:A5:DC:ED:B7:94 ADV_NONCONN_IND -58 dBm
0.1.675 07:46:14 am [CMD-RSSI]  F9:2D:CC:DD:D8:F8 Undiscoverable Device Name RAN                                                                                                                     D RSSI: -91 dBm (Fast Motion Departing, changed -91)
0.1.675 07:46:14 am [CMD-RAND]  F9:2D:CC:DD:D8:F8 ADV_NONCONN_IND -91 dBm
0.1.675 07:47:22 am [CMD-RSSI]  64:7C:5E:D1:E1:A4 Undiscoverable Device Name RAN                                                                                                                     D RSSI: -100 dBm (Fast Motion Departing, changed -100)
0.1.675 07:47:22 am [CMD-RAND]  64:7C:5E:D1:E1:A4 ADV_IND -100 dBm
0.1.675 07:47:31 am [CMD-RSSI]  3C:01:78:CC:C5:BE Undiscoverable Device Name RAN                                                                                                                     D RSSI: -60 dBm (Fast Motion Departing, changed -60)
0.1.675 07:47:31 am [CMD-RAND]  3C:01:78:CC:C5:BE ADV_NONCONN_IND -60 dBm
0.1.675 07:48:11 am [CMD-RAND]  64:7C:5E:D1:E1:A4 ADV_IND -90 dBm
0.1.675 07:48:31 am [CHECK-DEL] 0D:A5:DC:ED:B7:94 expired after 75 seconds
0.1.675 07:49:06 am [CHECK-DEL] 64:7C:5E:D1:E1:A4 expired after 55 seconds
0.1.675 07:50:29 am [CMD-RSSI]  3C:01:78:CC:C5:BE Undiscoverable Device Name RAN                                                                                                                     D RSSI: -44 dBm (Slow/No Motion, changed 15)
0.1.675 07:51:01 am [CMD-RSSI]  3C:01:78:CC:C5:BE Undiscoverable Device Name RAN                                                                                                                     D RSSI: -58 dBm (Slow/No Motion, changed -14)
0.1.675 07:51:33 am [CMD-RSSI]  2E:8D:4C:43:6A:A6 Undiscoverable Device Name RAN                                                                                                                     D RSSI: -57 dBm (Slow/No Motion, changed -11)
0.1.675 07:52:07 am [CMD-RSSI]  F9:2D:CC:DD:D8:F8 Undiscoverable Device Name RAN                                                                                                                     D RSSI: -82 dBm (Slow/No Motion, changed 12)
0.1.675 07:53:42 am [CMD-RSSI]  3C:01:78:CC:C5:BE Undiscoverable Device Name RAN                                                                                                                     D RSSI: -44 dBm (Slow/No Motion, changed 16)
0.1.675 07:53:42 am [CMD-RSSI]  1A:22:B4:AD:B8:47 Undiscoverable Device Name RAN                                                                                                                     D RSSI: -64 dBm (Fast Motion Departing, changed -64)
0.1.675 07:53:43 am [CMD-RAND]  1A:22:B4:AD:B8:47 ADV_NONCONN_IND -64 dBm
0.1.675 07:54:14 am [CMD-RSSI]  3C:01:78:CC:C5:BE Undiscoverable Device Name RAN                                                                                                                     D RSSI: -62 dBm (Slow/No Motion, changed -18)


???
im confused as to why you took your phone out of the known devices???

If your phone isnt in the known devices than it will never get a name scan. You will never see the phone at all because they do not give their mac address it has to be requested.

-g is only for beacons…

All i asked was if the mac addresses in known_devices were uppercase or lowercase. they should be lower case.

1 Like

@MarkR, @benjimatt is correct hear. These are errors related to the underlying Bluetooth hardware. I have found in the past that simply stopping the service for about 30 seconds or re-booting the raspberry pi cures the issue.

This usually occurs when starting or stopping the service rapidly during testing.

This is likely the same air that other supported related to iBeacons. Should be addressed in the beta.

Can you help or give me some hints about my iBeacon Problem (Confidence not being updated when iBeacon obviously is offline) above ? that would be awesome. Thanks

I have posted an iBeacon bug in github that is being investigated, it looks really similar to your problem. https://github.com/andrewjfreyer/monitor/issues/41

this is exactly what i’m seeing too … thank you very much for the “confirmation” that this is a bug (still present in beta branch … right ?) …

so i’ll monitor that bug report … thanks !

I tried both, and 1 is just numbers

why I removed them, as a test to see if they would appear to advertise.

I think I am getting myself all confused as I read some people say they have it set only on triggered departs and arrivals when the phone advertises itself… then others say I need to increase when it scans for arrivals. I just would love this to work