Raspberry PiにBluetoothでGPSレシーバを接続する

前提条件

項目 条件
本体 Raspberry Pi 3 Model B
OS Raspberry Pi OS 5.4.79-v7+ (Raspbian Buster)
GPS 747 Pro

1.ペアリング

pi@raspberrypi:~ $ bluetoothctl
[bluetooth]# scan on
(※1)
[bluetooth]# scan off
[bluetooth]# pair **:**:**:**:**:**
(※2)
[bluetooth]# connect **:**:**:**:**:**
(※3)
[bluetooth]# trust **:**:**:**:**:**
[bluetooth]# quit

(※1)ここでMACアドレスを取得。
[NEW] Device ::::: 747PRO GPS
(※2)PINコード入力
Enter PIN code: 0000
(※3)以下のエラーメッセージが出ますが、問題なし。もしかしたら、コマンド自体不要?
Attempting to connect to :::::
[CHG] Device ::::: Connected: yes
[CHG] Device ::::: ServicesResolved: yes
Failed to connect: org.bluez.Error.NotAvailable
[CHG] Device ::::: ServicesResolved: no
[CHG] Device ::::: Connected: no

2.シリアル通信の設定

USB接続とは異なり、Bluetooth接続の場合、シリアル通信の受け口を作成する必要があります。

pi@raspberrypi:~ $ sudo rfcomm bind 0 **:**:**:**:**:**

bind の後の0はデバイス番号。0だと、/dev/rfcomm0に接続されます。
起動時に自動接続するために、/etc/rc.localに追記しておきます。

3.動作確認

catコマンドで確認してみます。

pi@raspberrypi:~ $ cat /dev/rfcomm0
$GPGGA,012004.445,,,,,0,0,,,M,,M,,*4A
$GPGSA,A,1,,,,,,,,,,,,,,,*1E
$GPGSV,1,1,01,15,61,030,*48
$GPRMC,012004.445,V,,,,,0.00,0.00,140501,,,N*4E
$GPGGA,012004.800,,,,,0,0,,,M,,M,,*47

返信を残す

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