GPS rarely receives a valid string

Hi guys,

I am using an Arduino Uno on which I have connected an em-406a GPS. The only GPS string that is useful for me is the one with the $GPGGA code.

The validations that I run on each received string is that the $GPGGA code exists, I tokenize the string and I check that there are at least 10 parts and that the checksum exists, too.

My problem here is that I receive a valid string once a minute with a bit of luck. Shouldn't I be receiving a valid string at most every 10 seconds?

Any ideas would be appreciated.

Thank you in advance, gabys

Can you just print out each string you receive from the GPS unit to check that you are in fact receiving 'good' data?

Then narrow it down to the type of interest, and when you know that is working as expected do your processing.

I was displaying each string on the Serial Monitor and most of the strings, regardless of the type of string, it was either incomplete or invalid in general.

Can we have a link to the device you are using, and details of any libraries? It sounds like it’s not connected right. I’m assuming that you are using it with a clear view of the sky for testing, and not buried deep inside a building somewhere?

Can we have a link to the device you are using

details of any libraries

I am using the AltSoftSerial library for the GPS. Here is link about it: http://www.pjrc.com/teensy/td_libs_AltSoftSerial.html

Note: I am using an xbee S2B module to transmit the gps string to another xbee S2B module for further processing

My Code:

#include <XBee.h>
#include <SoftwareSerial.h>
#include <AltSoftSerial.h>
#include <stdio.h>

// Define SoftwareSerial TX/RX pins
#define xbeeRX 2
#define xbeeTX 3
//create xbee connection
SoftwareSerial xbeess = SoftwareSerial(xbeeRX, xbeeTX);
//create gps connection. it uses pin 8(Rx) and pin 9(Tx)
AltSoftSerial gpsss;

//Create an XBee object
XBee xbee = XBee();

char gpsstr[256] = "";
const char *deviceid = "23,";
const char *xbeeextension = "\n\r";
char c;

//Define the Destination address of the packets
XBeeAddress64 destaddress = XBeeAddress64(0x0013A200, 0x406F1997);

void setup()  
{
  Serial.begin(9600);  //connect serial
  gpsss.begin(4800);  //connect gps
  xbeess.begin(9600);   //connect xbee
  //We hook the XBee into the Software Serial
  xbee.setSerial(xbeess);
  
  Serial.println("Goodnight moon!");
}

void loop() // run over and over
{

  while (gpsss.available()>0){
    c = gpsss.read();
    if (c == '

){
     break;
   }
   else{
     strncat(gpsstr, &c, 1);  //concatenate a character to the string
   }
 }
 strcat (gpsstr, xbeeextension);
 Serial.println(gpsstr);
 delay(2000);
 Serial.println("--------------------");
 ZBTxRequest zbtx = ZBTxRequest(destaddress, (uint8_t *)gpsstr, strlen(gpsstr));
 xbee.send(zbtx);
 gpsstr[0] = ‘\0’;  //resets the value
 strcat (gpsstr, deviceid);
 strncat(gpsstr, &c, 1);  //concatenate a character to the string

Hi,

I did something similar but using a pair UNO & nRF24L01+ instead of Xbee...

Since the nRF24L01 max payload is 32 bytes, I use two bytes as headers and remaining 30 bytes as GPS payload... and the receiving end merge them back and I can hook it up to a computer with GPS s/w to read from the UNO/nRF USB virtual serial port and all the valid satellite and GPS lock will show up...

Pls see the link below :- http://forum.arduino.cc/index.php?topic=170253.0

Note: I am using an xbee S2B module to transmit the gps string to another xbee S2B module for further processing

Perhaps you should step back and just connect the GPS directly to the arduino and get that working first.