Generic BLE temp/rh sensor

Hi folks. I have a few of these: Smart Bluetooth Thermometer Hygrometer Mini Lcd Digital Indoor Outdoor Hygrometer Gauge Sensor App Control Record With Switch - Thermometer Hygrometer - AliExpress
They are BT/BLE and send updates to their own app (Qaqa), but I’m not sure what protocol is used.

Does anyone know how I can configure ESPHome to listen to them and exchange temp/rh data with Home Assistant?

Thanks. I have now… Sample output below. Not sure the parsing makes too much sense, but I may be misinterpreting. Any thoughts?

[15:43:41][I][ble_sensor:031]: [Whoopee temp] Connected successfully!
[15:43:41][I][ble_client:170]: Service UUID: 0x1800
[15:43:41][I][ble_client:171]:   start_handle: 0x1  end_handle: 0x5
[15:43:41][I][ble_client:383]:  characteristic 0x2A00, handle 0x3, properties 0x2
[15:43:41][I][ble_client:383]:  characteristic 0x2A01, handle 0x5, properties 0x2
[15:43:41][I][ble_client:170]: Service UUID: 0x180A
[15:43:41][I][ble_client:171]:   start_handle: 0x6  end_handle: 0x10
[15:43:41][I][ble_client:383]:  characteristic 0x2A19, handle 0x13, properties 0x12
[15:43:41][I][ble_client:170]: Service UUID: 0xFFE5
[15:43:41][I][ble_client:171]:   start_handle: 0x15  end_handle: 0x1a
[15:43:41][I][ble_client:383]:  characteristic 0xFFE9, handle 0x17, properties 0x4
[15:43:41][I][ble_client:383]:  characteristic 0xFFE8, handle 0x19, properties 0x10
[15:43:41][I][ble_client:170]: Service UUID: 0xFE59
[15:43:41][I][ble_client:171]:   start_handle: 0x1b  end_handle: 0x23
[15:43:41][I][ble_client:383]:  characteristic 8EC90001-F315-4F60-9FB8-838830DAEA50, handle 0x1d, properties 0x18

Trying again - I’d hate to give up on these - anyone have any idea as to how to suck temp/rh data from these critters into esphome? Thanks!

1 Like

I followed this flashing guide for my Xiomia versions of that sensor:

What a great idea! Just tried that. I had my hopes up but the flasher does seem to recognize these sensors and would not connect to them or flash them. I opened a FR with the author…

Thanks!!

Hey,

I have the same devices and curious if there is anything new regarding the connection?

Found on a french homepage ( Température Bluetooth LE dans domoticz par reverse engineering et MQTT auto-discovery Home Assistant | LPRP.fr ) something which might help us here.

There is an encryption for the data:
"To get to this screen, you have to find the right device (usually LT_xxxx), connect to it, locate the service 0xFFE9 and its notification feature 0xFFE8, click on the little icon on the right to subscribe to notifications, and wait a few seconds to see the value line displayed, which in this example is (0x) AA-AA-A2-00-06-01-10-01-86-10-00-95-55; we are observing well:

AA-AA: the header
A2 : it is the hygrometry
00-06 : the size of the data is 6 bytes
01-10 : 0x0110, that is to say 256 in decimal, to divide by 10 : 25,6° (and that falls well, it is well what my thermometer displays !)
01-86 : 0x0186, that is 390 in decimal, to divide by 10 : 39%.
01 : battery indication ; I suppose that 1 means that the battery indicator is not displayed
00 : we are in degrees Celsius
95 : the checksum (and it is correct)
55 : the footer
We can now read the data and move on!"
Translated by DeepL

1 Like

I’m also interested in this, having found one of these sensors for very cheap on Temu.

It looks like it should be possible to add configuration to my ESP32 esp-home device that’s working as a bluetooth proxy, based on https://esphome.io/components/sensor/ble_client.html?highlight=ble+sensor and a lambda return to decode from the BLE notification - I’ll update here if I get it working.

I can confirm the following added to my esphome successfully got the current temperature and RH from this sensor.

I’m sure there could also be improvements such as detecting if the temperature is not in celcius but it works for me.

Obviously you will need to update the BLE MAC address to match your device and update names to suit:

ble_client:
  - mac_address: cf:3d:fb:90:7c:0e
    id: kitchen_ble_rh_t

sensor:
  - platform: ble_client
    type: characteristic
    ble_client_id: kitchen_ble_rh_t
    name: "Kitchen Temperature"
    service_uuid: 'FFE5'
    characteristic_uuid: 'FFE8'
    lambda: |- 
      return float(x[5] * 0x100 + x[6]) / 10.0f;
    notify: true
    unit_of_measurement: '°C'

  - platform: ble_client
    type: characteristic
    ble_client_id: kitchen_ble_rh_t
    name: "Kitchen RH"
    service_uuid: 'FFE5'
    characteristic_uuid: 'FFE8'
    lambda: |- 
      return float(x[7] * 0x100 + x[8]) / 10.0f;
    notify: true
    unit_of_measurement: '%'

I may have spoken too soon - I’ve seen this work exactly once, with the figures on screen and then never again.

I suspect there’s something strange going on with a characteristic that can only be read by notification.
If I add the descriptor_uuid 2902, it appears to connect but only returns the 2 bytes of the descriptor!

What do you mean they showed up once and not again? Were the values correct when it did show up? Does it just show “unknown” or “unavailable” now

I too have acquired a few of these sensors, and would love to see them in my HA setup. I followed the French link referenced above, and was able to see the message exactly as described using nRF Connect. That is rather positive. However, I am a little fuzzy as to how I should go about the next step. Are there some giants about, on whose shoulders I could stand?

The French link even leads us to blelt2mgtt, which is a python script to translate the BLE data from these very sensors to MQTT. I am quite certain that all the information needed to make them work with a HA bluetooth proxy running on an ESP32, for example, would be in there, if only I was clever enough to figure it out. But alas!
image
Just to be clear - we are talking about these units, with the insipid little face.

Do you know the protocol? They are sometimes tricky…

Yes indeed: https://github.com/rpeyron/blelt2mqtt/blob/0ccaac5c8cc9f4c31425ccf6e49b80d06e9f2eba/protocol.md
Rémi Peyronnet documented it rather well.

Not so clear for the 2 bytes together.
Are you comfortable with esphome yaml coding?

I tried l33tmike Michael’s code above, without success, with one sensor monitoring the temperature and humidity in my 3D printer’s filament drybox. By chance (OK, because I am lazy) I left everything switched on for the weekend, and yesterday, when I updated ESPHome to the lastest version 2024.5.2, it seems to have quietly started working. Ours not to reason why, ours just to exploit good fortune while it lasts. So I added two more units - plenty more where those came from - each time getting the MAC addresses with the help of nRF Connect, and copied and pasted as needed. All three units have been reporting exactly what they show on their screens for the past few hours.
I started off with the ESPHome Readymade bluetooth proxy running on an ESP32, and added until my code looks like this:

substitutions:
  name: esp32-bluetooth-proxy-3054b0
  friendly_name: Bluetooth Proxy 1
packages:
  esphome.bluetooth-proxy: github://esphome/firmware/bluetooth-proxy/esp32-generic.yaml@main
esphome:
  name: ${name}
  name_add_mac_suffix: false
  friendly_name: ${friendly_name}
api:
  encryption:
    key: XgsdfgsdfgYR4ISwruF+De+wJUER0QsVPODk3Ar3w=

wifi:
  networks:
  - ssid: !secret wifi_ssid1
    password: !secret wifi_password1

ble_client:
  - mac_address: ff:aa:bb:cc:dd:f1
    id: filament_th
  - mac_address: b8:88:f9:4d:1B:07
    id: slaapkamer_th
  - mac_address: ee:22:dd:93:82:06
    id: speelkamer_th    



sensor:
  - platform: ble_client
    type: characteristic
    ble_client_id: filament_th
    name: "Filament: temperatuur"
    service_uuid: 'FFE5'
    characteristic_uuid: 'FFE8'
    lambda: |- 
      return float(x[5] * 0x100 + x[6]) / 10.0f;
    notify: true
    unit_of_measurement: '°C'
    accuracy_decimals: 1

  - platform: ble_client
    type: characteristic
    ble_client_id: filament_th
    name: "Filament: RH"
    service_uuid: 'FFE5'
    characteristic_uuid: 'FFE8'
    lambda: |- 
      return float(x[7] * 0x100 + x[8]) / 10.0f;
    notify: true
    unit_of_measurement: '%'

  - platform: ble_client
    type: characteristic
    ble_client_id: slaapkamer_th
    name: "Slaapkamertemperatuur"
    service_uuid: 'FFE5'
    characteristic_uuid: 'FFE8'
    lambda: |- 
      return float(x[5] * 0x100 + x[6]) / 10.0f;
    notify: true
    unit_of_measurement: '°C'
    accuracy_decimals: 1

  - platform: ble_client
    type: characteristic
    ble_client_id: slaapkamer_th
    name: "Slaapkamer RH"
    service_uuid: 'FFE5'
    characteristic_uuid: 'FFE8'
    lambda: |- 
      return float(x[7] * 0x100 + x[8]) / 10.0f;
    notify: true
    unit_of_measurement: '%'

  - platform: ble_client
    type: characteristic
    ble_client_id: speelkamer_th
    name: "Speelkamertemperatuur"
    service_uuid: 'FFE5'
    characteristic_uuid: 'FFE8'
    lambda: |- 
      return float(x[5] * 0x100 + x[6]) / 10.0f;
    notify: true
    unit_of_measurement: '°C'
    accuracy_decimals: 1

  - platform: ble_client
    type: characteristic
    ble_client_id: speelkamer_th
    name: "Speelkamer RH"
    service_uuid: 'FFE5'
    characteristic_uuid: 'FFE8'
    lambda: |- 
      return float(x[7] * 0x100 + x[8]) / 10.0f;
    notify: true
    unit_of_measurement: '%'

And it shows up beautifully as device Bluetooth Proxy 1 in HA (Settings - Devices & services - ESPHome), showing the 6 sensor values:
image
Now I can see my drybox is indeed dry, which was the main purpose of the exercise.

Interesting.
With ble_client
I never managed to make it work, I had to go with ble_tracker

Hmm - I have of course kept going, and learned that “A maximum of three devices is supported due to limitations in the ESP32 BLE stack. If you wish to connect more devices, use additional ESP32 boards.”
Not a show-stopper, but slightly disappointing.

Then you should try with tracker, since it’s not connecting to anything, it’s not limited to 3.

Why thank you - I shall indeed. Do you have experience of these specific units? And/or can you suggest how I could transplant the working ESPHome code above to work with ble_tracker? I admit that I am not quite (at all, actually) clear how service_uuid and characteristic_uuid should be handled, if at all.