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

Increasing the beacon expiration will help reduce chatter, but since beacons only report every so often, confidence will drop s time marches on.

Thanks for the reply, and I really appreciate all you work on this project!

Iā€™ve tried both the master and beta branches with the same results. Just to be clear on your second suggestion, should there actually a known_static_beacons file or was that just an accidental mash-up of the known_beacon and known_static files? If itā€™s the later, Iā€™ve tried the mac addresses in both files. In known_beacons, they wonā€™t respond at all. In known_static, they just show a 0 confidence .

Thanks for your help.

1 Like

accidental mixup haha. sorry

1 Like

Iā€™ve stopped tracking my Tiles I found the reporting to be a little hit and miss and my 2.4 interference went through the roof.

Looks pretty amazing.
Ordered a Pi zero w to try this.
Is there a more GUI/user friendly way/browser based way of adding known devices?

ā€“ Below has been solved ā€“

Also something I am not quite clear on in the guide, especially when the text suddenly tells about mqtt response or something like that.

Add the mac address that you copied for your phone at the end of the file. Next to the mac address, you can add a "nickname" or a hash-prepended comment if you like. For example:

```
00:11:22:33:44:55 Andrew's iPhone #this is a comment and everything after the hashmark is ignored
```

Do this with all other cell phone/laptop devices that you'd like to track via mqtt messages posted/formatted like this:

```
topic:    location/first floor/00:11:22:33:44:55
message:  {
  retain: false
  version : 0.1.666
  address : 00:11:22:33:44:55
  confidence : 0
  name : Andrew's iPhone
  timestamp : Fri Sep 28 2018 22:41:11 GMT+0000 (UTC)
  manufacturer : Apple, Inc.
  type : KNOWN_MAC
}
```
1 Like

Once you get the Pi just follow the instructions. You basically need your devices MAC in the Known_devices file and the MQTT server settings in the Mqtt_preferences file

2 Likes

Also planning to just use it with iPhones, no beacons or BLE devices. Can I do something to reduce interference further or improve accuracy/efficiency/reliability?

1 Like

Thanks a lot.
But is there a way to add known devices on the fly without having to SSH?

1 Like

There is not a way to add devices on the fly. I suppose a trigger could be made but as of this time this is not possible. You filter out some of the BT devices around you that do not need to be scanned. THis would go in the blacklist

2 Likes

Hi guys,
Looking for some advice here. I have been tinkering with 3 Pi Zeroā€™s w/ Monitor script for a while now.
Reading about how to configure in forums and the README, but I canā€™t seem to get it working reliable and quick.

I live in a house in which I have placed 2 Pi Zeroā€™s : Ground floor and second floor.
There is a third in the garage , which is detached from the house and in which I have a garage port which I can open & close w/ HA.

I would like the Garage Pi to detect presence within 5-10 seconds of proximity with our iPhones.
The House Piā€™s should reliable detect my presence during the time I am in the house.
I have sensors on both doors on ground floor to exit the house.

My idea was that all Piā€™s should do arrive scans when an RAND BTLE advertisement is seen.
The house Piā€™s should only do departure scans when a sensor on the two doors is triggered.

So I end up with : monitor.sh -E -a -m -tdr

Would you say that this is correct?
When would you configure the monitor script with : -r toggle? I donā€™t understand that.

Thanks so much for your time and all the great work you have put into the monitor script!

Okay finally got it set up.
Recieved 1st scan Mqtt as well.
However nothing happens after that.
Switched off Bluetooth on my iPhone nothing seemed to change in my sensor. Was still 100%

enabled script by typing:
sudo bash monitor.sh

Also if I terminate the terminal window will the service still keep running?

Also I want to be able to only scan for known devices, basically donā€™t have any Ble beacons or anything, hopefully will improve performance?

How do I scan for arrive and depart?

Really new to mqtt pi zero and all this.
Thanks a lot.

Also if I terminate the terminal window will the service still keep running?

You can enable a service to keep the service running ; sudo service monitor start
I think the monitor.service is configured for you after the initial run.

Or you can install : screen, which will allow you to run a command in a shell, and send it to the background.

How do I scan for arrive and depart?

post a mqtt message to <>/scan/ARRIVE or <>/scan/DEPART

Hi guys,
I have managed to set up monitor to recognise my 2 phones but when it comes to Tile tracker and FitBit Flex 2 I am not having so much luck. I have read manual and posts in this thread countless times but I am still unable to detect presence of Tile and FitBit. The interesting thing about it is that I got Bluetooth finder app on my phone and while the monitor canā€™t see these devices my phone app can. If I run monitor with -b -g arguments and previously save in the beacons file mac addresses of the flex and tile then I get to see some discoveries however never with confidence greater than 0 :confused:

{
	retain: false
	version : 0.1.675
	address : E9:BE:FB:63:9E:F6
	confidence : 0
	name : Fitbit Flex 2 beacon
	timestamp : Sun Nov 18 2018 14:48:33 GMT+0000 (GMT)
	manufacturer : Unknown
	type : KNOWN_MAC
}
0.1.675 02:48:34 pm [CMD-NAME]	E9:BE:FB:63:9E:F6 Fitbit Flex 2 beacon  Unknown
0.1.675 02:48:34 pm [CMD-RSSI]	62:57:2D:93:D2:F7 Undiscoverable Device Name RAND RSSI: -75 dBm (Fast Motion Departing, changed -75) 
0.1.675 02:48:34 pm [CMD-RAND]	62:57:2D:93:D2:F7 ADV_NONCONN_IND -75 dBm
0.1.675 02:48:35 pm [CMD-RSSI]	47:9D:1A:12:37:E5 Undiscoverable Device Name RAND RSSI: -78 dBm (Fast Motion Departing, changed -78) 
0.1.675 02:48:35 pm [CMD-RAND]	47:9D:1A:12:37:E5 ADV_IND -78 dBm
0.1.675 02:48:35 pm [CMD-RSSI]	62:57:2D:93:D2:F7 Undiscoverable Device Name RAND RSSI: -77 dBm (Slow/No Motion, changed -11) 
0.1.675 02:48:36 pm [CMD-RSSI]	62:57:2D:93:D2:F7 Undiscoverable Device Name RAND RSSI: -66 dBm (Slow/No Motion, changed 11) 
0.1.675 02:48:37 pm [CMD-SCAN]	(No. 1) ED:41:AB:80:79:1A arrival? 
0.1.675 02:48:37 pm [CMD-RSSI]	67:8B:5D:8E:B8:72 Undiscoverable Device Name RAND RSSI: -77 dBm (Fast Motion Departing, changed -77) 
0.1.675 02:48:37 pm [CMD-RAND]	67:8B:5D:8E:B8:72 ADV_NONCONN_IND -77 dBm
0.1.675 02:48:42 pm monitor/room/ED:41:AB:80:79:1A 
{
	retain: false
	version : 0.1.675
	address : ED:41:AB:80:79:1A
	confidence : 0
	name : Tile key fob beacon
	timestamp : Sun Nov 18 2018 14:48:42 GMT+0000 (GMT)
	manufacturer : Unknown
	type : KNOWN_MAC

Any ideas please?
Thanks in advance.

Getting better at this.
Now how do I set this up so that whenever my phone leaves bluetooth range it shows occupancy 0
And whenever it enters back in automatically switch to 100?

Iā€™ll be putting this in a stairway away from any other devices or router so 2.4ghz interference shouldnā€™t be an issue.

Basically want to trigger automations when I walk up the staircase.
Donā€™t want to trigger manual arrive/depart scans. Want it to be automatic?
Whatā€™s the best case scenario I can achieve with this? As in whatā€™s the fastest I can get occupancy reports automatically?

Also can I use it some way to trigger lights in a room? As in is it responsive enough for real-life usage?

I dont know what is the best but got a cheap one from aliexpress (~7$ round white) and it works great ( use the keys+phone with a min_max sensor on confidence - my phone sometimes disconnects when in bedroom on the far side of the house but keys are always detected in the ā€œlanding padā€).

Ordered some other cheap ones (one that looks like a tile tracker for 4$ and some really cheap ones at 1.5$ with a button o.O ) just to test so will update the thread when they come.

Using the beta branch too btw.

Room-assistant may be more for your use case https://github.com/mKeRix/room-assistant

1 Like

try beta branch

Thanks. Do they have a decent battery life?

i hope that at least a year - i use it for 2 months now so i can report back in a year or when it dies :wink:
Here is a handy application note for the beacon (CC2541) that calculates the expected lifetime to 400 days:
http://www.ti.com/lit/an/swra347a/swra347a.pdf

link to the beacon (wont win any style awards tho) : https://www.aliexpress.com/item/CC2640-1-8V-3-8V-Bluetooth-BLE-4-1-Wireless-Module-For-DOTT-iBeacon-Base-Station/32846400403.html?spm=a2g0s.13010208.99999999.339.45183c00VCB6Kj

EDIT to clarify - the calculation is for cc2541 but i use cc2640 that is suppose to be much more energy efficient.