LoginSignup
25
19

More than 5 years have passed since last update.

Raspberry Pi で Bluetooth を使ってみた。(2)

Last updated at Posted at 2015-09-07

Bluetoothのドングルは、BLE (Bluetooth Low Energy) 対応のPlanexのBT-Micro4を使用。

ライブラリのインストール

$ sudo apt-get update
$ sudo apt-get install libdbus-1-dev libdbus-glib-1-dev libglib2.0-dev libical-dev libreadline-dev libudev-dev libusb-dev make

BlueZのダウンロード

BlueZ のソースコードを /usr/src にダウンロードします。
2015年9月7日時点での最新バージョンは ver.5.34 でした。

$ cd /usr/src/
$ sudo wget https://www.kernel.org/pub/linux/bluetooth/bluez-5.34.tar.xz
$ sudo xz -d bluez-5.4.tar.xz
$ sudo tar xvf bluez-5.34.tar

BlueZのインストール

ソースコードをビルドします。ビルドには少し時間がかかります。

$ cd bluez-5.34
$ sudo ./configure --disable-systemd
$ sudo make

ビルドが完了したらインストール。

$ sudo make install

作動確認

Raspberry PiにBluetoothドングルを挿します。
まず lsusb コマンドでドングルが認識されていることを確認。
PlanexのBT-Micro4の場合、Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode) と認識されました。

次にドライバの作動確認。hciconfig コマンドを使用。以下のような結果になりました。

$ hciconfig
hci0:   Type: BR/EDR  Bus: USB
    BD Address: 00:1B:DC:04:AA:4B  ACL MTU: 310:10  SCO MTU: 64:8
    UP RUNNING 
    RX bytes:15799 acl:0 sco:0 events:189 errors:0
    TX bytes:931 acl:0 sco:0 commands:78 errors:0

もし、UP RUNNING ではなくて DOWN と表示されていたら、

$ sudo hciconfig hci0 up

を実行。

Bluetooth機器を検索

  • コマンド hcitool scan を実行し、Bluetooth機器を検索します。
  • BLE機器を探すには sudo hcitool lescan を実行。 hcitool scan と違って検索し続けるので、Ctrl+C で検索を中止します。

リンク

参考

25
19
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
25
19