Arduino_Genuino
Published © CC BY

Gnome Traveller

Our Gnome is ready to follow you in your travels and keep track of all the places you visit, thanks to a GPS shield and the Nano Every.

IntermediateFull instructions provided904
Gnome Traveller

Things used in this project

Hardware components

Arduino Nano Every
Arduino Nano Every
×1
Arduino MKR GPS Shield
×1
MicroSD Card with Adapter
Digilent MicroSD Card with Adapter
×1
Level Shifter Board
SparkFun Level Shifter Board
×2
Power Bank Electronics
×1
Li-Ion Battery 1000mAh
Li-Ion Battery 1000mAh
×1
Slide Switch
Slide Switch
×1
Wire, Wrapping Wire
Wire, Wrapping Wire
×1

Hand tools and fabrication machines

3D Printer (generic)
3D Printer (generic)
Soldering iron (generic)
Soldering iron (generic)

Story

Read more

Custom parts and enclosures

Gnome lower part

3D print it to create the Gnome lower part

Gnome upper part

3D print this to create a full gnome joining it with the lower part

Code

Gnome Tracker

Arduino
Load this sketch and compile it after you have downloaded TinyGPSPlus library from http://arduiniana.org/libraries/tinygpsplus/
#include <TinyGPS++.h>
#include <SPI.h>
#include <SD.h>

TinyGPSPlus gps;

int chipSelect = 4;   // digital pin 4 for the SD cs line
File logfile;// the logging file

//data logger timing and other
long logPace=10000; // 10 seconds between entries
long readTime = 0; // time of last read()
#define DEBUG 1 // echo GPS data to serial port for debug purposes

void setup() {
  Serial.begin(115200);
  Serial1.begin(9600);  // our module communicates at 9600
  delay(1000);
  Serial.println("Basic Initialization");  // we sen something to the consolle

  // initialize the SD card
  Serial.print("Initialising SD card...");

  // see if the card is present and can be initialized:
  if (!SD.begin(chipSelect)) {
    Serial.println("Card read failed, or not present");
    // Stop the sketch
    return;
  }
  Serial.println("card initialized.");

  // create a new file
  char filename[] = "GnomeT00.CSV";
  for (byte i = 0; i < 100; i++) {
    filename[6] = i / 10 + '0';
    filename[7] = i % 10 + '0';
    if (! SD.exists(filename)) {
      // open the next file in the numbered sequence
      logfile = SD.open(filename, FILE_WRITE);
      break;  // leave the loop!
    }
  }

  Serial.print("Logging to: ");
  Serial.println(filename);

  logfile.println("latitude, longitude, altitude, date, time");

#if DEBUG   //serial debug active?
  Serial.println("Serial Debug Active");
  Serial.println();
  Serial.println("latitude,  longitude, date,     time,     altitude");
#endif// we show the columns for the data sent to console

#if !DEBUG   //serial debug deactivated
  Serial.println("No Serial Debug");
#endif
}

void loop() {

  while (Serial1.available() > 0)
  {
    gps.encode(Serial1.read());
    if (gps.location.isValid())
    {
      if ((millis() - readTime) < logPace) return;
      readTime = millis();
      logfile.print(gps.location.lat(), 6);
      logfile.print(", ");
      logfile.print(gps.location.lng(), 6);
      logfile.print(", ");
      logfile.print(gps.altitude.meters(), 0);
      logfile.print(", ");  
      logfile.print(gps.date.day());
      logfile.print(F("/"));
      logfile.print(gps.date.month());
      logfile.print(F("/"));
      logfile.print(gps.date.year());
      logfile.print(", ");
      if (gps.time.hour() < 10) logfile.print(F("0"));
      logfile.print(gps.time.hour());
      logfile.print(F(":"));
      if (gps.time.minute() < 10) logfile.print(F("0"));
      logfile.print(gps.time.minute());
      logfile.print(F(":"));
      if (gps.time.second() < 10) logfile.print(F("0"));
      logfile.print(gps.time.second());
      logfile.println("");
#if DEBUG   //serial debug active?
      Serial.print(gps.location.lat(), 6);
      Serial.print(", ");
      Serial.print(gps.location.lng(), 6);
      Serial.print(", ");
      Serial.print(gps.date.day());
      Serial.print(F("/"));
      Serial.print(gps.date.month());
      Serial.print(F("/"));
      Serial.print(gps.date.year());
      Serial.print(", ");
      if (gps.time.hour() < 10) Serial.print(F("0"));
      Serial.print(gps.time.hour());
      Serial.print(F(":"));
      if (gps.time.minute() < 10) Serial.print(F("0"));
      Serial.print(gps.time.minute());
      Serial.print(F(":"));
      if (gps.time.second() < 10) Serial.print(F("0"));
      Serial.print(gps.time.second());
      Serial.print(", ");
      Serial.print(gps.altitude.meters(), 0);
      Serial.println("      ");
#endif
      logfile.flush();        //write data to disk
    }
  }
}

Credits

Arduino_Genuino

Arduino_Genuino

63 projects • 5473 followers

Comments

Add projectSign up / Login