I have set up an ESP32-c3 Bluetooth Proxy for a Mi ble thermometer (and I have a few other BLE sensors that I haven’t managed to set up yet).
The proxy config can be found here.
Be sure to modify the variables to match whatever you want to do. I’m using static IPs because auto discovery is unreliable (hostname.iot.internal
).
You’ll also need to add the !secret
variables into the secrets.yaml
file.
Note that there’s an issue with Bluetooth and WiFi on single cores (i.e.: the ESP locks up as it can’t do both at boot). The workaround is in that config file.
Use on single-core chips
On dual-core devices the WiFi component runs on core 1, while this component runs on core 0. When using this component on single core chips such as the ESP32-C3 both WiFi and ble_tracker must run on the same core, and this has been known to cause issues when connecting to WiFi. A work-around for this is to enable the tracker only while the native API is connected. The following config will achieve this:
Esphomeesp32_ble_tracker: scan_parameters: continuous: false api: encryption: key: !secret encryption_key on_client_connected: - esp32_ble_tracker.start_scan: continuous: true on_client_disconnected: - esp32_ble_tracker.stop_scan:
To flash the Mi thermometer, use this flasher and the firmware from here.
Example output of the log (from Esphome in Home Assistant directly, but can be seen from the web interface as well):
You can then add the proxy (and the entities) in Home Assistant. It should update every couple of minutes (the Mi device updates every 5 or so minutes, the Proxy scans every channel every 3-ish minutes).
In the example above, I (at the time of writing) only have one Bluetooth sensor, but it should be quite trivial to add more. The hardest part is finding the right MAC address of the sensors… 🙂
Leave a Reply…