Tuesday, 17 September 2024

Bluetooth Proxy

 I have a number of these,

https://buythermopro.com/product/tp357/?srsltid=AfmBOopPAqMD8LevxJewN2nf1H35xTTa1SQUm3UZew3Ek0fzLAU5LL80

Available from Amazon.


They are cheap, reasonably accurate, BLE thermometers & humidity sensors.


They are hooked up to Home Assistant via a Thermopro integration & work well, but the odd one is right on the edge of range from the RPI4 running HA.


So, never played with ESPHome before, it integrates into Home Assistant  & offers an easy way to compile & run on an ESP32.


I had a few spare ESP32C3 boards, so decided to give it a go.

Installed the ESPHome addon into HA, plugged the C3 board into my laptop, added a Bluetooth proxy & compiled it, it compiles on the RPI4 & makes it stagger a bit, despite having several  goes at installing it, it baulks at the installation.


I used a downloaded ESP installer which works, after that all updates are done over wifi.


Sat & watched it, no devices showing in the log, tweaked to log to verbose, still nothing.


Edited the YAML to try various things, nothing.


Eventually, this works,


esphome:
  name: bluetooth-proxy
  friendly_name: Bluetooth Proxy

esp32:
  board: esp32-c3-devkitm-1
  framework:
    type: esp-idf
    sdkconfig_options:
      CONFIG_BT_BLE_50_FEATURES_SUPPORTED: y
      CONFIG_BT_BLE_42_FEATURES_SUPPORTED: y
      CONFIG_ESP_TASK_WDT_TIMEOUT_S: "10"

esp32_ble_tracker:
  scan_parameters:
# Adjust timing if the defaults do not work in your environment
#    interval: 1100ms
#    window: 1100ms
    active: true

bluetooth_proxy:
  active: true
 

# Enable logging
logger:
  level: DEBUG

# Enable Home Assistant API
api:
  encryption:
    key: "xxxxxxxxxx"

ota:
  - platform: esphome
    password: "xxxxxxxxxxxxxxxx"

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

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Bluetooth-Proxy Fallback Hotspot"
    password: "xxxxxxxxxxxxx"

captive_portal:
   

It proxies the Bluetooth packets over wifi to whatever integration requires it (in my case Thermopro)
It runs seamlessly with the normal Bluetooth on the RPI4.

Result!

No comments:

Post a Comment