NEO-6M SD Card CSV Errors

Hi there,

First off- I am a beginner with all this, so forgive me if I am being an idiot!

I am doing a project for college and the aim is to log GPS info onto an SD card. The GPS information is printed in a 'CSV' string to the card, which is imported into google fusion tables.

I have the GPS and SD card reader working together, and the information is printing to the SD card as it should. My problem however, is that the "string" seems to mess up every so often, seemingly a speed issue. The information printed to the card is as follows- : "TIME, LATITUDE, LONGITUDE, SPEED".

The program uses the TinyGPS+ library, which tells it to print the following information to the SD each loop. What seems to happen is that the speed takes too long to update on some cycles, which causes the string to start again, until the speed is updated and it then carries on.

I originally thought that this was a baudrate issue from the GPS working faster than the program could, but after lowering the GPS baudrate, the problem still occurs (see the attached GPS image). I also tried adding a delay at the end of each loop, which made no difference.

Any ideas how I could fix this? Is there a command which I could put in the code which waits for all the information required from the GPS, before printing it and moving on to the next line?

I have also attached my code.

Thanks :slight_smile: :slight_smile: :slight_smile:

CollegeArduinoGPSwithSD.ino (2.42 KB)

The program uses the TinyGPS+ library

No such thing. There IS a TinyGPS++ library...

SoftwareSerial ss(RXPin, TXPin);     // The serial connection to the GPS device

There is nothing magic in the name. gps or ssGPS would make it clear(er) what the instance was for.

    gps.encode(ss.read());     //GPS data read

gps.encode() returns a value. It is foolish to ignore the value that it returns.

    Serial.flush();

Block until all pending output data has been sent. Why is THIS necessary?

  while (ss.available() < 0)     //when GPS data stops
  {
  
  datafile.close();     //close the file on SD card
  Serial.println("GPS signal lost, file closed");
}

If there is no data to read, available() will return 0. Under no circumstances will it return a negative number, so this while loop was a waste of effort, and will NOT do what the comments claim.

Opening the file, when there may not be anything to write to it is pointless. Closing the file that you may not have opened is just plain wrong.

Thanks for the response, I understand your comments and will make those changes, however will these solve the problem I am referring to?

Thanks