arduino GPS incorrect location

Hey, I've been trying to interface a GPS module with my arduino and i am getting the values in the serial monitor, but whenever i put those values in google maps i get an incorrect location which is around 60-70km off track. i did the appropriate conversion of say to dd.mmmm for lat and lon .. but i still dont see the right location.. Any help would be appreciated..thanks..

It would be nice to see your code.

hey thanks a lot for your reply… im using the code available in the arduino playground…

 #include <string.h>
 #include <ctype.h>
 int ledPin = 13;                  // LED test pin
 int rxPin = 0;                    // RX PIN 
 int txPin = 1;                    // TX TX
 int byteGPS=-1;
 char linea[300] = "";
 char comandoGPR[7] = "$GPRMC";
 int cont=0;
 int bien=0;
 int conta=0;
 int indices[13];
 void setup() {
   pinMode(ledPin, OUTPUT);       // Initialize LED pin
   pinMode(rxPin, INPUT);
   pinMode(txPin, OUTPUT);
   for (int i=0;i<300;i++){       // Initialize a buffer for received data
     linea[i]=' ';
 void loop() {
   digitalWrite(ledPin, HIGH);;         // Read a byte of the serial port
   if (byteGPS == -1) {           // See if the port is empty yet
   } else {
     linea[conta]=byteGPS;        // If there is serial port data, it is put in the buffer
     Serial.print(byteGPS, BYTE); 
     if (byteGPS==13){            // If the received byte is = to 13, end of transmission
       digitalWrite(ledPin, LOW); 
       for (int i=1;i<7;i++){     // Verifies if the received command starts with $GPR
         if (linea[i]==comandoGPR[i-1]){
       if(bien==6){               // If yes, continue and process the data
         for (int i=0;i<300;i++){
           if (linea[i]==','){    // check for the position of the  "," separator
           if (linea[i]=='*'){    // ... and the "*"
         Serial.println("");      // ... and write to the serial port
         for (int i=0;i<12;i++){
             case 0 :Serial.print("Time in UTC (HhMmSs): ");break;
             case 1 :Serial.print("Status (A=OK,V=KO): ");break;
             case 2 :Serial.print("Latitude: ");break;
             case 3 :Serial.print("Direction (N/S): ");break;
             case 4 :Serial.print("Longitude: ");break;
             case 5 :Serial.print("Direction (E/W): ");break;
             case 6 :Serial.print("Velocity in knots: ");break;
             case 7 :Serial.print("Heading in degrees: ");break;
             case 8 :Serial.print("Date UTC (DdMmAa): ");break;
             case 9 :Serial.print("Magnetic degrees: ");break;
             case 10 :Serial.print("(E/W): ");break;
             case 11 :Serial.print("Mode: ");break;
             case 12 :Serial.print("Checksum: ");break;
           for (int j=indices[i];j<(indices[i+1]-1);j++){
       conta=0;                    // Reset the buffer
       for (int i=0;i<300;i++){    //  
         linea[i]=' ';             

That code is not converting the string data from the GPS to any floats.

im getting a similar output like the one in the GPS playground…
ex : $GPRMC,074516.000,A,1300.8067,N,07733.0003,E,0.00,349.99,2701$GPGGA,074517.000,1300.8067,N,07733.0003,E,1,6,2.26,910.4,M,-88.1,M,*74

so if i filter out this part 1300.8067,N,07733.0003,E and then shift the decimals to

13.008067,077.330003 and put them in google maps i see a location which is around 40-50km off track… is there any specific conversion i need ot do with the above output to get the right co ordinates?

thanks for your reply…

That's not the correct way to convert the lat and long. The latitude is formatted as DDMM.ffff and longitude is DDDMM.ffff where D is the degrees and M is minutes plus the fractional minutes. So, 1300.8067,N is 13 degrees 00.8067 minutes North and the longitude of 07733.0003,E is read as 77 degrees 33.0003 minutes East. Converting to degrees you would have to do this: 13 + 00.8067/60 for latitude and 77 + 33.0003/60 for the longitude.


1 Like

thank you so much for your reply.. that really helped.. I did the conversion as you said and it gave me the exact location...thank you :)