Inkbird IBS-TH1 Linux(ubuntu)からbluetoothでのデータ取得

投稿者: | 2020年5月28日

ESP32を使って温度計測をしようかと検討していたが目的を速く達成すべく安価でワイヤレスで温湿度データをPCへ取得できる良いものが無いかとネットを徘徊していたら表題のInkbird IBS-TH1 miniなるものを見つけた。

安価だったので早速amazonで2個購入。
https://amzn.to/2X920dY

DP2M0138

DP2M0140

DP2M0143

モノは非常に小さく500円玉より少し大きく、そして分厚い。
それでもかなりの小型。
仕様的には35mm×10.5mmの20g。リチウム電池で動作するのだが付属で2つ付いているのも良心的である。
かなり小さいのでどこにでも置けそうである。

自分の場合はPCでデータを読み込むというのが最終目的だがまずは標準のアプリで動作チェック&アドレスの確認をしよう。
標準のアプリの詳細は割愛するが

IMG_0027IMG_0028

こんな感じで見る事ができる。
動作確認をするとともにアドレスをメモっておく。

 

動作が確認できたらPCでの読み込み。
私が使用しているこのWEBサーバ用PCはBluetoothを搭載していないので近所の家電量販店でELECOMの高い方を購入。

エレコム Bluetooth4.0 USBアダプター LBT-UAN05C1

2種類しか置いてなかったが上記のものはClass1で伝達距離が100メートルとあったので、センサーをあちこちに置きたい事もあって此方をチョイスした。もう一方は10メートル(class2)。

https://www.elecom.co.jp/products/LBT-UAN05C1.html

Linux(ubuntu18.04LTS)でも難なく認識

$ bluetoothctl
# scan on
Discovery started
[CHG] Controller 00:1B:DC:F5:EC:70 Discovering: yes
[NEW] Device 44:B0:35:B1:33:BE 44-B0-35-B1-33-BE
[NEW] Device D6:6D:55:9C:3A:7E D7500_2025627
[NEW] Device 9E:2F:46:00:00:A1 9E-2F-46-00-00-A1
[NEW] Device 78:DB:2F:B8:5A:B4 sps
[NEW] Device 42:7F:C7:35:CD:34 42-7F-C7-35-CD-34
[NEW] Device 51:13:7C:C0:4E:B4 51-13-7C-C0-4E-B4
[NEW] Device 78:DB:2F:C0:B9:21 sps
[NEW] Device 5C:62:37:01:40:E6 5C-62-37-01-40-E6
[CHG] Device 51:13:7C:C0:4E:B4 RSSI: -58
[CHG] Device 51:13:7C:C0:4E:B4 RSSI: -45
[CHG] Device 9E:2F:46:00:00:A1 RSSI: -50
[bluetooth]# exit

データの読み込みは

$ gatttool -b 78:DB:2F:B8:5A:B4 –characteristics
handle = 0x0002, char properties = 0x12, char value handle = 0x0003, uuid = 00002a19-0000-1000-8000-00805f9b34fb
handle = 0x0007, char properties = 0x02, char value handle = 0x0008, uuid = 00002a00-0000-1000-8000-00805f9b34fb
handle = 0x0009, char properties = 0x02, char value handle = 0x000a, uuid = 00002a01-0000-1000-8000-00805f9b34fb
handle = 0x000b, char properties = 0x0a, char value handle = 0x000c, uuid = 00002a02-0000-1000-8000-00805f9b34fb
handle = 0x000d, char properties = 0x08, char value handle = 0x000e, uuid = 00002a03-0000-1000-8000-00805f9b34fb
handle = 0x000f, char properties = 0x02, char value handle = 0x0010, uuid = 00002a04-0000-1000-8000-00805f9b34fb
handle = 0x0012, char properties = 0x20, char value handle = 0x0013, uuid = 00002a05-0000-1000-8000-00805f9b34fb
handle = 0x0016, char properties = 0x02, char value handle = 0x0017, uuid = 00002a23-0000-1000-8000-00805f9b34fb
handle = 0x0018, char properties = 0x02, char value handle = 0x0019, uuid = 00002a24-0000-1000-8000-00805f9b34fb
handle = 0x001a, char properties = 0x02, char value handle = 0x001b, uuid = 00002a25-0000-1000-8000-00805f9b34fb
handle = 0x001c, char properties = 0x02, char value handle = 0x001d, uuid = 00002a26-0000-1000-8000-00805f9b34fb
handle = 0x001e, char properties = 0x02, char value handle = 0x001f, uuid = 00002a27-0000-1000-8000-00805f9b34fb
handle = 0x0020, char properties = 0x02, char value handle = 0x0021, uuid = 00002a28-0000-1000-8000-00805f9b34fb
handle = 0x0022, char properties = 0x02, char value handle = 0x0023, uuid = 00002a29-0000-1000-8000-00805f9b34fb
handle = 0x0024, char properties = 0x02, char value handle = 0x0025, uuid = 00002a2a-0000-1000-8000-00805f9b34fb
handle = 0x0026, char properties = 0x02, char value handle = 0x0027, uuid = 00002a50-0000-1000-8000-00805f9b34fb
handle = 0x0029, char properties = 0x0a, char value handle = 0x002a, uuid = 0000fff1-0000-1000-8000-00805f9b34fb
handle = 0x002c, char properties = 0x02, char value handle = 0x002d, uuid = 0000fff2-0000-1000-8000-00805f9b34fb
handle = 0x002f, char properties = 0x0a, char value handle = 0x0030, uuid = 0000fff3-0000-1000-8000-00805f9b34fb
handle = 0x0032, char properties = 0x02, char value handle = 0x0033, uuid = 0000fff4-0000-1000-8000-00805f9b34fb
handle = 0x0035, char properties = 0x02, char value handle = 0x0036, uuid = 0000fff5-0000-1000-8000-00805f9b34fb
handle = 0x0038, char properties = 0x10, char value handle = 0x0039, uuid = 0000fff6-0000-1000-8000-00805f9b34fb
handle = 0x003c, char properties = 0x0a, char value handle = 0x003d, uuid = 0000fff7-0000-1000-8000-00805f9b34fb
handle = 0x003f, char properties = 0x0a, char value handle = 0x0040, uuid = 0000fff8-0000-1000-8000-00805f9b34fb
handle = 0x0042, char properties = 0x08, char value handle = 0x0043, uuid = 0000fff9-0000-1000-8000-00805f9b34fb

$ gatttool -b 78:DB:2F:B8:5A:B4 –char-read –handle=0x002d
Characteristic value/descriptor: 7b 07 12 16 00 6f 1b

1、2Byte目が温度、3,4Byte目が湿度だ。
7b 07 12 16の部分がデータ
0x077bが温度
0x1612が湿度
十進変換後100で割る

$ gatttool -b 78:DB:2F:B8:5A:B4 –char-read –handle=0x0003
Characteristic value/descriptor: 64

バッテリ?

78:DB:2F:B8:5A:B4の部分がIBS-TH1 miniのアドレス。

上記のコマンドを10分おきに実行し結果をデータベースに蓄積してトップページに表示しています。
実際にはXOJOでshellコマンドを実行し結果を切り出している感じで最終的にはセンサーを増やして更にグラフ表示したい。

Inkbird IBS-TH1 Linux(ubuntu)からbluetoothでのデータ取得」への2件のフィードバック

  1. 佐野

    大変参考になります。
    一つお伺いしたいことがあり、コメントさせていただきました。

    > 1、2Byte目が温度、3,4Byte目が湿度だ。
    > 7b 07 12 16の部分がデータ
    > 0x077bが温度
    > 0x1612が湿度
    > 十進変換後100で割る

    という割り出し方はどのようにして調べたのでしょうか?
    公式サイトなどで探してみたのですが、探し方が悪かったのか見つからず。。。
    よろしければ、ご教授いただければ幸いです。

    返信
    1. 通りすがりロガラー

      横から失礼。
      過分に「想像」だと思います。しかしながら、製品の特性から鑑み、それ以外のデータはいないのでは?
      アプリで取れる数字と比較して、妥当性を求めたとすれば、私は信じて良い値だと思います。
      事実私も比較してみて差異を感じませんし。
      また、バッテリーの残量と思しきも、私もそうかな?と思います。
      アプリは「本体温度」「本体湿度」「プローブ温度」「電池残量」しかわからない点からも想像できる限界かと。

      返信

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です