Boaz Lawnce
Published © GPL3+

Marco Polo || Mega Route Logger

Track and save your foot path.

IntermediateShowcase (no instructions)1,175
Marco Polo || Mega Route Logger

Things used in this project

Hardware components

Arduino Mega 2560 & Genuino Mega 2560
Arduino Mega 2560 & Genuino Mega 2560
×1
Jumper wires (generic)
Jumper wires (generic)
×15
GPS receiver (generic)
×1
microSD module
×1

Software apps and online services

Arduino IDE
Arduino IDE
Google Sheets
Google Sheets

Story

Read more

Schematics

Circuit Diagram

I Used SKG13BL GPS Module

Code

Code

C/C++
/*
  SD card datalogger using Mega2560 - Boaz & Priyatharshini
 ** MOSI - pin 51
 ** MISO - pin 50
 ** CLK - pin 52
 ** CS - pin 53
*/
#include <SoftwareSerial.h>
#include <TinyGPS.h>
#include <SPI.h>
#include <SD.h>

SoftwareSerial mySerial(10, 11);
TinyGPS Bz_gps;

long lat, lon;
unsigned long time, date, speed, course;
unsigned long chars;
unsigned short sentences, failed_checksum;

int year;
int fkmph;
byte month, day, hour, minute, second, hundredths;
unsigned long fix_age;

String dataString = "";
const int chipSelect = 53;

void setup()
{
  mySerial.begin(9600);
  Serial.begin(9600);
  pinMode(53, OUTPUT);
  if (!SD.begin(chipSelect))
  {
    Serial.println("Card failed, Check MOSI & MISO pin Connection");
    return;
  }
  Serial.println("card initialized.");
}
void loop()
{
  if (mySerial.available())
  {
    char c = mySerial.read();
    //Serial.write( c );
    if (Bz_gps.encode( c ))
    {
      Bz_gps.get_position(&lat, &lon, &fix_age);
      Bz_gps.get_datetime(&date, &time, &fix_age);
      speed = Bz_gps.speed();
      course = Bz_gps.course();
      Bz_gps.crack_datetime(&year, &month, &day, &hour, &minute, &second, &hundredths, &fix_age);
      int fkmph = Bz_gps.f_speed_kmph();
      dataString = String(day) + "," + String(month) + "," + String(year) + "," + String(hour) + "," + String(minute) + "," + String(second) + "," + String(lat) + "," + String(lon) + "," + String(fkmph);
      Serial.println(dataString);
      File dataFile = SD.open("datalog.txt", FILE_WRITE);
      if (dataFile)
      {
        dataFile.println(dataString);
        dataFile.close();
      }
      else
      {
        Serial.println("error opening datalog.txt");
      }
    }
  }
}

Credits

Boaz Lawnce

Boaz Lawnce

11 projects • 30 followers
Electronics Engineer, Founder, Hobbyist....

Comments