logo elektroda
logo elektroda
X
logo elektroda

OpenESP32-C3 Bluetooth testing for OpenBeken as BT Coordinator

DeDaMrAz 1410 32
Best answers

Can OpenBeken be turned into a Bluetooth proxy/coordinator on ESP32-C3 or similar devices, and what is the practical implementation path?

Yes, but the workable result in this thread is a scan-only Bluetooth proxy, not a full coordinator with active connections. The implementation was ported to OpenBK7231T as a BT proxy with passive and active scan support, exposed through `BLEScan` and `BLEScanMode`, and the BT scan API was extended with an `active` flag in `scan_param` so `GAPM_SCAN_PROP_ACTIVE_1M_BIT` can be enabled when needed [#21850611][#21849822] Advertisement forwarding was changed to send data to Home Assistant almost immediately using a non-blocking socket plus a short delay, instead of batching 10 ads every 40 seconds, which reduced drops and improved visibility of devices [#21849822][#21847558] The working initialization flow became `BTInit` → `BTSetWindowInterval [window] [interval]` → `BTSetScanMode [isActive]` → `BTStartScan` → `startDriver ESPHomeAPI`, and the proxy can expose itself to HA when BTInit is used [#21852129] ESP support was disabled for now because it needs more rewriting, while the proxy was enabled by default on RTL8720D and in btproxy variants on RTL87X0C, BK7238, and BK7231N_ALT [#21850947] Later testing showed BK7238 and LN882H can receive coded-channel advertisements, while RTL8720C/D cannot; the code also bypassed nanopb and mapped PSRAM into heap when present to handle larger advertisements [#21857230]
Generated by the language model.
ADVERTISEMENT
  • #31 21852129
    insmod
    Level 31  
    Posts: 1353
    Help: 160
    Rate: 425
    Cleaned up a little and added LN882H support (rssi is bugged, enabling powersave 2 will break bt until reboot)

    Current initialization sequence
    BTInit
    BTSetWindowInterval [window ms] [interval ms] (optional)
    BTSetScanMode [isActive] (optional)
    BTStartScan
    startDriver ESPHomeAPI

    ESPHomeAPI can be started without BTInit, but then it won't expose itself as proxy.

    @divadiow do you wish to check it?
    Just add the esphome device by ip in HA.
  • ADVERTISEMENT
  • Helpful post
    #32 21852673
    divadiow
    Level 38  
    Posts: 4859
    Help: 424
    Rate: 860
    something's happening. Tuya TH05 nearby
    Network graph with central node “OpenLN882H…” linked to “Home Assistant” and many MAC-address nodes
    Screenshot of OpenLN882H device page showing Bluetooth info and empty Controls and Logbook sections
    ESPHome dashboard screenshot showing LN882H device info with Controls, Connected devices, and Logbook panels

    Code: Text
    Log in, to see the code
  • #33 21857230
    insmod
    Level 31  
    Posts: 1353
    Help: 160
    Rate: 425
    Found my TLSR sensor. Flashed pvvx ATC firmware and enabled long range.
    BK7238 and LN882H can get advertisements on coded channels, RTL8720C/D can't.
    BK7231N most likely can too.

    Made it so advertisements are passed immediately to HA, because i got some advs on BK7238 with 96 bytes length.
    In esphome protocol - the limit is 62 bytes, but i saw no warnings in HA.
    This also frees some heap reserved for buffer.

    Still no nanopb.

    Enabled PSRAM on RTL8720D in a way that would work on chips without PSRAM. Mapped into heap If it's present.

Topic summary

✨ The discussion centers on Bluetooth testing using the ESP32-C3 as a Bluetooth coordinator for the OpenBeken project. The implementation is based on the bluedroid stack, chosen for compatibility with ESPHome and ease of integration. Challenges include differences in ESP-IDF versions, Bluetooth 4.2 versus Bluetooth 5 and BLE support, and build environment issues such as parsing errors in partitions.csv and Docker build bugs. A working solution has been developed and is available on a GitHub fork, though the code requires cleanup. The conversation also covers coexistence settings between WiFi and Bluetooth, with coexistence ratios like 40% WiFi and 60% Bluetooth discussed. Binary sizes for the RTL8720D platform are noted, with builds around 1053kb without Berry and 1157kb with it. Build system limitations for the RTL8720D, such as the inability to use parallel make (-j), are mentioned. There is interest in adapting the ESPHome API as an alternative to MQTT for communication. Overall, the thread highlights practical issues and solutions in integrating Bluetooth proxy functionality on ESP32-C3 and RTL8720D platforms within the OpenBeken ecosystem.
Generated by the language model.

FAQ

TL;DR: Early ESP32‑C3 BT Proxy for OpenBeken boots on ESP‑IDF v5.5.2 with 4 MB flash; “Proof of concept is working…”. It targets coordinator‑style BLE relaying, but author paused pending real use cases. [Elektroda, DeDaMrAz, post #21846290]

Why it matters: Makers testing BLE gateways on low‑cost ESP32‑C3/RTL8720D need clear build notes, limits, and quick fixes.

Quick Facts

Quick Facts

What is OpenBeken?

OpenBeken is a lightweight open-source firmware for smart devices, focused on Wi‑Fi/IoT control and driver extensibility. The ESP32‑C3 BT Proxy test runs inside an OpenBeken build, identified in boot logs as Project “OpenBeken.” [Elektroda, DeDaMrAz, post #21846290]

Does the ESP32‑C3 BT Proxy proof of concept actually work?

Yes. The author confirmed, “Proof of concept is working…”. It boots on ESP‑IDF v5.5.2 and exchanges API messages, indicating a functional handshake and entity listing. This is an experiment parked until clear use cases appear. [Elektroda, DeDaMrAz, post #21846290]

Which Bluetooth stack is used: NimBLE or Bluedroid?

Bluedroid. The author chose Bluedroid because ESPHome was the base and easiest to integrate for this prototype. “bluedroid as ESPHome was the base and easiest to implement.” [Elektroda, DeDaMrAz, post #21846587]

Where can I get the experimental code?

A work‑in‑progress branch is shared: a BT_proxy branch on the author’s fork. It’s noted as messy but usable for experimentation pending cleanup. [Elektroda, DeDaMrAz, post #21846593]

I miss BLE advertisements once Wi‑Fi connects—how do I fix that?

This symptom was observed. Tuning Wi‑Fi/BLE coexistence and BLE scan timing helped on ESP. Try a 40/60 Wi‑Fi/BT split and adjust scan intervals/windows to recover advertisements. “play around with that ratio.” [Elektroda, DeDaMrAz, post #21847084]

What coexistence ratio worked during tests?

A 40% Wi‑Fi and 60% BT split was reported during ESP tests. This improved advertisement capture under contention. Treat as a starting point and validate in your RF environment. [Elektroda, DeDaMrAz, post #21847063]

How big is the RTL8720D build, and does flash size matter?

A minimal RTL8720D build measured ~1053 KB without Berry, about 1157 KB with it. Devices with only 2 MB flash may struggle once BT components inflate binaries. Leave overhead for OTA and filesystem. [Elektroda, insmod, post #21847067]

Will 2 MB flash devices be supported?

The author warns BT proxy binaries are often large, likely excluding 2 MB targets. Treat this as a constraint until further optimization or feature trimming lands. [Elektroda, DeDaMrAz, post #21846290]

Can I build RTL8720D firmware with parallel make jobs?

Avoid make -j on RTL8720D. Builds fail when parallelized. Use single‑job builds to stabilize toolchain behavior in current snapshots. [Elektroda, insmod, post #21847083]

Is MQTT required, or can I adapt the ESPHome API?

An alternative using the ESPHome API was proposed. This can simplify discovery and state sync versus MQTT, especially for Home Assistant setups. Evaluate API throughput against BLE scan load. [Elektroda, insmod, post #21847083]

How do I try the ESP32‑C3 BT Proxy build? (3 steps)

  1. Clone the author’s fork and checkout the BT_proxy branch.
  2. Build for ESP32‑C3 with ESP‑IDF v5.5.2, enabling the BT proxy flag.
  3. Flash, connect Wi‑Fi, then verify BLE handshake logs over UART. [Elektroda, DeDaMrAz, post #21846593]

I saw a MAC address issue—what’s the status?

One tester hit a MAC display issue initially and fixed it first. Ensure correct SDK config and init order when enabling BT coexistence. Validate with fresh logs after changes. [Elektroda, insmod, post #21847064]

Is there a Dockerized local build to speed iteration?

Yes. The author recommends the Docker local build from the fork to accelerate compile‑flash cycles. This helps when testing BTProxy and TCPuart combos. [Elektroda, DeDaMrAz, post #21847075]

What’s the project status and roadmap?

Development is paused due to cost‑benefit concerns. The test device will keep collecting stability data. A port to RTL8720D is planned when the dev board is available. [Elektroda, DeDaMrAz, post #21846290]

Will this use case extend to RTL8720D Zigbee gateways?

Yes, the initial goal was restoring BT proxy on a Zigbee gateway with RTL8720D. Work began on ESP32‑C3 first due to availability and prior hurdles. [Elektroda, DeDaMrAz, post #21846587]

Any other tuning tips beyond coexistence?

Yes. Tweak BLE scan timing (interval/window) for better capture under Wi‑Fi load. This improved results in ESPHome contexts during testing. [Elektroda, DeDaMrAz, post #21847088]
Generated by the language model.
ADVERTISEMENT