BLE beacon tracker, sort of (Raspberry Pi needed)

So I wasn't able to find a solution to do some presence detection with some BLE beacon I had lying here. Therefor I search the internet for a solution. I found one I was able to change a little (I like to do as less as possible) to make it call the Maker API app of HE.
For each beacon you have to make a virtual presence device, Add Maker API app and create an child of that for every beacon as well. After that you should have the ID of the Maker API app instance, the ID's of the Maker API child instances per beacon.
I use these: https://www.aliexpress.com/item/32453926532.html
Also I use a Raspberry Pi, doesn't really make a difference which version, as long as it has either a BLE adapter onboard or one in a USB port. I had a RPI3b+ doing nothing and a Logilink bluetooth dongle class 1. Amazon.com
For me this covers my whole house when I place the rpi in the center of it, near my HE hub actually.
On the RPI i installed the latest rapbian lite distribution, and followed the instructions of the original author of the script. Presence detection (Bluetooth 4.0 Low energy Beacon) - Domoticz
I changed the script to make the calls to the Maker API app of HE. The HE version of the script is:
HA/BLE at master ยท Frits1980/HA ยท GitHub
Be aware, the repeat mode of the original script will not work at the moment for the maker API, didn't see the use for it yet. Also I have to mention that this is not tested to work over an internet connection, it might work, but I only use it locally.

It will only push "arrive" and "departed" to the HE. Nothing fancy there. In the future I have the following plans to work on:

  1. test on RPI zero W
  2. make script to work with triangular positioning with multiple RPI's

If anybody wants to contribute, help, or just use it, go ahead.

4 Likes

How are you able to get a BLE to cover your whole house with a single AP? If I can get that kind of coverage (I've tested several popular and less well known tokens, and haven't found any where near that kind of coverage), I will be happy to contribute, minus the PY stuff :face_vomiting:. My solution is javascript and node.

Well I think it's all about my house. It's a brick wall house of 6x9meters, 3 stories high with wooden flooring with under floor heating. But it's not that big. The AP is on the ground floor about 30cm above the floor almost in the middle of the building. But my goal is to create a couple of pi zero W's (about 7) and put them on the corners of my house. That way I can map my house with the rssi of the tag on all possible locations from all different rpi's. After that it's just a matter of putting it all together to make local presence really work.

Did you try with a class 1 Bluetooth dongle?

I don't think I did. I wasn't aware of that designation. I've ordered the one you listed above, and the same token. Will test their strength, and the other tokens with the new dongle and see what comes. I'd be super happy if I could implement two or three APs and cover the house.

Well I don't know how big your house is, for class 1 bluetooth dongles the range should be 100 meter line of sight... And with my brick walls and other interference and so on I'm pretty satisfied with the 9 meters I'm getting. (sorry for the metric measurements, to lazy to convert at the moment).

I was actually trying to get everything to work with this script: GitHub - andrewjfreyer/monitor: Distributed advertisement-based BTLE presence detection reported via mqtt
Because in that script the whole multi instance (read multi rpi's) local presence is covered. It works with MQTT which i've already got anyways. But when I ran the script it gave me some errors. But since the author is replying again to the issues, I'm going to give that a go again and chat with the author about why it's not running.

You might want to edit the version your have on Github. It has the access token in your script.

image

1 Like

That was not very clear of me. Thanks for the heads up. Fortunately I'm only allowing local access to the endpoints.

1 Like

I figured as much but better to be safe than sorry. You shouldn't get punished for trying to help folks out and there are some real jerks out there. We all gotta look out for each other. :slight_smile:

1 Like

There are indeed always jokers who try. Again, thanks!

1 Like

Just for clarification, is this being proposed as a whole-home occupancy alternative, or can you pepper your house with these things to get true room-based occupancy? I have dreamt for ages that I could somehow track my phone or smartwatch in a passive manner from their perspective. Seems like a difficult task though. Most go for the passive beacon and active phone app like tasker/etc.

No, this does not track per room location. I will eventually be testing with other solutions to get room location. But I'm not ready yet (need a lot more RPI zero's) and haven't go the time anywhere soon.

I'm going to play around with a few pi I have laying around, and see what I can come up with. Highly interested in this stuff. Could build some simply wall-plug mounts for RPi0-based probes. I'm also pulling wireless device RSSI from my Asus router to help correlate location. I figure if I combine that with at least a few RPi tracking BT on mobile devices, I could get some decent room detection.

I wish the Asus AIMesh stuff worked worth a damn between my various-model Asus routers, because then I could probably have each node report the RSSI of each device and not fool with any of the RPi stuff at all.

Good luck. I've been looking in to using this code for room detection instead of the one I'm using now. GitHub - andrewjfreyer/monitor: Distributed advertisement-based BTLE presence detection reported via mqtt

This is perfect for me as I only need to detect exit/entry to enable/disable HSM for the family. I've got this type of beacon NRF51822 2V 3.3V Bluetooth 4.0 Wireless Module For iBeacon Base Station Intelligent Control System Beacon BLE Module 4MA W/ Case-in Electricity Generation from Home Improvement on AliExpress - 11.11_Double 11_Singles' Day on order and I'm hopeful it will work.

I just dug up some long forgotten trackr units and they seem to be recognised by the python test script. But I got stuck at interfacing these to the maker api (like how do I create the child apps?) and how to use the outputs to toggle HSM modes. Any help would be much appreciated!:grinning:

EDIT: I managed to get it all working in the end :smiley: using the Trackr seems to be fine although it does look like they need to be paired with the trackr app on a phone in the first instance otherwise they appear to timeout and stop transmitting until the front button is pressed. There is a small lag on entry though which I'll need to sort out to make sure HSM is off before I open the door. I'm also using a Pi 3 with onboard bluetooth.

Thanks frits!

Any luck getting this working? So far the NRF51822 beacons seem to work fine but now wanting to get more coverage around the house. The trackrs work well but have very limited ability to penetrate walls.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.