ESPHome does not discover phone using BLE

I have just configured an ESP32 using ESPHome with the following configuration

esphome:
name: bluetooth
platform: ESP32
board: esp32doit-devkit-v1

wifi:
ssid: “m-kbridge”
password: “…”

Enable fallback hotspot (captive portal) in case wifi connection fails

ap:
ssid: “Bluetooth Fallback Hotspot”
password: “…”

captive_portal:

Enable logging

logger:

Enable Home Assistant API

api:
password: “…”

ota:
password: “…”

esp32_ble_tracker:

binary_sensor:

  • platform: ble_presence
    mac_address: 58:B1:0F:08:5E:77
    name: “Mikes phone”

When I bring my Samsung S9 into proximity (or turn off & on bluetooth, I do not get any discovery of the BLE device.

INFO Reading configuration /config/esphome/bluetooth.yaml…
INFO Starting log output from bluetooth.local using esphome API
INFO Connecting to bluetooth.local:6053 (192.168.0.21)
INFO Successfully connected to bluetooth.local
[23:22:55][I][app:100]: ESPHome version 1.14.2 compiled on Nov 14 2019, 17:24:59
[23:22:55][C][wifi:409]: WiFi:
[23:22:55][C][wifi:277]: SSID: [redacted]
[23:22:55][C][wifi:278]: IP Address: 192.168.0.21
[23:22:55][C][wifi:280]: BSSID: [redacted]
[23:22:55][C][wifi:281]: Hostname: ‘bluetooth’
[23:22:55][C][wifi:285]: Signal strength: -47 dB ▂▄▆█
[23:22:55][C][wifi:289]: Channel: 6
[23:22:55][C][wifi:290]: Subnet: 255.255.255.0
[23:22:55][C][wifi:291]: Gateway: 192.168.0.1
[23:22:55][C][wifi:292]: DNS1: 198.142.152.164
[23:22:55][C][wifi:293]: DNS2: 198.142.152.165
[23:22:55][C][logger:175]: Logger:
[23:22:55][C][logger:176]: Level: DEBUG
[23:22:55][C][logger:177]: Log Baud Rate: 115200
[23:22:55][C][logger:178]: Hardware UART: UART0
[23:22:55][C][esp32_ble_tracker:442]: BLE Tracker:
[23:22:55][C][esp32_ble_tracker:443]: Scan Duration: 300 s
[23:22:55][C][esp32_ble_tracker:444]: Scan Interval: 512 ms
[23:22:55][C][esp32_ble_tracker:445]: Scan Window: 320 ms
[23:22:55][C][esp32_ble_tracker:446]: Scan Type: ACTIVE
[23:22:55][C][ble_presence:011]: BLE Presence ‘Mikes phone’
[23:22:55][C][captive_portal:169]: Captive Portal:
[23:22:55][C][ota:029]: Over-The-Air Updates:
[23:22:55][C][ota:030]: Address: bluetooth.local:3232
[23:22:55][C][ota:032]: Using Password.
[23:22:55][C][api:095]: API Server:
[23:22:55][C][api:096]: Address: bluetooth.local:6053
[23:23:24][D][esp32_ble_tracker:148]: Starting scan…
[23:28:24][D][esp32_ble_tracker:148]: Starting scan…
[23:33:24][D][esp32_ble_tracker:148]: Starting scan…
[23:38:24][D][esp32_ble_tracker:148]: Starting scan…
[23:43:24][D][esp32_ble_tracker:148]: Starting scan…
[23:48:24][D][esp32_ble_tracker:148]: Starting scan…
[23:53:24][D][esp32_ble_tracker:148]: Starting scan…

Can somebody please help identify where I am going wrong.

Mike Paneth
Melbourne Australia

I had the same issue… From what I understand:

Android does not send information using ble by default. You need an app to simulate ble beacon.

Something like

Thanks
I tried the app but unfortunately it generates a random mac address, so it cannot be used for detection.

Is there an app which uses the phones bluetooth mac address as a fixed address?

You should be able to use an app like Beacon Scope to broadcast a constant address. I use it with my ESP32 MQTT Room project to broadcast a simulated iBeacon. You’ll need to restart the app occasionally, but it does a decent job.

Thanks for the suggestion but Beacon Scope also randomises the MAC address.

From further reading it seems that this may be by design to reduce the hackability of the connection.

It looks like UUID id the constant factor in the equation.

Apologies, I haven’t used the ESPHome tracker, as I use my project instead. If you’re not using the ESP32 for other functionality and just want a BLE scanner, you can check it out here:

I’ve been hoping for a solution to the ESPHome Bluetooth tracking as well.

I don’t understand something about this though.
Why can HA track my phone without pairing?

Can you explain to me what is different about the Bluetooth that HA uses in it’s Bluetooth tracking?

I don’t have an answer for that. Perhaps someone with more experience using the ESPHome component can offer some insight.

My project is aimed at room-level presence detection, where the native bluetooth tracker in home assistant isn’t looking at BLE advertisements, but instead is using the older bluetooth protocol.

Probably the best introduction is the first post in the monitor thread. [monitor] Reliable, Multi-User, Distributed Bluetooth Occupancy/Presence Detection

1 Like

i am also searching for a bluetooth presence detection setup using esp32 and esphome , so i was also trying if esphome ble can search my smartphones , but failed ,

is there any other monitor like method with esp32 and esphome with phones inbuilt bluetooth ?

and there is a feature request in esphome too .

1 Like

can it support all the smartphones ?

It only supports devices that can broadcast BLE advertisements. Currently, it’s been tested with Android phones running an app such as Beacon Simulator to advertise as an iBeacon. Unfortunately iPhones don’t allow broadcasting in the background, so it won’t track your iPhone. I do not own an iPhone so cannot test/build for it.

I am looking around at presence and room presence detection at the moment.
I have a number of ESP32 dev boards running ESPHome controlling lights and I was hoping to add a few lines to use the same boards for BLE tracking.
Unfortunately, as I use these boards for other things, that eliminates ESP32-mqtt-room as an option.
Has anyone managed to get ESPHome BLE / beacon tracking to work properly?
I know I could make ESPHome simulate an iBeacon and work in reverse, but that doesn’t suit my purpose as I want to also track my pet by having a tag around her neck so I know what room she’s in :slight_smile:

1 Like

+1
I am also interested in a solution.
As a temporary solution, I installed radar pirs on the esp (HW-MS03).

this feature is built into companion app now, disabled by default
settings > companion app > sensors > bluetooth Sensors > BLE Transmitter


2 Likes