ESP32 based BLE tracking for mqtt_room

Hi ptrsnja,

Being now happy bubbles no more supported/sold I was wondering why someone (with propor skills :slight_smile: ) does not adapt their firmware to esp32 (happy bubbles is based on esp8266)

From a logical point of view it should be much straightforward isn’t it?

I know this is in development but, will this work with iPhones? I can see that the mac address and uuid are changing randomly.

You’ll need to use an app to broadcast a beacon from your iPhone. If you can do that, you can enter the beacon UUID (without any dashes) into your mqtt_room sensor, and it should work properly. That’s how I’m tracking my android devices.

Which android app do you use?

Thanks
Randy

I use Beacon Simulator on my OnePlus 5 (although I can’t get it to persist reliably), and on my old Nexus 5 I’m using an app called Beacon Toy. I can’t seem to find it in the play store any more, however.

I’ve also tried Beacon Locate but couldn’t manage to get it to broadcast in the background.

1 Like

Seems like you can download the apk for beacon toy
https://apkpure.com/beacon-toy/com.uriio/versions

Esp32 installed, do not know how to configure the IOS phone.

@eric3616191 This is a solution to track iBeacons locally, not iPhones. Unfortunately, Apple does not allow iOS devices to broadcast beacons in the background. You’ll need to use another solution to track your iPhone, maybe owntracks.

I’m looking at configuring the ESP32 to broadcast a beacon packet as well as detect other beacons. This may enable you to use the ESP32 transceivers to inform owntracks of your room (this is not yet implemented).

How to configure Android mobile phone?

What Android app is installed?

Thank you!

hi ptrsnja,

is it compatible with happy bubble presence server?
shouldn’t be too difficult reading here:
https://www.happybubbles.tech/presence/detector

just needed to publish rigth values on MQTT

@mspinolo It would certainly be possible to use this with the Happy Bubbles server, but I can’t seem to find the spec for what messages the server expects to receive from the sensor nodes. It’s possible that @happybubbles might be able to provide more information, but I’m not clear that using the server would improve things in any way as compared to using the standard mqtt_room component as it’s currently designed.

As an update, I’m still working on addressing the watchdog timeout problem. It appears to be a widespread issue that affects ESP32 projects using the Arduino framework. I’ve tried a few things, and I’ve managed to improve stability, but it still crashes after a random (and now very long) period of time.

I’m also waiting on additional boards for development, but Canada Post has gone on strike, so progress is going to be delayed.

Maybe we should share the results of our tests depending on the board on a spreadsheet or an equivalent

@ptrsnja : you can find information at the link above, i will report here for completeness (hoping this is what you are looking for as I am really far from being an expert)

In terms of advantage it will be for people (like me obviously :slight_smile: ) who already have some happy bubbles around the house and would like just to add more sensors on the same system

Happy Bubbles will publish all advertisments it sees to the MQTT topic:

happy-bubbles/ble/<the-hostname>/raw/<the-bluetooth-MAC-address>

with a payload like:

{ "hostname": "living-room", "mac": "dd6ed85b7a80", "rssi": -94, "is_scan_response": "0", "type": "3", "data": "0201061aff4c000215e2c56db5dffb48d2b060d0f5a71096e000680068c5" }

@mspinolo The information you referenced is what the Happy Bubbles server sends to Home Assistant. What I need to know is what the sensor nodes send to the Happy Bubbles server (that is, one step earlier in the chain). I couldn’t uncover that information on the site, and I’ve not tried to parse the source code for that project, as it’s written in a language I don’t know.

If you’re able, you could use a simple mqtt client to subscribe to the happy bubbles topic and paste the results here. It won’t provide the full picture, but it would be a good start

@ptrsnja sorry for that I think it just shows the not much in depth understanding I have :slight_smile:

I did a little search though and found this:
Link
Where apparently someone else implemented an esp32 based node for happy bubble presence server.

As far as I understood you should find needed information here: Link

Is there any chance support could be added to non-paired devices without emulating a beacon, similar to what Monitor does?

Hello, i got the same questions as areks. Why does the ESP32 not implement the direct lookup of a unpaired device as the monitor does? As far as i can see it actually uses the command “hcitool name MAC” to identify if a device is present. How can i use this mode with the ESP32, is there any description on how to use this name lookup?

I will not be implementing the name lookup as it is implemented in Monitor, as it requires knowing the bluetooth MAC of the device (not as it is reported in the advertised packet). There is no hcitool for the ESP32 environment. Because it is not a full-fledged operating system, the resources available are much more limited. As this is not a use-case I am personally able to test, I will not develop for it.

I’m still working on fixing a disruptive watchdog timer issue that affects all Arduino-based ESP32 projects (as far as I can tell). My time has thus far been spent going down several roads that looked promising, but the bug is still lurking.

1 Like

I understand that you will not implement it. I would be able to implement it, if i knew which function i need to look at to do the actual name lookup with the functions that the ESP-IDF bluetooth API offers. Are you aware of any example code that can run on an arduino that is able to read the bluetooth device name by looking up the mac address? I tried to do it with the function “esp_ble_gattc_open” from the gatt client example but it doesnt work. I also tried to do it via bluetooth inquiry but these ways cannot read the device name by bluetooth mac.

1 Like

@kero I appreciate the interest. I’ve not had a chance to dig deeper into the SDK beyond what’s provided in Kolban’s example code. Hopefully once I have fixed the issue of watchdog timer resets, I can help point you in the right direction (if you’re still interested).

@1technophile I understand the bug to be related to BLE/WiFi coexistence. Specifically, if the scan callback does not yield to the WiFi, it will crash. I have had some success with modifying the interval and window parameters of the bluetooth scan, as well as using an asynchronous MQTT library. If this does not prove sufficient, I will have to look a re-writing the callbacks to use a queuing system. I’ve been referencing this site and section 5.3.2 of this document.