Send data from HA to ESP32 using BTHome protocol

Hi.
I’m evaluating BTHome project and I’ve understood how to transmit sensor data from ESP32 board (i.e. a value on a speficic pin) to Home Assistant.
Anyway I’m looking to do the same in the reverse direction.
In other words is it possible to send a value (i.e. ON or OFF, 0 or 1) from HA to ESP32 board using the BTHome protocol ?
I’m very confused about this.

Any idea?
Thanks in advance

Its very confusing isnt it!? It seems like BT traffic is only one way. Although I do understand your question, let me ask you a question back. Esphome basically fills that role and its an integration of HA the same as any other BT integration is that controls a light or whatever. If for example I create a BT switch in esphome, I then have a switch in HA to toggle that BT switch. I am essentially sending the BT service from HA.

Even if you created that BT switch in config.yaml its still going to use some BT integration to push out the service. So my question to you. Whats the difference?

1 Like

It appears that the bthome integration only supports bt sensors.

See BTHome - Home Assistant (Category: Sensor) and bthome.io (BTHome is an open standard for broadcasting sensor data and button presses over Bluetooth LE)

Have you seen or tried this? It looks interesting if it works.

@indeeed not sure how this helps? As I understand @m4biz wants to control an esp32 over Bluetooth.

Hi.
Thanks for your reply.
I’m very interested to your project but I haven’t understood well how it works and how may use it for my needs.
I.e., I’ve this BTHome sensor and I can see every two seconds voltage on pin 32 of an ESP32 board on the HA dashboard.

It broadcast this data:

{"name": "DIY-pin32_Voltage_1", "id": "E8:31:CD:CB:63:3E", "rssi": -49, "servicedatauuid": "fcd2", "servicedata": "413e7a32400600005bee118a"}

That being the case, how may I use your “integration” to write on an other pin (i.e. pin 24) of the same ESP32 board a simple value as 0 or 1 (On or OFF).
May you help me?
Thanks in advance

You’ll need to work out the relevant GATT and write to it.

What is this device?

Its not my integration… It was just something I found while searching and shared it here. I havnt even used it to be honest. To just send a 1/0 or On/Off, theres documentation for doing this already. You really have to familiarize yourself with them and always go there and use the search box before anything. The answers may already be there and you dont need to go do any Google-foo and waste your time. Setting up ble trackers, ble sensors, ble switch, ble text_sensor, etc etc. This stuff has been available and documented for a while.

Hi nickrout.

The BTHome device is an ESP32 board.

The code I’ve uploaded is that you can download from the official BTHome page:

GitHub - Chreece/BTHomeV2-ESP32-example: An BTHome v2 example with encryption for ESP32

Do you mean you want to turn something On/Off from a gpio? High/low 0v/3.3v?

Ok well that won’t work. Bthome is a sensor only system.

Ya, thats the conclusion I came to as well. I thought with so many clever people around, there might be some way to do it but, i found nada.

Ill tell you whats kind of irritating is there seem to be pushes by different people or groups on BT in this case. So, BThome for example it does sensors well but not much else. Then over here you’ve got HA and esphome adding BT support which doesnt do sensors well but does other things well outside of a handful of BT sensors. Now you have to pick which one you want to use on the esp32. It’s the same way with room presence detection. Espresence is still the best IMO but you lose general esphome use if you choose Espresence. I just wish people would get together and develop one software that will do all the things so we dont have to choose which functionality to use and alsp lose at the same time.

Hi Nick, I’m searching for some info about BT and bumped on this.
From the BTHome site:


Is this something different to what you’re saying?

This whole post was regarding bthome…

Hi Justin, what I wrote is also about BTHome.
What am I missing?

This whole thread is about using bthome… so, is the bthome link you posted it something different? Obviously its the exact same thing.

No that’s exactly what I am talking about.

Sorry, I don’t get it: :blush:

From bthome.io

BTHome is an open standard for broadcasting sensor data and button presses over Bluetooth LE

The Bthome integration can read button presses, because there is really no difference between reading a button press and e.g a temperature. Both are really sensors, one senses a button press, the other senses a temperature.

1 Like