Presence Detection using Bluetooth / RFID

Hi,

I’m working on my presence detection rules and currently have things rolling along quite nicely with but presence detection for me and my wife via owntracks and hping3, thanks to the excellent tutorials on here but am looking to expand this to include guests, (parents, cleaner etc)…

Everyone has different phones and I don’t want to have to keep up with them changing phones etc and I can’t ask them to install an app to track them, (not sure the cleaner would be interested for a start!). Plus not everyone in the house will be on my wifi, (cleaner), so I can’t use that for detection.

I also don’t like the idea of the generic motion detected / door opened etc = someone at home as that might not be someone I want in the house.

So, I’m rolling down the idea of giving people key fobs. Everyone that I want in the house will have a set of keys so a fob on there isn’t too much of an issue to them. I’m preferring Bluetooth over RFID as I really just want things to happen without user intervention - ie having to tap the fob somewhere on entry as in RFID.

I’ve trawled the community forums and seen lots of attempts and plans to do this but nothing concrete so before I go gung ho into this, does anyone have any experience in trying and reasons not to do it / experienced problems along the way.

I’ve got a RaspPi 3 so it has it’s own bluetooth and I’ve found these on ebay which should do the job

and then will add the Bluetooth binding and go from there, sure there will be a little bit of setting up, (I’ve obviously simplified the process here for ease of reading) and controlling but the principle seems to easy and makes me wonder why it hasn’t already been done!

I’m hoping that a tag will remove all the issues people seem to be having with different mobiles as it should just be a ‘dumb’ device and all I’m looking for is a fob id and present / not present and then I can get OH to do the rest.

It has been done, but using the 3rd Party Bluetooth. The Main BT binding is terrible.

Ah, so it’s the Bluetooth binding that is the barrier…

I’m guessing it’s this thread you are referring to?

I’ll go and lend my support to it, thanks…

Yep and you can use ~$1 BT Keytags

Great, just reading through the docs and it seems they have tested it on some tags I found on aliexpress earlier today so I’ll take a punt and order a handful and get testing when they arrive…

reelyActive Smart Spaces Revisited might be useful for you. With a fob you don’t have the problem with phones spoofing their BT addresses.

If you are running on an RPi 3, I’ve found that the on board BT interferes with the on board WiFi so you might not want to run this detection on the same RPi as OH unless that RPi is wired or you have a BT or WiFi dongle instead of the on board ones. If you are not running OH on an RPi 3 then no problem with the BT bindings.

1 Like

Hi,

Yes, I saw the various posts about reelyActive and it seemed overkill in set up and implementation than what I need it for so was hoping to create an easier way.

I am on RPi3 but the connection is wired and I was wondering if a dongle was the way to go or not but was going to play around with that once I worked out the best way to get the Bluetooth working.

Thanks for the heads up on the potential issues.

Without the benefit of a tutorial to follow I had reelyActive up and running in about two hours. With the tutorials posted to this forum I think you can have it running in 30 minutes at the most.

I think you either under estimate your skills or overestimate mine!

I’ll have a closer look at rA in the morning and see if I can make more sense of it. If it’s a relatively easy install then it’s worth a try before I go and mess around with some undocumented Bluetooth options…

I have been using ESP32 boards (£6 each) around the house listening for the key fob BLE signals, these are then reported to OH via MQTT.

I added a rule to determine the location of the key fob but this is similar to the rA rule.

A few things to be aware of:

  • Don’t register the key fob with OH as it will send an alarm when out of range.
  • The key fobs have a button on the outside and this gets knocked and turns off easily.
  • The key fob battery compartment can come loose.
  • The fob may be picked up in multiple rooms so you need to pick the highest signal.
  • Batteries go flat in a few months so keep a few spare.
  • Use the expire binding so that OH knows the fob is out of range.
  • There is a delay between entering the room and the fob being detected (5s to 2mins) although clicking the button on the fob sends a signal immediately.

I also use the iphone binding for location and combine this with the fob data so you know when you are in the area and then in a room, this is a good check and I also can check who left their keys at home (iphone location >100m away from home but fob in a room).

I have linked this to the Alexa binding for music when someone arrives home, welcome to each room and photos change on the screens (Echo show and spot) specific to each fob preference. I plan to add a drop down menu in OH for easy selection of preferences for each fob.

The ESP32 boards can be linked to multiple sensors in the room and also report this back to OH. I have temperature and humidity running (if >40C there may be a fire in the room). This could also be door/window or light sensors.

Hi
are you able to detect iphones? apple watch ?

with the 3rd party BT this is not possible, so i want and bought Nut Mini
its working great but must be on me

What software are you running on the ESP32?

Hi Gad_Ofir,
the ESP32 software detects the Bluetooth from the iPhone but the iPhone changes the mac address for Bluetooth all the time so cant be used to detect a specific phone.
With the iCloud binding it shows the location of iPhone and Apple watch but the accuracy is within 100m so not useful for room detection but it can be used to detect when you are home.

If you want to have presence detection without a key fob there is a project for face detection ESP32 cam but I am not sure how to integrate it with OH.

1 Like

Hi Michael,
I use the MQTT Gateway for the ESP32
https://github.com/1technophile/OpenMQTTGateway/wiki/Module-Overview-ESP32

Dear Community,

I just stumbled upon OpenHAB while searching for BLE presence detection. The whole framework could be valuable to me if the accuracy is high enough.

Can anyone please share on this point? Here are some questions I’ve noted:

  • What is the accuracy we can expect with Tx = smartphone ? With Tx = a Bluetooth key fob? I mean accuracy = 1 - (wrong detections / total detections).
  • What is the minimum number of receivers I need to install in each room?
  • What the minimum distance for detection? What I’d like : 1m before the doorstep = KO (out of the room), 1m past the doorstep = OK (in the room).
  • How can be sure the TX device is in Room_A and not the neighbour Room_B?

This looks like an asset tracking system with high resolutionn but I don’t know if OH could be tweaked into such a system…

Thanks in advance for your feedbacks!

You might ask this on the reelyActive site which is a special purpose built system for doing this sort of thing. See reelyActive Smart Spaces Revisited for how to integrate it with OH and some of the experiences and limitations with the system.

In general, the biggest problem with a smart phone is many of them spoof their MAC address so that you can see that and iPhone (for example) is present, but not a specific iPhone is present.

Many thanks Rich fro the quick answer! I’ll dig a bit on reelyActive website!

By the way, here’s a bit of context: the project will operate in schools (elementary to high schools) and will aim at automatically calling roll for the students. I don’t really mind detecting smartphones, even if teachers will probably have one, as the students will be equipped with some kind of wearable for other reasons. These wearables will support BLE communication, so I’ll request the manufacturer to add the proper beacon/advertising function to provide for presence detection.

Thanks again for your help!

That would be a good option for me.
However, I am not experienced with an ESP32, so I am wondering if there is a “ready to use” BT reader to put into wall socket to detect BT devices outside the door?

You can use an M5stickC or M5 atom with a plug2usb adapter.
Load Openmqttgateway into them and you will detect the ble devices nearby added to the weather station reading (if you have)

Thank you!
I will look into that!