Where does the value come from?
I tried using ble_server.characteristic.set_value, but it didn’t work.
I’m not sure if esp32_ble_server actually updates the value or if I’m misunderstanding how it works.
I also couldn’t find many examples of ESPHome using the newer BLE implementation — it seems pretty scarce.
Unfortunately, none of us can help you find out why it didn’t work previously or what it would take to make it work because, you’ve provided us with 0% details, 0% code, 0% log outputs and etc. Kind of hard to offer someone suggestions for the problem they wont publish for us to look at.
You really need to slow down and go back to Start. Read the documentation, try to replicate and modify the simplest things with BT etc. Using the BT for Esphome is a bit complicated IMO and it wont work if you take shortcuts or you’re just guessing and hoping to make something work. Using Esphome BT has beat down many good men over the years and there’s just no easy stuff in here that people can use a copy/paste job from online and then move on. Unfortunately it just takes working, trial and error, and time practicing.
IMO the reason your not finding answers to your questions or examples of the Integrations is because you never read through the Esphome documentation or you went there and only looked at it briefly, otherwise you would have saw the answers to your questions and lots of examples.
I would suggest that you determine why you’re wanting to use BT for this task and then determine if BT is your only option for achieving whatever it is that your doing.
You likely may not even need to be using this BT method and there may be far better choices but, you didnt want anyone to know much about your project because its Top Secret perhaps?
I’ve been working on this for a while, but luckily I finally had some time to figure it out.
Now I understand how it works — I think earlier I just had a mistake in the lambda part.
Enabling read: true allows reading data in two different ways:
However, both options cannot be used at the same time.
Right now, I’m programming a light switch. I tested it with the nRF Connect app on my phone, and so far it works.
Next, I’ll program another ESP32 as a client with a button.
Here’s my current server code:
Hi,
I managed to implement BLE communication between two devices with light state synchronization. You might wonder why the system is designed this way. The bedside light has its own button, but there is no Wi-Fi coverage in that area, so it cannot be controlled directly via Home Assistant. Near the door, there are two buttons controlling both the bedside light and the main room light, and this device has Wi-Fi connectivity.
Below, I’m sharing a part of the BLE code – both the server and client implementation. The button handling and other logic are not included here, as they are quite straightforward to implement.