Presence detection - ESP32 Bluetooth Classic scanner

Here is a little interesting project if you are looking for presence detection to be used in your home automation & security system. Myself, I have since years been using Andrew Freyer's Monitor project.
How I am using it is described here: Use Bluetooth to scan for devices as a presence detector? - #15 by xx_Nexus_xx

This has worked so good & reliable, I was actually not looking for a replacement, but when I found a new variant, said to be a port of Andrew's work, now possible to run on an ESP32, I could not resist at least trying it

Even better, it is a port shared by RoboMagus that works with ESPHome!! (If you haven't tried ESPHome yet, well it is a simple way of using ESP devices for all kind of tasks, I say it is a "more or less no-coding" environment to program ESP devices)
https://esphome.io/guides/installing_esphome

The component shared by RoboMagus is not yet merged with the official ESPHome release so some extra simple "things" needs be taken care of, i.e. importing it from github, see the example .yaml below

First thing I recommend you to do is to install or update ESPHome to latest version. I have ESPHome installed in both Windows, Linux and MacOS. Currently I use MacOS most of the time but the others are also working fine. And you need to have python3 installed, yes

New installations, run in command prompt/terminal: pip3 install esphome
Update existinhg: pip3 install esphome -U

Then verify your installation: esphome version

With ESPHome you define your projects functionallity and features in a simple way with a .yaml configuratíon file. So, if you try the one I have attached below, you first check that it is correct from syntax point of view: esphome config btclassic_example.yaml

After you have updated the configuration file with your own access point's ssid, password, prefered ip addresses for the device, your mqtt broker and data about your phone to scan (name and mac address etc), you can go ahead and upload it to your ESP32 device: esphome run btclassic_example.yaml

If everything works as expected, your ESP32 should now start to scan, looking for your configured phones and devices

What is great to see, it recognizes my iPhone correctly when it is in or out of reach. I have not tested the distance it can cover but it is a great concept since you can now have multiple cheap ESP32 devices distributed around to cover the whole area of interest

To integrate with Node-RED via MQTT (what else??) a simple flow like below can be used as a starting point. Number of use cases are just limited by lack of fantasy

Enjoy :santa:

Please change extension from .txt to .yaml after download
btclassic_example.txt (1.9 KB)

6 Likes

Well documented :+1: :+1: I'm using the same approach in meanwhile as well (sorry, had no time to document) ... and I can confirm it works reliable.

I have positioned one ESP32 in every room and can easily detect a phone (or any bluetooth device) moving in my house.

Question: Has anybody use any of these bluetooth trackers which can be found at Aliexpress? .. Any feedback is welcome

Comment: I'm not using the ESPHome ecosystem, but only the ESP32 module with MQTT functionality and integration into Node-Red

have fun with this project

well done @krambriw (mach weiter so :smiley: )

1 Like

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