Pages: [1]   Go Down
Author Topic: Reading GPS data  - SOLVED  (Read 1559 times)
0 Members and 1 Guest are viewing this topic.
Bulgaria
Offline Offline
Newbie
*
Karma: 0
Posts: 2
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi everyone.
I'm trying to use GPS data coming from PMB-248 GPS Receiver in order to calculate distance to my target. When I use Serial.print(GPS.read(),BYTE); I see all NMEA data. I use char array to store specific parts of the NMEA data, however if I print this char array the displayed data misses every second symbol. I'm using the following code
Code:
#include <SoftwareSerial.h>

SoftwareSerial GPS(2,300); // rx pin = 2 for GPS
char tag[6], gpsData[60];

void setup()
{
  GPS.begin(4800);
  Serial.begin(9600);
}

void GPSRead()
{
  while(1)
  {
    if(GPS.read() == '$')
    {
      for(int i=0;i<6;i++)
      {
        tag[i] = GPS.read();  
      }
      if(memcmp(tag, "GPGGA,",6) == 0)
      {
        GPSCollect();
        break;
      }
    }
  }
  Serial.println(gpsData);
}

void GPSCollect()
{
  for(int i=0;i<60;i++)
  {
    gpsData[i] = GPS.read();
    if(GPS.read()=='*')
    {
      break;
    }
  }
}

void loop()
{
  GPSRead();
}
The data should come out like this:
183356,4239.4169,N,02321.3495,E,0,00,,00655.8,M,036.9,M,,
but the char array stores only this:
140,2946,,22.45E00,0658M069M,

I'm not sure what I'm missing here...
I'll appreciate your help.

Best regards,
Morwel
« Last Edit: October 21, 2010, 03:35:20 pm by Morwel » Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 310
Posts: 26632
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
   gpsData[i] = GPS.read();
    if([glow]GPS.read()=='*'[/glow])
You're reading, but not storing in the highlighted section.

Did you mean:
Code:
   gpsData[i] = GPS.read();
    if(gpsData[i] =='*')
?
« Last Edit: October 21, 2010, 03:27:57 pm by AWOL » Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Bulgaria
Offline Offline
Newbie
*
Karma: 0
Posts: 2
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

AWOL, thank you so much. This change fixed the problem.
Logged

Pages: [1]   Go Up
Jump to: