I’ve just bought this medical cooling box which is Bluetooth capable. The vendor provides a very simple and primitive Android app which lets you monitor the cooling box its temperature and the battery status (I’m not interested in battery status as the device is always on 230V power line in my case anyway).
What I would like to do now is to monitor the cooling box its temperature with EPSHome in Home Assistant by using an ESP32 microcontroller with bluetooth capability instead of the Android app.
Now for reverse engineering, what I recently did, is to generate a bluetooth bug report with my Android phone while connected via the Vendor’s Android app by Bluetooth and then imported the bug report into Wireshark. In combination with the vendor’s instructions on GitHub about the Bluetooth communication protocol I could already find out which values I have to write (send) and read (receive) via ESP32 to get the according byte array which contains the according byte, holding the current temperature of the cooling box (I marked it yellow in the following screenshot):
So with this information I set up the following ESPHome testing code:
esp32_ble_tracker:
ble_client:
- mac_address: f4:b5:ed:bf:10:a9
id: my_ble_client
time:
- platform: sntp
on_time:
- seconds: /5
then:
- ble_client.ble_write:
id: my_ble_client
service_uuid: 0000fee9-0000-1000-8000-00805f9b34fb
characteristic_uuid: d44bc439-abfd-45a2-b575-925416129600
value: [0xaa, 0x8f, 0x01, 0x55]
sensor:
- platform: ble_client
type: characteristic
ble_client_id: my_ble_client
update_interval: 5s
name: "Temperature"
service_uuid: 0000fee9-0000-1000-8000-00805f9b34fb
characteristic_uuid: d44bc439-abfd-45a2-b575-925416129601
unit_of_measurement: '°C'
lambda: |-
uint16_t test = x[2];
float temp = (float)test;
return temp / 10;
Now the code for the ESP32 device works and as far as I can see I am able to write (send) to the cooling box device but something seems wrong with the read (received) data and I am not able to find out what it is. The ESPHome logs are showing the following message frequently:
[ble_sensor:080]: Error reading char at handle 14, status=2
When I do not insert the sensor’s lambda function then there is no error message appearing so I guess it must have something to do with wrong formatted or wrong parsed values or something.
I feel I am so damn close but I’m at the end of my knowledge with this error.
Any help would be very appreciated.
Thanks in advance!
Edit: Here are the complete ESPHome logfiles for downloading.