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

I’m using an existing broker, I did not set up a new broker, also when I check for bluetooth devices on my network, it does not pick up the new pi zero W, but i pick it up on ssh, so I’m thinking the bluetooth service is perhaps not switching on

That is one beast of a shell script!

1 Like

Update: I changed the port to 1883, I have checked if bluetooth is on for the RPI-Z W through hci tools and it seems to be ON as I can scan for it via a phone’s bluetooth, it is also on SSH as I can login to it. My subscription to location/owners/garage/XX:XX:XX:XX:XX:XX or location/# (as per @cgtobi suggestion ) still does not yield anything, I know mosquitto_sub works because i have subbed other devices and got results, in the mqtt settings for the new pi zero W, should it be “192.168.1.1XX**:1883**” or just “192.168.1.128” ? I know its probably a small step that I am missing. :frowning::frowning::frowning::frowning:

You are not really giving enough information for anyone to help you identify your issue.

Here are the steps I would do:
1 check that your mqtt broker is working correctly - on the machine running the broker use your favourite method to listen to all traffic (I use the same method as @cgtobi but without the location/) ; then open a terminal on that same machine and use a mosquito_pub to publish to a test topic. Confirm you can see the test posting. When that works remember the test command.

2 check that you can publish from your Pi Zero W to your broker - open a terminal on the Pi Zero and use the same mosquito_pub command as you used in step 1 with the addition of -h <THE_IP_OF_YOUR_BROKER>. If your broker is - as standard - using port 1883 you do not need to specify a port. If you cannot publish from the Zero then you need to identify why.

3 go CAREFULLY through @andrewjfreyer’s excellent installation instructions and make sure you have not made any errors

Just like that it clicked, I conflated having an existing broker with being able send mqtt messages, I neglected the step about installing mosquitto on the new RPi-Z W, I will do so when I get home from work and test it, I think that is the issue, it should have clicked when I tried to sub a topicon the new Pi Z and it did not recognize the command.I will flash mosquitto and report back, hopefully I will be reporting good news.:face_with_raised_eyebrow::face_with_raised_eyebrow::face_with_raised_eyebrow:

Hi all.
I have some problem setting it up.
For some reasons there is no connection to mqtt i tried different approaches so far everything fails.
Is there any log file where i can see what is wrong, if yes can someone please send me the path where i can find it.
I am running MQTT on PI3 with ssl, i tried including https:xxx.xxx.x.xx i even added the port to the end with no success. The presence is on a PI w
Thanks for all the help.

Detection exists, can you calculate the distance of the area? Room and room

Not really. There isn’t a reliable metric for distance measurement. Even with RSSI calculations (which won’t work for phones, the target of this script), error is pretty dramatic even with sophisticated filtering.

In the MQTT_PREFERENCES file, you should not be specifying the port with a colon after the IP address. Just specify the IP address.

Thank you for your answer!

thanks, I loaded everything from scratch, it now sends the messages, but does not recognize devices, one is a Samsung tablet, the other a Huawei P10, see the messages below:

|location/owner/garage/E8:4E:84:B6:72:XX|{"confidence":"0","name":"Invalid device: No such device","scan_duration_ms":"5083","timestamp":"Tue Jul 03 2018 19:40:11 GMT+0000 (UTC)"}

what could be the issue?

Try searching the script for -hc01 and deleting it.

Where do I find the script? :face_with_raised_eyebrow::face_with_raised_eyebrow:

presence.sh @Caswell1000

I had the wrong assumption that the wifi MAC is the same as the BT MAC, but re-reading the thread made me realise that they are not one, so now I have 100 registering on the jfreyer scale and I am at peace, thanks a lot for your hard work. :mage::mage::mage: and I did not have to look for the .sh file…

location/owner/garage/E8:4E:84:XX:72:XX{"confidence":"100","name":"CN2014","scan_duration_ms":"981","timestamp":"Tue Jul 03 2018 21:40:31 GMT+0000 (UTC)"}
location/owner/garage/14:9D:XX:81:25:XX{"confidence":"100","name":"HUAWEI P10 CN","scan_duration_ms":"5037","timestamp":"Tue Jul 03 2018 21:40:37 GMT+0000 (UTC)"}
2 Likes

Ha Ha we making the same mistakes, not installing MQTT (i am glad i so your message) and forgetting that the one i sett was not BT MAC.
Now all works fine

THANKS SO MUCH for all that contributed and help with this project.
Finally my lights will stay one when i am home and my HA will not think that i left home

@NKF
Did you get it to work with your phones? I currently have an iPhone 5, working fine. iPhone 8, only visible when in the bluetooth scanning menu…

Anybody else having issues with the phone not being visible on BLE?

@andrewjfreyer What you have made is a great share!

1 Like

good,Thanks for sharing, thank you

1 Like

uhm… and then I paired the iPhone 8 with a carkit, and after it … suddenly was detected when I got home. :crazy_face:

1 Like

Hey all - check out my github for an alpha of the rewrite. The project is named, for the time being, monitor. Any thoughts or reports would be greatly appreciated. I have been testing for a very long time, and it works for my family with the same performance, if not a bit faster, while scanning about 75% less often than presence (substantially mitigating wifi interference issues).

Please let me know what y’all think.

7 Likes