Esphome Bluetooth madness

Hi. I had HA running on an old Asus nic, a new usb bluetooth 5 attached and integrated.
I had esphome and few esp32 mini c3 boards, pir sensors, etc. In my EspHome I have some projects that use a mini esp32 c3 board and a cheap PIR sensor as a motion sensor, very useful in various automations. It communicate with HA over wifi and it work just fine. But some of this devices run on battery and wifi is energy hungry. I’d like to switch the communication over bluetooth (BLE) but I have no clue how to do it. I’m not an expert in esphome but neither a newbie. I found all the documentation (about bluetooth in general) on esphome VERY CONFUSING !
Anyone have a piece of code that can put me on the right path ?

1 Like

Not supported by esphome to communicate between esphome and ha.

This is the one of the completely avoidable problems you get to win if you choose batteries to power devices that should have and could have been plugged into mains power from the start.

1 Like

Really ? That a big missing piece for esphome, imho. What about communicate with ha throw bluetooth proxy ? How should I implement the code ? A simple example will be appreciated
.

All your questions will be answered here Grasshopper!

Your really committed to using those silly batteries for a proxy and pir aren’t you?

Think im gonna throw a bag of popcorn in the microwave and watch this show!

I’m not agree with you. There’s a lot of projects using battery, take a look on web. You just avoid the problem.

Look, I did’t ask for your opinion if using battery is or is not a good idea. I don’t care about it. I just ask far a snap of code for a bluetooth connection. Did you have it ? Or did you have something constructive to say ? If so, you’re welcome. If not … enjoy your popcorn.

1 Like

I’ve been facing the same issue trying to use BLE with ESPHome to communicate sensor data from an ESP32 to Home Assistant. After trying several approaches, I found that BLE communication is currently not well-supported in ESPHome for this use case. Here’s a summary of what I’ve tried:

1. ESP32 as a BLE Server:

I tried setting up the ESP32 as a BLE GATT server to transmit sensor data to a Raspberry Pi acting as a BLE client. Unfortunately, the support for this in ESPHome is quite limited and didn’t work as expected.

2. BLE Advertising:

I also explored using BLE advertising to broadcast sensor data, but ESPHome doesn’t seem to support esp32_ble_advertiser, which made this approach a dead end.

3. MQTT over Wi-Fi:

Given the challenges with BLE, I switched to using MQTT over Wi-Fi, which works reliably for sending sensor data to Home Assistant. Here’s a snippet of the configuration that worked for me:

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

mqtt:
  broker: !secret mqtt_broker
  username: !secret mqtt_username
  password: !secret mqtt_password

sensor:
  - platform: bme680
    address: 0x77
    temperature:
      name: "BME680 Temperature"
      state_topic: "esp32/sensors/temperature"
    pressure:
      name: "BME680 Pressure"
      state_topic: "esp32/sensors/pressure"
    humidity:
      name: "BME680 Humidity"
      state_topic: "esp32/sensors/humidity"
    gas_resistance:
      name: "BME680 Gas Resistance"
      state_topic: "esp32/sensors/gas_resistance"
    update_interval: 60s

Conclusion:

For those looking to use BLE with ESPHome, it’s currently not a straightforward path. The most stable alternative I found is to use MQTT over Wi-Fi, even though it might not be as energy-efficient as BLE. I hope ESPHome will improve BLE support in the future.

If anyone has managed to get BLE working or has other suggestions, I’d love to hear from you.

Yes that is how esphome is supposed to work, over wifi using MQTT or the esphome API.

Thank you.
The only “elegant” way I found to communicate with HA throw bluetooth is using Arduino and BTHome.

And how is bthome communicating with HA?

Assuming you:

  • Have home assistant bluetooth configured (and BLE supported)
  • Upload from arduino the code

The HA will automatically discover it, like any other compatible bluetooth device.

Bthome is just an library (a code snippet) added to arduino code that make easy implementing bluetooth.

1 Like