esphome / issues

Issue Tracker for ESPHome
https://esphome.io/
293 stars 36 forks source link

radon_eye_ble doesn't connect to Radon Eye RD200 V3 #6304

Open baldisos opened 1 month ago

baldisos commented 1 month ago

The problem

I am trying to connect my Radon Eye RD200 V3 sensor with the radon_eye_ble component. I can read and write data with the python script from https://github.com/sormy/radoneye. The output i get from the python script when using radoneye list: 94:B5:55:7F:51:26 FR:HG04RE000465 And when using radoneye status 94:B5:55:7F:51:26

alarm_enabled   no
alarm_interval_minutes  60
alarm_level_bq_m3   300
alarm_level_pci_l   8.11
counts_current  85
counts_previous 90
counts_str  85/90
day_avg_bq_m3   584
day_avg_pci_l   15.78
display_unit    bq/m3
firmware_version    V3.0.1
latest_bq_m3    452
latest_pci_l    12.22
model   D200V3
month_avg_bq_m3 0
month_avg_pci_l 0.0
peak_bq_m3  961
peak_pci_l  25.97
serial  000HG04RE465
uptime_minutes  9729
uptime_str  6d18h09m

But when using the radon_eye_ble within esphome on a Wemos Mini D1 ESP32 (ESP32-Wroom-32) i don't get any output. No logs on connection and no data.

I've only ever read about V2 versions online, the device i got is a V3. But it does work with the python script, so i guess there's something missing within the esphome component.

Which version of ESPHome has the issue?

2024.9.2

What type of installation are you using?

Home Assistant Add-on

Which version of Home Assistant has the issue?

2024.10.1

What platform are you using?

ESP32

Board

Wemos Mini D1 ESP32 (ESP32-Wroom-32)

Component causing the issue

radon_eye_rd200

Example YAML snippet

esp32_ble_tracker:

ble_client:
  - mac_address: 94:b5:55:7f:51:26
    id: radon_eye_ble_id

sensor:
  - platform: radon_eye_rd200
    ble_client_id: radon_eye_ble_id
    update_interval: 5min # default
    radon:
      name: "Radon"
    radon_long_term:
      name: "Radon Langzeit"

Anything in the logs that might be useful for us?

[14:51:09][W][radon_eye_rd200:141]: Connection in progress
[14:53:09][W][radon_eye_rd200:141]: Connection in progress
[14:54:57][D][esp32_ble_tracker:270]: Starting scan...
[14:55:09][W][radon_eye_rd200:141]: Connection in progress
[14:57:09][W][radon_eye_rd200:141]: Connection in progress
[14:59:09][W][radon_eye_rd200:141]: Connection in progress
[14:59:58][D][esp32_ble_tracker:270]: Starting scan...
[15:01:09][W][radon_eye_rd200:141]: Connection in progress
[15:03:09][W][radon_eye_rd200:141]: Connection in progress
[15:04:57][D][esp32_ble_tracker:270]: Starting scan...
[15:05:09][W][radon_eye_rd200:141]: Connection in progress
[15:07:09][W][radon_eye_rd200:141]: Connection in progress
[15:09:09][W][radon_eye_rd200:141]: Connection in progress
[15:09:57][D][esp32_ble_tracker:270]: Starting scan...
[15:11:09][W][radon_eye_rd200:141]: Connection in progress
[15:13:09][W][radon_eye_rd200:141]: Connection in progress
[15:14:57][D][esp32_ble_tracker:270]: Starting scan...
[15:15:09][W][radon_eye_rd200:141]: Connection in progress
[15:17:09][W][radon_eye_rd200:141]: Connection in progress

Additional information

photo_2024-10-05_14-41-51

ckuethe commented 1 month ago

maybe a duplicate of #5655 ?

baldisos commented 1 month ago

As per the instructions from https://esphome.io/components/sensor/radon_eye_ble.html, if i understand it correctly, the _radon_eyeble component is just used to find the mac address of the Radon Eye? The _radon_eyeble isn't referenced in the _radon_eyerd200 component which is used to read the values, right? So the issue should be within the _radon_eyerd200 component. The referenced issue is within the _radon_eyeble component.

ckuethe commented 1 month ago

For fun, I patched radon_eye_rd200 to use the UUIDs from sormy/radoneye/KNOWLEDGE_V2.md ... which also doesn't work, but at least gets a little further. Far enough to say whether protocol v1 or v2 is in use.

I haven't tried updating the decoder to work with v2 responses.

[C][esp32_ble:032]: Setting up BLE...
[D][esp32_ble:284]: Enabling BLE...
[C][esp32_ble:032]: Setting up BLE...
[C][esp32_ble:032]: Setting up BLE...
[W][radon_eye_rd200:141]: Connection in progress
[D][esp32_ble:284]: Enabling BLE...
[V][esp32_ble:359]: (BLE) gattc_event [esp_gatt_if: 4] - 0
[V][esp32_ble_client:121]: [0] [30:C9:22:A3:7E:CE] gattc_event_handler: event=0 gattc_if=4
[V][esp32_ble_client:127]: [0] [30:C9:22:A3:7E:CE] gattc registered app id 1
[D][esp32_ble_client:110]: [0] [30:C9:22:A3:7E:CE] Found device
[D][esp32_ble_tracker:671]: Found device 30:C9:22:A3:7E:CE RSSI=-57
[D][esp32_ble_tracker:692]:   Address Type: PUBLIC
[D][esp32_ble_tracker:694]:   Name: 'FR:ID16RE000939'
[D][esp32_ble_tracker:219]: Pausing scan to make connection...
[D][esp32_ble_tracker:219]: Pausing scan to make connection...
[D][esp32_ble_tracker:219]: Pausing scan to make connection...
[I][esp32_ble_client:067]: [0] [30:C9:22:A3:7E:CE] 0x00 Attempting BLE connection
[V][esp32_ble:359]: (BLE) gattc_event [esp_gatt_if: 4] - 40
[V][esp32_ble_client:121]: [0] [30:C9:22:A3:7E:CE] gattc_event_handler: event=40 gattc_if=4
[D][esp32_ble_client:110]: [0] [30:C9:22:A3:7E:CE] ESP_GATTC_CONNECT_EVT
[V][esp32_ble:359]: (BLE) gattc_event [esp_gatt_if: 4] - 2
[V][esp32_ble_client:121]: [0] [30:C9:22:A3:7E:CE] gattc_event_handler: event=2 gattc_if=4
[D][esp32_ble_client:110]: [0] [30:C9:22:A3:7E:CE] ESP_GATTC_OPEN_EVT
[I][radon_eye_rd200:015]: Connected successfully!
[V][esp32_ble:359]: (BLE) gattc_event [esp_gatt_if: 4] - 46
[V][esp32_ble_client:121]: [0] [30:C9:22:A3:7E:CE] gattc_event_handler: event=46 gattc_if=4
[D][esp32_ble_client:306]: [0] [30:C9:22:A3:7E:CE] Event 46
[V][esp32_ble:359]: (BLE) gattc_event [esp_gatt_if: 4] - 7
[V][esp32_ble_client:121]: [0] [30:C9:22:A3:7E:CE] gattc_event_handler: event=7 gattc_if=4
[V][esp32_ble:359]: (BLE) gattc_event [esp_gatt_if: 4] - 7
[V][esp32_ble_client:121]: [0] [30:C9:22:A3:7E:CE] gattc_event_handler: event=7 gattc_if=4
[V][esp32_ble:359]: (BLE) gattc_event [esp_gatt_if: 4] - 7
[V][esp32_ble_client:121]: [0] [30:C9:22:A3:7E:CE] gattc_event_handler: event=7 gattc_if=4
[V][esp32_ble:359]: (BLE) gattc_event [esp_gatt_if: 4] - 6
[V][esp32_ble_client:121]: [0] [30:C9:22:A3:7E:CE] gattc_event_handler: event=6 gattc_if=4
[D][esp32_ble_client:110]: [0] [30:C9:22:A3:7E:CE] ESP_GATTC_SEARCH_CMPL_EVT
[V][esp32_ble_client:223]: [0] [30:C9:22:A3:7E:CE] Service UUID: 0x1801
[V][esp32_ble_client:225]: [0] [30:C9:22:A3:7E:CE]  start_handle: 0x1  end_handle: 0x5
[V][esp32_ble_client:223]: [0] [30:C9:22:A3:7E:CE] Service UUID: 0x1800
[V][esp32_ble_client:225]: [0] [30:C9:22:A3:7E:CE]  start_handle: 0x14  end_handle: 0x1c
[V][esp32_ble_client:223]: [0] [30:C9:22:A3:7E:CE] Service UUID: 0x1523
[V][esp32_ble_client:225]: [0] [30:C9:22:A3:7E:CE]  start_handle: 0x28  end_handle: 0xffff
[I][esp32_ble_client:227]: [0] [30:C9:22:A3:7E:CE] Connected
[V][esp32_ble_client:069]: [0] [30:C9:22:A3:7E:CE]  characteristic 0x1524, handle 0x2a, properties 0x6
[V][esp32_ble_client:069]: [0] [30:C9:22:A3:7E:CE]  characteristic 0x1525, handle 0x2c, properties 0x12
[V][esp32_ble_client:069]: [0] [30:C9:22:A3:7E:CE]  characteristic 0x1526, handle 0x2f, properties 0x12
[V][radon_eye_rd200:147]: writing 0x50 to write service
[V][esp32_ble:359]: (BLE) gattc_event [esp_gatt_if: 4] - 18
[V][esp32_ble_client:121]: [0] [30:C9:22:A3:7E:CE] gattc_event_handler: event=18 gattc_if=4
[D][esp32_ble_client:188]: [0] [30:C9:22:A3:7E:CE] cfg_mtu status 0, mtu 517
[V][esp32_ble:359]: (BLE) gattc_event [esp_gatt_if: 4] - 9
[V][esp32_ble_client:121]: [0] [30:C9:22:A3:7E:CE] gattc_event_handler: event=9 gattc_if=4
[D][esp32_ble_client:110]: [0] [30:C9:22:A3:7E:CE] ESP_GATTC_WRITE_DESCR_EVT
[V][esp32_ble:359]: (BLE) gattc_event [esp_gatt_if: 4] - 3
[V][esp32_ble_client:121]: [0] [30:C9:22:A3:7E:CE] gattc_event_handler: event=3 gattc_if=4
[D][esp32_ble_client:110]: [0] [30:C9:22:A3:7E:CE] ESP_GATTC_READ_CHAR_EVT
[V][radon_eye_rd200:081]: result bytes: 0000 00000000 00000000 00000000 0000 0000 0000
baldisos commented 1 month ago

I tried the same thing, but i can't wrap my head around how the decoding works. I can't get this to work. The data is read, but as you say, it's not decoded properly.

ckuethe commented 1 month ago

first problem is radon_eye_rd200.cpp#L148 where it's sending a 0x50 to poll the device and according to KNOWLEDGE_V2.md the newer version seems to use 0x40.

after I 3d print some round tuits, I'm going to see about adding another check in here to try detect characteristics with the new UUIDs and use that to set some sort of version flag. Once the protocol version is known, the right command can be send and its response can be decoded. of course, there will need to be a decoder written for the new protocol...

ckuethe commented 1 month ago

Yay, a different error! I'm still not getting meaningful data from my RD200 - getting back a 20-byte message full of 0x00, but at least I can now make my detector beep when the ESP32 connects.

baldisos commented 3 weeks ago

I wonder if @sormy could be of help here. This is beyond my capabilities.

sormy commented 3 weeks ago

Original implementation for v1 polls, but is supposed to subscribe. V2 works only with subscribe. I have actually implementation v1/v2 that i have never tested (i sold house with radon meters so have no devices to test on), i can share branch for testing if interested. Alternative is to use bluetooth protocol dump to reverse engineer v3, i can provide instructions for ios and mac.

ckuethe commented 3 weeks ago

Sure, that sounds helpful.interesting

My RD200V3 works with https://github.com/sormy/radoneye and https://github.com/sormy/radoneye-reader - I'm able to poll the full measurements as described in https://github.com/sormy/radoneye/blob/main/KNOWLEDGE_V2.md

sormy commented 2 weeks ago

Here is a branch: https://github.com/sormy/esphome/tree/rd200v2 Feel free to polish if needed