TinyGPS Help

Hi,

Im having an issue using TinyGPS with the hardware serial port. Is it okay to do

TinyGPS gps;
NewSoftSerial nss(0, 1);

and then:

Serial.begin(4800);
  nss.begin(4800);

The rest of the program is the same as the example but I just get the output from setup() and then nothing. When I just output everything coming into the port, just using serial, no tinygps, I can see the raw NMEA output. What am I missing?

Thanks.

You can't use NewSoftSerial on the hardware port's pins.

If your GPS is connected to the hardware serial port (pins 0 and 1), use Serial to read the data. Of course, if your GPS is connected to the hardware serial port, you won't be able to see output on the Serial Monitor that comes from the GPS.

So, where is the GPS connected?

You can't use NewSoftSerial on the hardware port's pins

"can't" is a bit strong - you could, though it may be a little silly, unless there was a very good reason, like swapped Rx and Tx pins.

The last thing "init()" does is disconnect the USART from pins 0 and 1, so until you call "Serial.begin", they're uncommitted.

so until you call "Serial.begin", they're uncommitted.

Which HABalloonGirl does in setup().

Ah! "You" in the specific sense, rather than "one can't use..."

cool.

okay-so if I can't use Newsoftserial with those pins, can I still use the tinyGPS library to parse the NMEA data? As I mentioned, I can get the gps output raw if I just dump whats coming in over the serial. Do I need to parse that myself then?

I also tried again and removed the newsoftserial stuff and changed feedgps to:

bool feedgps()
{
  while (Serial.available())
  {
    if (gps.encode(Serial.read()))
      return true;
  }
  return false;
}

but that still gives the same resultant hang.

To clarify, I have an interesting setup. Its a custom board with pin 0 hooked into the GPS (rx to get the gps data) and pin 1 (tx) connected to a digital radio. I only need to read from the GPS and transmit on the radio. And yes, I do have to take out a resistor every time I program the thing with the ftdi breakout-a "to fix" on the next design revision. With the serial dump, I can see the digital radio output the NMEA data.

Thanks.

Try storing the value received from Serial.read in a variable and Serial.print it before passing the value to gps.decode. See if there is some specific character that it hangs on.

mmmk-the result of using

bool feedgps()
{
  while (Serial.available())
  {
    char serialchar=Serial.read();
    Serial.print(serialchar, BYTE);
    if (gps.encode(Serial.read()))
      return true;
  }
  return false;
}

gives:

Testing TinyGPS library v. 9
by Mikal Hart

Sizeof(gpsobject) = 103


v»ææ–³s+
æÖ

öææ

Ö“
æ

VÖ$SFX,O: *5
PRTTW: 11*7
PRTTPS 67137 0 0*2A
$PSRFTXT,CLK:  96250*25
$PSRFTXT,CHNL: 12*73
$PSRFTXT,Baud rate: 4800*65
$GPGGA,235946.060,,,,,0,00,,,M,0.0,M,,0000*5F
$GPGSA,A,1,,,,,,,,,,,,,,,*1E
$GPRMC,235946.060,V,,,,,,,310109,,,N*4E
$GPGGA,235947.068,,,,,0,00,,,M,0.0,M,,0000*56
$GPGSA,A,1,,,,,,,,,,,,,,,*1E
$GPRMC,235947.068,V,,,,,,,310109,,,N*47
$GPGGA,235948.058,,,,,0,00,,,M,0.0,M,,0000*5A
$GPGSA,A,1,,,,,,,,,,,,,,,*1E
$GPRMC,235948.058,V,,,,,,,310109,,,N*4B
$GPGGA,235949.058,,,,,0,00,,,M,0.0,M,,0000*5B
$GPGSA,A,1,,,,,,,,,,,,,,,*1E
$GPRMC,235949.058,V,,,,,,,310109,,,N*4A
$GPGGA,235950.071,,,,,0,00,,,M,0.0,M,,0000*58

GPS doesn't have a lock but... So its just never returning true so never printing out anything. Could the hex characters at the start be causing issues? Shouldn't the function be printing something even though the GPS has no lock? Thanks for the help.

Er, if it's never printing out anything, where is the NMEA coming from?

Hard to say without seeing all your code, but it looks OK from here.

Garbage data on startup is not terribly unusual.

If this is for a high altitude balloon make sure it actually works above 60k', as most GPS units don't.

-j

while (Serial.available())
  {
    char serialchar=Serial.read();
    Serial.print(serialchar, BYTE);
    if (gps.encode(Serial.read()))
      return true;
  }

You want to pass the character you read from the serial port to gps.encode, not read another one. We won't learn much seeing every other character...

duh, missed that. time for me to go home. :slight_smile:

-j

duh, missed that. time for me to go home.

I've had days like that. Weeks, really.