More Related Content Similar to 技適なBluetooth GNSS/GPSレシーバーをRaspberryPiで作りたい (20) More from Kenichiro MATOHARA (20) 技適なBluetooth GNSS/GPSレシーバーをRaspberryPiで作りたい2. Kenichiro MATOHARA
● @matoken
● http://matoken.org/
● 興味
– Linux
– FLOSS
– OpenSteetMap
– 電子工作
– :
© OpenStreetMapへの協力者
4. 鹿児島らぐ
● 今のところ鹿児島Linux勉強会を月1回開催
– 今回第6回で0回目から数えて7回目の開催
● 鹿児島Linux勉強会
– Linux読書会
– Linux関連の発表
– その他…
● これからの予定
– 来月オープンソースカンファレンス2014福岡出展
http://www.ospn.jp/osc2014-fukuoka/
– オープンソースアンカンファレンス鹿児島開催
– OSMもそろそろやりたい
5. 精度の高いGPSモジュールを利用
して位置測定をしたい
● OpenStreetMap Foundation Japanの
miurahrさんの小江戸らぐ9月のオフな集まり発
表資料を見る
● "技適な Bluetooth GNSS/GPS レシーバー
の作成と活用”
● 面白そう!
● BluethoothSPPモジュールは持ってないけれど
RaspberryPiやUSB Bluethoothモジュールは
あるのでこれで真似したい
● ついでに単体でログ取りとかもするようにしたい
7. 用意したもの
● RaspberryPi B+(A/Bでもok)
● USB Bluethoothドングル
– 5種類くらい持っていてこれまでに使えなかった物はないが,購
入前に型番で検索して利用できるか確認したほうが無難
● OSはRaspberryPi標準のRasbianを利用(DebianWheezyベー
ス)
● TTLが出てるGPSモジュール(GT-723F 秋月電子で2,800)
● Android端末にSPP接続が出来るBluetooth Terminalを導入
(デバッグ用)
● Android端末にBluetoothGPS を使えるようにする
Bluetooth GPSを導入
10. Bluetooth デバイスの確認
$ hcitool dev
Devices:
hci0 E0:91:53:77:E8:99
$ hciconfig -a
hci0: Type: BR/EDR Bus: USB
BD Address: E0:91:53:77:E8:99 ACL MTU: 310:10 SCO MTU: 64:8
UP RUNNING PSCAN
RX bytes:10030 acl:8 sco:0 events:191 errors:0
TX bytes:1702 acl:8 sco:0 commands:111 errors:0
Features: 0xff 0xff 0x8f 0xfe 0x9b 0xbf 0x59 0x87
Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3
Link policy: RSWITCH HOLD SNIFF PARK
Link mode: SLAVE ACCEPT
Name: 'raspberrypi-0'
Class: 0x420100
Service Classes: Networking, Telephony
Device Class: Computer, Uncategorized
HCI Version: 3.0 (0x5) Revision: 0x1aa1
LMP Version: 3.0 (0x5) Subversion: 0x1aa1
Manufacturer: Cambridge Silicon Radio (10)
11. 周りのデバイス検索
$ hcitool scan
Scanning ...
78:DD:08:B0:1F:37 x201s-0
98:91:20:21:55:78 Bluetooth Keyboard
● ※周りのデバイスは検索可能にしておく
12. ペアリングが可能なようにモードを変
更してペアリング
● ペアリング可能なようにモード変更
$ sudo hciconfig hci0 piscan
● ペアリング(ペアリングのキーはこの場合4835)
$ sudo bluetooth-agent 4835
Confirmation request of 396777 for device
/org/bluez/2150/hci0/dev_70_F9_27_71_74_5B
※ペア先のデバイスは検出可能にしておく
● 周りから見えないようにモードを戻しておく
$ sudo hciconfig hci0 noscan
14. SPPで接続して通信を試みる
$ sudo rfcomm listen /dev/rfcomm0 22
Waiting for connection on channel 22
Connection from 70:F9:27:71:74:5B to
/dev/rfcomm0
Press CTRL-C for hangup
● これで /dev/rfcomm0 を通してSPP通信が出来る
15. 実際に通信してみる
● 受信したり
$ cat /dev/rfcomm0
test
hello
hello pi
● 送信したり
$ echo "hello android" > /dev/rfcomm0
16. GPSモジュールを利用できるようにす
る
● RaspberryPiのGPIOのシリアルはシステムコン
ソールに割り当てられているのでこれを解除
● GPSモジュールとRaspberryPiの接続
● GPSモジュールから送られてきた情報を取得
17. RaspberryPiのシステムコンソール割
り当て解除
● /boot/cmdline.txt を以下のように編集(ここは要らないかも?)
編集前
dwc_otg.lpm_enable=0 console=ttyAMA0,115200
console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4
elevator=deadline rootwait
編集後
dwc_otg.lpm_enable=0 console=tty1 root=/dev/mmcblk0p2
rootfstype=ext4 elevator=deadline rootwait
● /etc/inittab の以下の行をコメントアウト若しくは削除
T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100
18. ついでにグループ追加して再起動して
反映
● pi ユーザでGPSモジュールが利用できるようにdialout
GROUP に pi USER を追加
●
$ sudo addgroup pi dialout
The user `pi' is already a member of `dialout'.
$ id
uid=1000(pi) gid=1000(pi) groups=1000(pi),20(dialout)
$ sudo reboot
21. ● 配線
GT-723F P1(GND) <---> Pi P1-06(GND)
GT-723F P2(PWR) <---> Pi P1-01(3.3V)
GT-723F P5(TTL-In) <---> Pi P14(TX)
GT-723F P6(TTL-Out) <---> Pi P1-15(RX)
23. GPSモジュールから送られてきた情報
を取得
● GPIOのRX/TXはRaspberryPi上では/dev/ttyAMA0に割り当てられている
● gpscatコマンド(python-gps pkg)で内容を取得する
$ sudo apt-get install python-gps
$ gpscat -s 9600 /dev/ttyAMA0
$GPRMC,120834.000,V,0000.0000,N,00000.0000,E,000.0,000.0,280606,,,N
*70
$GPGGA,120834.000,0000.0000,N,00000.0000,E,0,00,0.0,0.0,M,0.0,M,,000
0*61
$GPGSA,A,1,,,,,,,,,,,,,0.0,0.0,0.0*30
$GPGSV,2,1,07,02,63,062,,26,59,190,,05,55,342,,10,30,043,*7B
$GPGSV,2,2,07,29,24,314,,15,23,212,,12,07,232,*46
:
25. AndroidでGPS情報として表示
● Bluetooth GPSを利用
https://play.google.com/store/apps/details?id=
googoo.android.btgps
● 「Enabke Mock GPS Provider」にチェックを付け
ることで他のAndroidアプリでもGPS情報が利用
可能に
32. これから
● Bluethooth自動接続
● DiskのRO化(電源断に対処するため)
● GPSのデータをローカルに保存するようにする(領域を分けて保存できるようにする)
● 持ち運びやすくする
● 性能のいいGNSS GPS利用(SBU3333T MTK3333 TTLレベル 中国GPS北斗対
応)
● iOS対応
● GPSコマンド利用
● その他
– BUN/PAN等のプロトコルも試してみたい(Bluethoothモバイルルータ化)
33. 参考URL
● "技適な Bluetooth GNSS/GPS レシーバーの作成
と活用"
https://dl.dropboxusercontent.com/u/9077946
0/Bluetooth_GNSS_receiver_201409.pdf
● "ja/BluetoothUser - Debian Wiki"
https://wiki.debian.org/ja/BluetoothUser
● "Gentoo Linux ドキュメント -- Gentoo Linux
Bluetoothガイド"
https://www.gentoo.org/doc/ja/bluetooth-guide.
xml