Bluetooth presence detection?

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
Oetsch
Normal user
Posts: 195
Joined: 13 Jul 2020, 12:10

Bluetooth presence detection?

#1 Post by Oetsch » 06 Jan 2022, 10:18

Hi
for presence detection I like to use bluetooth low energy scanning mechanism which can often be found with usage of ESP32.

Tried to find if this is supported by ESPEasy but didn´t find so far. Is there sth. known/tested?

Seems that there are different methods used. E.G. BLE scanning for iBeacons is based on identifying a UUID which can also be generated by a software on a smartphone like Beacon simulator (https://play.google.com/store/apps/deta ... l=de&gl=US).

Other method which is used is working based on the BLE MAC adress. For several devices I guess this cannot be used in our days because the MAC adress is changed automatically.

I´m interested in using ESPeasy for detection of smartphones, fitness watches and beacons to assure more reliable presence detection.

Is there any experience/information available what can be used within ESPEasy?

Thx!

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Bluetooth presence detection?

#2 Post by TD-er » 06 Jan 2022, 10:48

As of now I have not used Bluetooth for ESPEasy since there was way other stuff to work on.

I know about Bluetooth that on a higher level it does use "profiles".
Thus a device claims to support "recording audio", "playing audio" or "serial port" to name just a few of the very first Bluetooth standard.
This also means that you will always support only a subset of the bluetooth appliances out there.
Though the "serial" profile is probably very usable in ESPEasy context as it is also going to be used in the new upcoming standards "Matter" and "Threads", which will be very important in about 6 months for all kinds of IoT applications.

Scanning is also one nice feature to have, but modern Bluetooth devices do not respond to scanning probe packets unless they are told to. (e.g. by pressing long on the button of headphones)
So in order to scan for just any BLE packet and then looking at the MAC address is what remains.
But then we enter the next hurdle.
Bluetooth switches frequency roughly 1600x a second. (at least that was with the first few Bluetooth standards, not sure if that ever changed)
The 2 paired devices each agree on a frequency hopping pattern, to make sure they will not suffer a lot from interference from other devices.
This makes it hard to "scan" for devices as that frequency hopping makes it very likely you will miss it.
Thus the only way to "see" other Bluetooth devices is to constantly listen on a fixed frequency in some kind of "promiscuous mode" where you get the raw data packets.
And even then you will probably see new MAC addresses every now and then as modern devices switch MAC address every now and then to prevent tracking like this.
For the Covid tracking apps, the OS for Android and Apple devices even had to be adapted to let some special flagged apps ping using some fixed MAC address (or changing using a predictable pattern, not sure how they did it)

Maybe you can test with the Paxcounter project for ESP32 to see what is achievable?
I think that project also tried to count based on bluetooth. (it started using WiFi)
Since that project is also OpenSource (I also commited some fix for it in the past), we may be able to use some parts of it to port to ESPEasy.

User avatar
Ath
Normal user
Posts: 3418
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Bluetooth presence detection?

#3 Post by Ath » 06 Jan 2022, 10:51

I haven't investigated that myself yet either.

A quick Google search revealed this nice, easy and small example: https://www.instructables.com/ESP32-BLE ... -Detector/
/Ton (PayPal.me)

User avatar
Ath
Normal user
Posts: 3418
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Bluetooth presence detection?

#4 Post by Ath » 06 Jan 2022, 11:05

And an even more elaborate explanation and project: https://circuitdigest.com/microcontroll ... sing-esp32
/Ton (PayPal.me)

Oetsch
Normal user
Posts: 195
Joined: 13 Jul 2020, 12:10

Re: Bluetooth presence detection?

#5 Post by Oetsch » 06 Jan 2022, 11:13

Thx @TD-er and @Ath

Because of mentioned ongoing scanning cycles and just identifing a MAC adresse or UUID I understand that this might be big ressource effort for low level data information. Nevertheless there are devices like dedicated Beacons which are only made for the purpose of beeing detected. The semiconductors made by nordic semiconductors seems to be at a higher level with regard to battery life in comparison to the cheapest models available at Ali-Express and battery life is only only 1 month or so.

I´m aware that several projects are available but they are mostly based on "raw code skripts" which i personly do not really like prefering a standard and mantained solution like ESPEasy. In addition I will try to use a M5stack Atom lite as ESP32 scanner device because there is a housing, a RGB LED and a button already included. The LED and button is sth. which can be used very comfortably with ESPEasy for several perposes. This method of using additional sensors/devices seems much better to me in combination with ESPEasy (like i´ve done before) than manupulating the scripts available for BLE scanning like:

https://github.com/dollop80/ESP32-BLE-Scanner
https://esp32-server.de/mqtt-ble/
etc etc

I´m also asking because I like ESPEasy much more than other solutions where this can be found (chapter iBeacon):
https://tasmota.github.io/docs/Bluetooth/#features_1
or
https://esphome.io/components/binary_se ... sence.html


But if I understood right these purpose is not really implemented in ESPEasy and so it´s better for my purpose/project to make a most fitable solution out existing solutions. Right?

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Bluetooth presence detection?

#6 Post by TD-er » 06 Jan 2022, 11:33

More like, there currently is not BLE support in ESPEasy.
But if you could test to see if Paxcounter might work for your purpose, then we can look at that code to add support for scanning in ESPEasy.
It was more like advice to you to help understand what is available (and tested) to help pick what we can look into.

Just starting to code and see what problems we might find is probably not the best use of time :)

Oetsch
Normal user
Posts: 195
Joined: 13 Jul 2020, 12:10

Re: Bluetooth presence detection?

#7 Post by Oetsch » 06 Jan 2022, 11:40

Thx, yes I prefered to ask if sth. is available in ESPeasy before looking for other solutions. Please understand this as much appreciation for ESPEasy from me.
Hopefully end of this week the first hardware will arrive and I can start testing.
Because I haven´t heared before I will also try paxcounter to get some small first basic information :)

For implementation this guideline looks very informative to me and all different types of devices are mentioned so easiest way for me to start my journey :)
https://koen.vervloesem.eu/blog/connect ... n-esphome/

Post Reply

Who is online

Users browsing this forum: No registered users and 25 guests