- Qiita / @revsystem / 2021-05-14: Updated: 2024-11-09: Inkbirdの温湿度計のデータをRaspberry Piで取得しPrometheusとGrafanaで可視化する
- Aktnk Lab / 2023-01-05: InkbirdのBluetooth温度湿度計のアドバタイズデータから温度・湿度データを読み取る
AdvertisementData を拾う方法と GATT の vendor specific characteristic から "Real time data" を拾う方法が取れる。
GATT から拾う場合の handle は、
どうも機種毎に異なっている様子である。
ひょっとすると、FW version によっても変わるのかもしれない。
とりあえず、本機 IBS-TH2 Plus の場合は UUID : 0x2901 (Standard Descriptors : Characteristic User Description) に "Real time data" が設定されている handle = 0x0017 の Characteristic が目的のデータで、データ構造は、上記ページの情報の通り、
Ubuntu に bluez 入れてると以下のコマンドで取得できる。
AdvertisementData を拾う場合は
GATT から拾う場合の handle は、
- Qiita / @revsystem / 2021-05-14: Updated: 2024-11-09: Inkbirdの温湿度計のデータをRaspberry Piで取得しPrometheusとGrafanaで可視化する
どうも機種毎に異なっている様子である。
ひょっとすると、FW version によっても変わるのかもしれない。
とりあえず、本機 IBS-TH2 Plus の場合は UUID : 0x2901 (Standard Descriptors : Characteristic User Description) に "Real time data" が設定されている handle = 0x0017 の Characteristic が目的のデータで、データ構造は、上記ページの情報の通り、
{
int16le temperature_x100. // 100 倍した温度
int16le humidity_x100, // 100 倍した湿度
int8 unknown[3], // 不明
}
だった。Ubuntu に bluez 入れてると以下のコマンドで取得できる。
gatttool -b "$MAC" --char-read -a 0x0017
$ # temperature = 27.0℃
$ # humidity = 40.5%
$ # battery = 70%
$ read v < <(gatttool -b "$MAC" --char-read -a 0x0017); printf "%s\n" "$v"; \
readarray -t v < <(sed -E 's/.*: *//g;s/ +/\n/g' <<<"$v"); declare -p v; \
printf "%d\n" "0x${v[1]}${v[0]}" "0x${v[3]}${v[2]}" "0x${v[4]}" "0x${v[5]}" "0x${v[6]}"
Characteristic value/descriptor: 8f 0a f6 0f 00 97 c5
declare -a v=([0]="8f" [1]="0a" [2]="f6" [3]="0f" [4]="00" [5]="97" [6]="c5")
2703
4086
0
151
197
みたいな感じなので、末尾 3 バイトの素性は不明で、少なくともバッテリーの残量とは関係のない値のような気がする。AdvertisementData を拾う場合は
- Aktnk Lab / 2023-01-05: InkbirdのBluetooth温度湿度計のアドバタイズデータから温度・湿度データを読み取る
{
ManufacturerData Key : {
int16le temperature_x100, // 100 倍した温度 [℃/100]
},
ManufacturerData Value : {
int16le hupedity_x100. // 100 倍した湿度 [%/100]
int8 unknown[5], // 不明
}
}
みたいなデータ構造になってるっぽいんだが、- temperature = 27.08℃ : 2708 = 0x0a94
- humidity = 40.36% : 4036 = 0x0fc4
- battery = 69% : 69 = 0x45
$ bluetoothctl scan on Discovery started ... [NEW] Device **:**:**:**:**:** sps ... [CHG] Device **:**:**:**:**:** ManufacturerData Key: 0x0a94 [CHG] Device **:**:**:**:**:** ManufacturerData Value: c4 0f 00 52 08 45 08 ...R.E. ...みたいな結果が得られるので、
{
ManufacturerData Key : {
int16le temperature_x100, // 100 倍した温度 [℃/100]
},
ManufacturerData Value : {
int16le hupedity_x100. // 100 倍した湿度 [%/100]
int8 unknown1[3], // 不明
int8 battery, // 電池残量[%]
int8 unknown2, // 不明
}
}
じゃないかと思われる。タグ

コメントをかく