Skip to content

BTHome v2 decoding bug? #154

@mreymann

Description

@mreymann

First of all thank you for this wonderful piece of software! Made my life so much easier!
One litte thing, though:

pvvx firmware plans to switch to BTHome v2 messages only.
I'm using MiTemperature v6.0 and changed one of my thermometers to emit BHome v2 messages instead of the custom pvvx format.
Now the value for "Battery" shows 1 % instead of 100 % (this is a fresh battery):

BLE packet - BTHome : A4:C1:38:3E:B3:93 00 120201060e16d2fc40001b016402c808036c1a -54
Packet type: Data
Sensorname: new3
Temperature: 22.48
Humidity: 67.64
Battery voltage: 3.014 V
RSSI: -54 dBm
Battery: 1 %

Here's what ChatGPT says:


Nice — here’s the decoded BTHome v2 advertisement.

Raw hex you gave (grouped):
12 02 01 06 0e 16 d2 fc 40 00 1b 01 64 02 c8 08 03 6c 1a

Breakdown

02 01 06 — BLE Flags AD element (standard 0x020106).

0e 16 d2 fc — Service Data (UUID 0xFCD2 = BTHome) + payload.
BTHome

BTHome payload (after UUID): 40 00 1b 01 64 02 c8 08 03 6c 1a

0x40 — device info byte: BTHome v2, no encryption, regular updates.
BTHome

00 1b — object id 0x00 = packet id (uint8). Value 0x1B → 27.
BTHome

Measurements (object id → interpretation per BTHome v2 spec)

01 64

0x01 = battery (uint8, factor 1). 0x64 = 100%.
BTHome

02 c8 08

0x02 = temperature (sint16, little-endian, factor 0.01). Bytes C8 08 → value 0x08C8 = 2248 → 2248 × 0.01 = 22.48 °C.
BTHome

03 6c 1a

0x03 = humidity (uint16, little-endian, factor 0.01). Bytes 6C 1A → value 0x1A6C = 6764 → 6764 × 0.01 = 67.64 %.
BTHome

Human-readable summary

Packet id: 27

Battery: 100 %

Temperature: 22.48 °C

Relative Humidity: 67.64 %


Is there a bug in the decoding of BTHome v2 messages?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions