Dana Mah
Created March 5, 2019 © GPL3+

ATV GPS Tracker

This is a device that will record everywhere your ATV has been. Its activated when the bike is turned on.

IntermediateWork in progress3 hours19
ATV GPS Tracker

Things used in this project

Story

Read more

Code

Spresense Code

Arduino
This code will start the GNSS and SD modules in the SpreSense. I will read the GPS data and store it in a file.
#include <GNSS.h>
#include <SDHCI.h>

SDClass SD;
File myFile;
SpGnss gps;

void setup() {
  Serial.begin(115200);
  sleep(5);

  if (gps.begin() != 0)  {
    Serial.println("GPS failed!");
  } else {
    gps.select(GPS);
    gps.select(SBAS);
    if (gps.start(COLD_START) != 0)    {
      Serial.println("GPS error!!");
    } else {
      Serial.println("GPS OK");
    }
  }
}

void loop() {
  if (gps.waitUpdate(-1)) {

    SpNavData NavData;
    gps.getNavData(&NavData);

    Serial.print(NavData.latitude);
    Serial.print(",");
    Serial.println(NavData.longitude);

    // Write the latitude and longitude to a file that can be imported to GPS Visulator
    myFile = SD.open("gps.txt", FILE_WRITE);
    if (myFile) {
      myFile.print(NavData.latitude);
      myFile.print(",");
      myFile.println(NavData.longitude);
      myFile.close();
    } else {
      Serial.println("error opening gps.txt");
    }
  } else {
    Serial.println("no new data");
  }
}

Credits

Dana Mah

Dana Mah

11 projects • 15 followers
I'm a hobbyist interested in microcontroller solutions to simple problems.

Comments