Area/Room Presence Detection for Mobile Devices using ESP32-based BLE Beacons

How cool would it be if the BT Beacon stuff could be in the existing HA App, so it doesn’t require an additional app to be installed!

Have you looked at the method used here https://github.com/andrewjfreyer/monitor instead of requiring the beacon?

Ill take a look at this once im finished my current project :slight_smile:

I’d just like to say that I love this project - @st0nedB I fully agree with you that the cost/complexity of deploying raspberry pi zeros for Room Assistant is a significant hurdle that has also kept me away.

Like you, I already have a few ESP devices (a mix of 8266s and 32s) tracking other data around the house and it would be pretty simple to upgrade everything to 32s and deploy this solution.

Amazing, and thank you!

I’ve also read with interest the discussion regarding active/passive BLE and on-device vs off-device processing. Just to express my opinion, I also would prefer an off-device solution that doesn’t require an app to run, but that is just a bit of feedback. I am more than pleased with this solution and look forward to deploying it!

does yours work with apple watch?

i love the idea of using the bluetooth ring! I dont want to rely on carrying my phone around in order for automations to work, but a ring or smart watch is a great idea

This sounds very cool! Nice work!

Few questions:

  • Does the app work in the background on your phone?
  • Did you link to the project on GitHub already? Did I miss that? Or were you checking to see if the community was interested before sharing?

More questions id ask about ESP32s, but won’t ask them yet until I learn a bit more/figure out if this could work for me.

i would also like to test it

Amazing work @st0nedB thanks for sharing :slight_smile:

quick question, is the battery drain on the iphone bad? would you implement the app on android ?

thanks

This is something I’d be very interested in and happy to test! (just need to order a few ESP32’s)

If you don´t want to have an app for each OS (Android & iOS), go with the other direction, as @rsokolowski mentioned. Additionally, try listening for BLE signal of another device such a Fitness tracker e.g Xiaomi mi band (any version), that’s the way I do it and it works pretty well.

I have about 6 nanos and have been wanting to do just this in a 4bdr house. I see use cases for visually and hearing impaired users that may not have crossed your path. Would be glad to help with cross platform support too. Have you checked out Unity?

Hey everyone, thank you all so much for the replies, suggestions, and questions.
During weekdays I can’t find much time to post here, but I’ll do my best to provide appropriate answers.
First, to all who have expressed their willingness to help me test it on a broader audience, thank you :hugs:! I’m doing my best to set everything up as quickly as possible, please be patient. Workdays in Homeoffice are sometimes unexpectedly exhausting :wink:

Surely, passive scanning might work for most BLE devices (but I’m still not sure about iOS) and I looked at monitor (great project btw!). However, from what I understand, it works for presence detection, not room, and uses the RPi platform. Please correct me if I’m wrong.
In the end, passive is also a matter of perspective. In all wireless communication systems, some device is transmitting, another one is receiving. Both actions require power, nothing comes for free.
As minimalistic as I try to be, having an extra app is not a big hassle for me. It is designed to be in the background most of the time, makes collecting the training data easy, and consumes only some MB of disk space.

Yes, it does work in the background. I’m currently trying to improve the power consumption and pause the beacon measurements as often as possible.
Sorry, no GitHub link available, yet. But it’s planned. It should also help to assure all users, that the app is not doing something fishy in the background. As you assumed correctly, I first wanted to find out if the approach is even interesting for the community.

Please see above, I provided some debugging screenshots from Xcode to showcase the current progress. I hope it can be improved further. In some debugging sessions, the power consumption would drop too “low”, sometimes it won’t. According to my intuition, the new features are still a little buggy.

Maybe, but first I want to finish the iOS version. Any help in the development will be greatly appreciated, as I don’t own Android devices. That’s gonna make debugging hard :upside_down_face:.

Superb! I’d love to hear your use-cases and if it can help visually and hearing impaired users, all the better :sunglasses:!
Let’s get in touch and discuss it via PM, to not take it too far off-topic here.

Stay healthy everyone!

1 Like

No worries mate I can help in debugging :slight_smile:

hahah. I have a bluetooth thingy on my keys and a couple esp32 around the house to track me. As well as a useless automation that lets my phone know when I leave the house with out my keys. Which of course is too late as I am already locked out . . .

sounds very promising as it uses esphome which I already have around my appartment. Will have to wait for a android version tho. Will be following this thread.

This sounds really great. I’d like to try it out too.

Hey everyone,
after a bit of further development, the app now has reduced power consumption.
AFAIK it is not possible for iOS to wake up the app when the device is moved, so unfortunately it has to run in the background while it in the house/flat. To reduce power consumption, beacon measurements are only collected if the device is moved. To detect movement, the app monitors the devices’ gyroscope.
If the device battery goes below 30% and the device is not charging, the app is suspended. I plan to ease this constraint later, but for now, it should ensure that the battery is not drained to heavily by the app.
Here is a screenshot of how power consumption looks in Xcode when the device is resting.

Regarding the status, I am now reviewing the proper license, which allows me to publish it on Github and later also put in on the AppStore. If anyone already has experience with that, please get in touch. I’d appreciate any help on that matter.
In my mind, publishing it on GitHub would be the easiest way for others to try it out and provide feedback, but I am open to suggestions. If you have an idea regarding that, please let me know. Thanks in advance for any suggestions.

I can help test it out on Android too.

1 Like

Hey everybody,

progress has been made and the app is now available on GitHub.


There are some instructions, surely some are missing. Compiling with Xcode should be straightforward. Just open the *.xcworkspace file and build it for your device.
Surely, there are still some bugs left. If you find any or have suggestions for improvement, feel free to create an issue there.
Let me know what you think.

PS: Currently the Python scripts to train your own ML model are missing. I plan to add them as soon as possible, but it might take a few days. In the meantime, feel free to explore the required steps, create your setup and collect the first training samples. Scripts are available now. Instructions are updated, more detail will follow soon.

4 Likes

Hey @st0nedB,

Thanks for this project. Its actually exactly what I’m looking to implement.
I was able to get all the way to getting the app on my phone and running the “prediction” section. (completing all pre-requisites first) It unfortunately fails with “Invalid Model!”

I have opened an issue on the git project page. I hopefully have included all info’s there. If however you need more please let me know.

Any chance you could share your setup? It’s exactly what I am looking for. It would be a great help.