arduino tank meets bluetooth
TRANSCRIPT
![Page 1: Arduino tank meets bluetooth](https://reader033.vdocuments.site/reader033/viewer/2022051016/55a8b5b91a28ab26628b46ea/html5/thumbnails/1.jpg)
Arduino Tank meets
Bluetooth増田智明 @moonmile
Moonmile Solutions
![Page 2: Arduino tank meets bluetooth](https://reader033.vdocuments.site/reader033/viewer/2022051016/55a8b5b91a28ab26628b46ea/html5/thumbnails/2.jpg)
ハルロック(西餅 著)
大学生協で教科書と並べて売られている!
![Page 3: Arduino tank meets bluetooth](https://reader033.vdocuments.site/reader033/viewer/2022051016/55a8b5b91a28ab26628b46ea/html5/thumbnails/3.jpg)
アジェンダ
無線化とは何か?
Bluetooth の種類
ペリフェラルとセントラル
Bluetooth 2.0 と Bluetooth Low Enrgy の違い
SPP通信とGATT
Bluetooth モジュール
Bluetooth を制御する
Android で制御
Windows ストアアプリで制御
WPF アプリで制御
![Page 4: Arduino tank meets bluetooth](https://reader033.vdocuments.site/reader033/viewer/2022051016/55a8b5b91a28ab26628b46ea/html5/thumbnails/4.jpg)
何故、無線化するのか?
ロボットを制御するためにPCと直結させる。
移動が制限される
ロボットにPCを乗せる?
最近はmini PCがある。
ロボットを遠隔操作する?
通信速度の制限がある。
通信距離の制限がある。
直結
Wi-Fi/Bluetooth
![Page 5: Arduino tank meets bluetooth](https://reader033.vdocuments.site/reader033/viewer/2022051016/55a8b5b91a28ab26628b46ea/html5/thumbnails/5.jpg)
無線化の種類
PC/Android Tank
PC/Android Tank
USBケーブル
マスター機器 スレーブ機器
有線のUSBケーブルを外す
無線化して Tank を自由に動かす
赤外線(IR)
ガラケー、TVリモコン
WiFi(無線LAN)
Bluetooth
ラジコン、プロボ
Zigbee 近距離通信に特化
日本では2.4GHz のラジコン帯が自由に使える
![Page 6: Arduino tank meets bluetooth](https://reader033.vdocuments.site/reader033/viewer/2022051016/55a8b5b91a28ab26628b46ea/html5/thumbnails/6.jpg)
Bluetoothの帯域
2.4GHz体の40チャンネルを使う
たくさんのBT機器があると混線する
電子レンジの近くでは使えない
WiFi 802.11a/b/g と混在
ラジコン RFモジュールと混在
![Page 7: Arduino tank meets bluetooth](https://reader033.vdocuments.site/reader033/viewer/2022051016/55a8b5b91a28ab26628b46ea/html5/thumbnails/7.jpg)
ペリフェラルとセントラル
ペリフェラル Peripheral
温度センサー等のデバイス
制御機器、Arduino Tank
セントラル Central
PC で制御
Android/iPhone で制御
PC/Android デバイス
セントラル ペリフェラル
![Page 8: Arduino tank meets bluetooth](https://reader033.vdocuments.site/reader033/viewer/2022051016/55a8b5b91a28ab26628b46ea/html5/thumbnails/8.jpg)
Bleutooth 2.0 と BLE の違い
Bluetooth 2.0 は主に SPP通信(シリアル通信)、HID で使う
ファイル転送は、WiFi と同じように使える。
常時接続で大量データ通信使う。
BLE(Bluetooth Low Energy)は、省電力に特化。通信速度も遅い。
20byte パケットの制限
GATT でセンサーデータの送受信に使う。
ロボット制御で、制御電文に使う。
![Page 9: Arduino tank meets bluetooth](https://reader033.vdocuments.site/reader033/viewer/2022051016/55a8b5b91a28ab26628b46ea/html5/thumbnails/9.jpg)
Bluetooth の接続制限
BT 2.0 BLE BT/BLE Windows iPhone 5 Android
BT 2.0 ○ × ○ ○ × ○
BT/BLE ○ ○ ○ ○ × ○
Windows ○ ○ ○ ○ ×? ○
iPhone 5 ※1 ○ × ※2 × ○ ×
Android ○ ※3 ※3 ○ ×? ○
※1 iPhone では、SSP通信する場合は MFi が必要※2 BT/BLE 混在のドングルへは接続できない※3 BLE は Android 4.4 以降
![Page 10: Arduino tank meets bluetooth](https://reader033.vdocuments.site/reader033/viewer/2022051016/55a8b5b91a28ab26628b46ea/html5/thumbnails/10.jpg)
手軽/現実的な接続のために
Windows/Android からは、BT 2.0を利用して SPP通信(シリアル通信)が楽
iPhone を含めると BLE が必須
iBeacon(iPhone の BLE デバイス)は、今後ライセンスが必要
特に Beacon を名乗る必要が無ければ、別の BLE を使えば ok
![Page 11: Arduino tank meets bluetooth](https://reader033.vdocuments.site/reader033/viewer/2022051016/55a8b5b91a28ab26628b46ea/html5/thumbnails/11.jpg)
SPP通信(Serial Port Profile)
一番楽ちんな通信
Arduino の Serial クラスを使える
Windows で COM ターミナル(Tera term など)を使える。
Windows で RFCOMM クラスが使える
Windows ストア用だが、工夫すればデスクトップアプリでも使える
Raspberry Pi で ttyAMA を使う
Android で BluetoothSocket を使う
5V●TX ●RX ●
GND ●
●Vin
● TX
● RX
● GND
SPI接続は簡単
![Page 12: Arduino tank meets bluetooth](https://reader033.vdocuments.site/reader033/viewer/2022051016/55a8b5b91a28ab26628b46ea/html5/thumbnails/12.jpg)
GATT(Generic Attribute Profile)
iPhone を含めるときは GATT が必須
データのやり取りが、BT 2.0 より細かく決められている。
その分、手順が増えているけど
Windows では GattDeviceService, GattCharacteristic を使う
Android では BluetoothDevice.connectGatt を使う
iPhone では CBCentralManager を使う
![Page 13: Arduino tank meets bluetooth](https://reader033.vdocuments.site/reader033/viewer/2022051016/55a8b5b91a28ab26628b46ea/html5/thumbnails/13.jpg)
HID(Serial Port Profile)
Bluetooth接続のキーボード、マウスで使われている
アダプタを買えば、デバイスを「キーボード」として認識できる。
PC/スマートフォンではキーボードと認識されるので、キーコードを送ることで特殊なプログラムを組まなくて済む。
Arduino を使って自作できる。
![Page 14: Arduino tank meets bluetooth](https://reader033.vdocuments.site/reader033/viewer/2022051016/55a8b5b91a28ab26628b46ea/html5/thumbnails/14.jpg)
Bluetooth モジュールあれこれ(BLE)
CC2541 SensorTag 開発キット
温度センサー、加速度センサーボタンが2個BLEを扱う実験に使う $25.00
BLEduino
BLEとArduinoの組み合わせ3,500円程度
![Page 15: Arduino tank meets bluetooth](https://reader033.vdocuments.site/reader033/viewer/2022051016/55a8b5b91a28ab26628b46ea/html5/thumbnails/15.jpg)
Bluetooth モジュールあれこれ(BLE)
mbed HRM1017
BLEとmbedの組み合わせ5,400円
BLE 開発キット:BVMCN5103-BK KIT
nRF51288 搭載開発キット、デバイス2個とデバッガ付き14,500円
![Page 16: Arduino tank meets bluetooth](https://reader033.vdocuments.site/reader033/viewer/2022051016/55a8b5b91a28ab26628b46ea/html5/thumbnails/16.jpg)
Bluetooth モジュールあれこれ(BLE)
HM-10
CC2540 搭載のBLEモジュール$5程度
RedBearLab BLE Sheid
nRF8001 搭載 Arduino 用シールド3,000円程度
![Page 17: Arduino tank meets bluetooth](https://reader033.vdocuments.site/reader033/viewer/2022051016/55a8b5b91a28ab26628b46ea/html5/thumbnails/17.jpg)
Bluetooth モジュールあれこれ(BT 2.0)
MyBeacon Fan
iBeacon 専用モジュール1,000円
![Page 18: Arduino tank meets bluetooth](https://reader033.vdocuments.site/reader033/viewer/2022051016/55a8b5b91a28ab26628b46ea/html5/thumbnails/18.jpg)
Bluetooth モジュールあれこれ(BT 2.0)
HC-05
Mater/Slave両方可能なBT 2.0モジュール1,400円~$3程度
HC-06
Salve専用のBT2.0モジュール1,000円から$3程度
![Page 19: Arduino tank meets bluetooth](https://reader033.vdocuments.site/reader033/viewer/2022051016/55a8b5b91a28ab26628b46ea/html5/thumbnails/19.jpg)
Bluetooth モジュールあれこれ(BT 2.0)
HC-09
Slave専用のBT 2.0モジュール$3程度
![Page 20: Arduino tank meets bluetooth](https://reader033.vdocuments.site/reader033/viewer/2022051016/55a8b5b91a28ab26628b46ea/html5/thumbnails/20.jpg)
BT 2.0 の SPP通信を使う
BT 2.0 のモジュールは手に入りやすいので手始めに使いやすい。
HC-05 でシリアルピンついている
LEGO EV3 等の制御も SPP 通信が使われているので応用が利く。
Androidの古い機種でも動く
中古 SC-06D を買ってしまったので
Xamarin.Android が使える
![Page 21: Arduino tank meets bluetooth](https://reader033.vdocuments.site/reader033/viewer/2022051016/55a8b5b91a28ab26628b46ea/html5/thumbnails/21.jpg)
Arduino スケッチ
Serial クラスを使う
Serial.available() でデータ長チェック
Serial.read() で1バイトずつ読み込み
コマンド毎にモーターとLEDを制御
Serial.write() で応答を返せる
距離センサーこれで返すと良い。
9600bpsでオープン
データ受信
モーター駆動
![Page 22: Arduino tank meets bluetooth](https://reader033.vdocuments.site/reader033/viewer/2022051016/55a8b5b91a28ab26628b46ea/html5/thumbnails/22.jpg)
Windows ストアアプリから接続
RFCOMMを有効にする
![Page 23: Arduino tank meets bluetooth](https://reader033.vdocuments.site/reader033/viewer/2022051016/55a8b5b91a28ab26628b46ea/html5/thumbnails/23.jpg)
Windows ストアアプリから接続
RFCOMMでシリアル接続
接続先を検索
接続
![Page 24: Arduino tank meets bluetooth](https://reader033.vdocuments.site/reader033/viewer/2022051016/55a8b5b91a28ab26628b46ea/html5/thumbnails/24.jpg)
Windowsストアプリから制御
データ送信
![Page 25: Arduino tank meets bluetooth](https://reader033.vdocuments.site/reader033/viewer/2022051016/55a8b5b91a28ab26628b46ea/html5/thumbnails/25.jpg)
Android から接続
シリアル接続
BTオープン
接続先を検索
![Page 26: Arduino tank meets bluetooth](https://reader033.vdocuments.site/reader033/viewer/2022051016/55a8b5b91a28ab26628b46ea/html5/thumbnails/26.jpg)
Android から制御
データ送信
![Page 27: Arduino tank meets bluetooth](https://reader033.vdocuments.site/reader033/viewer/2022051016/55a8b5b91a28ab26628b46ea/html5/thumbnails/27.jpg)
WPF から接続
WinRTを利用可能にする
Windows.winmd が設定可能
![Page 28: Arduino tank meets bluetooth](https://reader033.vdocuments.site/reader033/viewer/2022051016/55a8b5b91a28ab26628b46ea/html5/thumbnails/28.jpg)
NetduinoでSPP受信
9600bpsでオープン
データ受信
LED点滅
![Page 29: Arduino tank meets bluetooth](https://reader033.vdocuments.site/reader033/viewer/2022051016/55a8b5b91a28ab26628b46ea/html5/thumbnails/29.jpg)
参考文献
Arduino – Home
Arduino - open-source tool for electronic projects
Netduino :: home
Mobile App Development & App Creation Software – Xamarin
Bluetooth Low Energyをはじめよう (Make:PROJECTS)
Bluetooth SMART デバイス(LE GATT Profile)と連携するWindows Store Appsの開発 - デバイスとITの架け橋 - Site Home - MSDN Blogs
Bluetooth GATT | Specifications | Bluetooth Development Portal
【連載】Bluetooth LE (2) iOS デバイスで Bluetooth LE 機器を使う (フェンリル | デベロッパーズブログ)
「ハルロック」http://www.moae.jp/comic/harurock/1/1
![Page 30: Arduino tank meets bluetooth](https://reader033.vdocuments.site/reader033/viewer/2022051016/55a8b5b91a28ab26628b46ea/html5/thumbnails/30.jpg)
購入先
CC2541 SensorTag 開発キット
BLEduino - BLE For Arduino 〈 Arduino 〉
mbed HRM1017
BLE 開発キット with J-Link segger:BVMCN5103-BK KIT PLUS
HC-06ワイヤレス ブルートゥースモジュール
HM-10 CC2540 4.0 BLE bluetooth to uart transceiver Module
BLE Shield — RedBearLab
MyBeacon® Fun MB005 Ac | 株式会社アプリックス
hc 09 RF Wireless Bluetooth Transceiver Module RS232
netduino 2 -スイッチサイエンス