Go Down

Topic: Arduino GPS Shield by iteadstudio.com (Read 39 times) previous topic - next topic

troyka_4484

Hi,

Yesterday i bought this arduino GPS shield http://iteadstudio.com/application-note/play-arduino-with-global-positioning-system-gps/
there's a demo for this shield, it saves the GPS data in a text file located on the sd card.
But I just want to extract the longitude and latitude from the GPS shield and post them on the serial interface...
does anyone have any idea??

thank you in advance!

troyka_4484

here's the demo code for the GPS shield
Code: [Select]
#include <SD.h>
const int chipSelect = 10;
void setup()
{
  Serial.begin(9600);
 
  pinMode(10, OUTPUT);
  if (!SD.begin(chipSelect)) {
   
    return;
  }

}

void loop()
{
  // make a string for assembling the data to log:
  char index = 0;
  char temp = 0;
  String dataString = "";
  // open the file. note that only one file can be open at a time,
  // so you have to close this one before opening another.
  /*
    while(Serial.available())
    {
      File dataFile = SD.open("datalog.txt", FILE_WRITE);
      if(dataFile)
      {
        temp = Serial.read();
        dataString += String(temp);
        dataFile.print(dataString);
        dataString = "";
        dataFile.close();
      }
    }
  */ 
File dataFile = SD.open("datalog.txt", FILE_WRITE);
if(dataFile)
{
   while(Serial.available())
   {
     temp = Serial.read();
     dataString += String(temp);
     index++;
     if(index>200)
       break;
   }
   dataFile.print(dataString);
   dataFile.close();
}
}


PaulS

Quote
does anyone have any idea??

I think that opening and closing the file for each character written to it is a pretty lame idea. Good thing that code is commented out.

Why did you leave all that commented out code in there, anyway?

In the code that is actually running, you keep accumulating data in the String dataString. After writing that data to the file, you'd think that it would be important to reset dataString to an empty string.

Regardless, there is a perfectly good library, TinyGPS, that can be used to collect the data from the GPS, and parse that data. You simply use the class methods, then, to get the data of interest.

If you want to parse the data AND save it to a text file, you'll need to modify the TinyGPS library to get the complete sentence, or modify the example that comes with TinyGPS to also write the character to the file.

I'd suggest the former, to minimize how often you need to open and close the file.

troyka_4484

Thanks Paul.

I just posted the code i downloaded from the GPS shield Site.
and i discovered TinyGPS this morning, it's a magnificent library, but i am having an issue in locating the rx and tx pins on the GPS shield.
On the datasheet there's a table describing the pins...
here's the datasheet:
http://iteadstudio.com/store/images/produce/Shield/Shields/gpsshield/ArduinoGPSshield_DS.pdf

Although the baud rate used in the GPS i have is 38400.
I am a  very beginner with handling a GPS...

Regards

PaulS

Quote
here's the demo code for the GPS shield

Does it work? If so, the GPS is connected to the hardware serial pins (0 and 1).

Go Up