Back to tech

RaspberryPiにおけるBLEの設定

1 min read
Table of Contents
kakakikikeke.blogspot.jp
kakakikikeke.blogspot.jp

必要なもの

  • RaspberryPi
  • BLEの機能があるBluetoothドングル (Bluetooth4.0以降なら可能) ※RaspberryPi3であればすでに内蔵しているため、購入する必要なし

インストール等々

sudo apt-get update
sudo apt-get upgrade
sudo reboot
sudo apt-get dist-upgrade
#これで勝手にBluezの一通りのセットアップはできている

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

sudo apt-get -y install python-pip
sudo apt-get install python-dev libbluetooth-dev libboost-all-dev
sudo pip install pybluez

使えそうなコマンド

Bluetooothドングルの情報出力

hciconfig

BLEデバイスのスキャニング

sudo hcitool -i hci0 lescan

Bluetoothドングルの再起動

sudo hciconfig hci0 down 
sudo hciconfig hci0 up

実際の使用の仕方は参考”2”のgitがオススメ

参考

  1. http://kakakikikeke.blogspot.jp/2015/10/raspberrypi-bluez-ble.html
  2. http://github.com/switchdoclabs/iBeacon-Scanner-