0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

obniz で GPS情報を取ってみた(取れるとは言ってない)

Last updated at Posted at 2019-07-06

はじめに

GPS情報を使ってなんかしたいので、手元にあったobnizでとりあえずやってみました。

用意するもの

GPS受信機キット 1PPS出力付き 「みちびき」3機受信対応
!!! はんだづけが必要 !!!
iOS の画像.jpg

iOS の画像 (1).jpg

obniz

完成したGPS受信機をぶっこみます
iOS の画像 (2).jpg

事前知識

GPSを受信するといろんな形式のデータがわさわさと取れます

$GPGGA,235944.799,,,,,0,0,,,M,,M,,*42
$GPGLL,,,,,235944.799,V,N*70
$GPGSA,A,1,,,,,,,,,,,,,,,*1E
$GPGSV,1,1,00*79
$GP
RMC,235944.799,V,,,,,0.00,0.00,050180,,,N*4B
$GPVTG,0.00,T,,M,0.00,N,0.00,K,N*32
$GPZDA,235944.799,05,01,3880,,*5B

それぞれがどういう形式なのか気になる方はこちらから
https://www.hiramine.com/physicalcomputing/general/gps_nmeaformat.html

その中でも今回は、GPGGAという形式のデータを使います

コード

$npm i obniz
$npm i gps

gps.js
const Obniz = require('obniz');
const GPS = require('gps')
var gps = new GPS;

gps.on('data', function(parsed) {
    console.log(parsed);
});

var obniz = new Obniz("xxxx-xxxx");
obniz.onconnect = async function () {
  
  obniz.display.clear();
  obniz.display.print("Hello World");
  
  obniz.io0.output(1);
  obniz.io1.output(0);
  const uart = obniz.getFreeUart();
  uart.start({tx: 2, rx: 3, baud:9600, drive:"3v"});
  
  var satellites = {};
    
  uart.onreceive = function(data, text) {
    obniz.display.print(text);
      
    if (typeof text === "string") {
      var lines = text.split('\n');
      for(var i = 0; i < lines.length; i++){
        if (lines[i].indexOf("$GPGGA") >= 0 ) {
          console.log( gps.update(lines[i]) )
        }
      }    
    }
  }
}
node gps.js

これで受信したGPSのGGA形式のデータをパースしてくれるはずなんだけど、屋内だからなのか、うまく緯度経度が取れません(泣)
obnizを利用しているので、wifiがある前提だから、外を歩き回るのも難しい。。。

{ time: 2019-07-06T23:59:52.800Z,
  lat: null,
  lon: null,
  alt: null,
  quality: null,
  satellites: 0,
  hdop: null,
  geoidal: null,
  age: null,
  stationID: null,
  raw: '$GPGGA,235952.800,,,,,0,0,,,M,,M,,*4A\r',
  valid: true,
  type: 'GGA' }

参考にさせていただいた記事

obnizとGPSモジュールで地図(その1)

準天頂衛星「みちびき」の信号をobnizで受信する

追記

SDKありました...

const Obniz = require('obniz');

var obniz = new Obniz("xxxx-xxxx");
obniz.onconnect = async function () {
  
    obniz.display.clear();
    obniz.display.print("Hello World");
   
    let gps = obniz.wired("GYSFDMAXB", { vcc:7, gnd:8, txd:9, rxd:10, Opps:11 });
    let gpsInfo = gps.getGpsInfo();
    console.log(gpsInfo);
}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?