GPSロガー


On this page

GPS受信機

秋月で安いGPS受信機を見つけたのでこれを使う。
USB接続のものもあるが、接続をコンパクトに収めたいのでバラ線のものを使うことにした。

Raspberry piへの接続

データシートを参考に接続する。
線は全部で5本あり、赤,黒,橙,緑,茶に分かれている。赤はVCCなのでraspi側の5V出力に、黒はGNDなのでraspi側のGNDに接続するのでわかりやすい。 橙と緑はそれぞれTxD,RxDとなっているがシリアル通信では逆に繋げる必要があるので、それぞれraspi側のRxD,TxDにつなげること

シリアル通信

Raspberry Piにまずscreen等のシリアル通信のテストができる環境があるか確認しなければインストール。
インストール後シリアル通信のための準備をする。まずはraspi-configでシリアル通信を許可する。 このときシリアルコンソールは不許可でOK。 下記のコマンドでシリアル通信を開始する。

$ screen 9600 /dev/ttyS0
  $GNGGA,<UTC position>,<Latitude>,N,<Longitude>,E,1,<Satellites Used>,1.46,<MSL Altitude>,M,<Geoids separation>,M,,<Check sum>
  $GNGSA,A,3,<Satellites Used>,<Satellites Used>,<Satellites Used>,<Satellites Used>,<Satellites Used>,<Satellites Used>,<Satellites Used>,<Satellites Used>,,,,,2.56,1.46,2.10*1D
  $GPGSV,3,1,<Satellites in view>,<Satellites ID>,<Elevation>,<Azinmuth>,<SNR>,<Satellites ID>,<Elevation>,<Azinmuth>,<SNR>,<Satellites ID>,<Elevation>,<Azinmuth>,<SNR>,<Satellites ID>,<Elevation>,<Azinmuth>,<SNR>*74
  $GPGSV,3,2,<Satellites in view>,<Satellites ID>,<Elevation>,<Azinmuth>,<SNR>,<Satellites ID>,<Elevation>,<Azinmuth>,<SNR>,<Satellites ID>,<Elevation>,<Azinmuth>,<SNR>,<Satellites ID>,<Elevation>,<Azinmuth>,<SNR>*78
  $GPGSV,3,3,<Satellites in view>,<Satellites ID>,<Elevation>,<Azinmuth>,<SNR>,<Satellites ID>,<Elevation>,<Azinmuth>,<SNR>,<Satellites ID>,<Elevation>,<Azinmuth>,<SNR>*46
  $GLGSV,1,1,00*65
  $GNGLL,<Latitude>,N,<Longitude>,E,<UTC position>,A,A*7D
  $GNRMC,<UTC position>,A,<Latitude>,N,<Longitude>,E,<Speed over ground>,,<Date(ddmmyy)>,,,A*66
  $GNVTG,,T,,M,<Speed>,N,<Speed>,K,A*35

この9600はボーレートでこのGPS受信機はデフォルトで9600に設定されている。