LoginSignup
2
4

More than 5 years have passed since last update.

arduinoでgpsロガー

Last updated at Posted at 2017-09-27

概要

arduinoでgpsロガーやってみた。

写真

log.JPG

結果

サンプルコード

#include <Arduino.h>
#include "TinyGPS.h"
#include <SoftwareSerial.h>


TinyGPS gps;
SoftwareSerial ss(10, 11);

void setup()
{
    Serial.begin(9600);
    ss.begin(9600);
    while (!Serial)
    {
        ;
    }
    Serial.println("start!");
}
void loop()
{
    bool newData = false;
    float lat = 0;
    float lon = 0;
    unsigned long age;
    while (ss.available())
    {
        char u = ss.read();
        if (gps.encode(u)) newData = true;
    }
    if (newData)
    {
        gps.f_get_position(&lat, &lon, &age);
        Serial.print('"');
        Serial.print(lat, 7);
        Serial.print(",");
        Serial.print(lon, 7);
        Serial.print('"');
        Serial.println(",");
    }
}



以上

2
4
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
2
4