Teensy3 and Sparkfun GPS-10920

Status
Not open for further replies.
I just got my Teensy3 and have it connected to my GPS, but I don't get any communication from on the GPS serial port. I've tried a bunch of stuff, but obviously, I'm missing something.

Here's my setup:
Teensy3 GPS-10920
GND <--> GND
RX2 <--> TX
TX2 <--> RX
3.3V <--> 3.3V
3.3V <--> VBAT

All other pins are open.

The green "NAV" light is flashing at about 1 pulse per second which I take to mean that it is getting a sat lock. (Although I'm not certain about that either).

Here is a minimal sketch: -- gpsSerial.available() is always false.


Code:
HardwareSerial gpsSerial = HardwareSerial2();

void setup()
{
  delay(5000);  // give me time to open the serial monitor. 
  Serial.begin(9600);
  gpsSerial.begin(9600);
  Serial.println( "setup complete" );
}

void loop()
{
  bool gpsDataAvailable = false;
  
  unsigned long start = millis();

  while (millis() - start < 5000)
  {
    while( gpsSerial.available() )
    {
        gpsSerial.read();
        gpsDataAvailable = true;
    }
  }
  if ( gpsDataAvailable )
  {
     Serial.println( "gps connected" );
  }
  else
  {
     Serial.println( "gps not connected" );
  }
}
 
Last edited:
I don't have the same GPS module, but I know that when I power up mine, it takes (up to) 2 minutes before my GPS gets a fix and starts receiving data...
Did you try running the sketch for a few minutes as well?

Also, what happens if you use Serial2. instead of gpsSerial. ?
 
OK. It seems to be working now ... at least in this tweaked test program, buy changing.

HardwareSerial gpsSerial = HardwareSerial2();

to

#define gpsSerial Serial2

note that:

HardwareSerial gpsSerial = Serial2;

does not work either.

Why would that be?
 
I'd have to be honest and say that I don't really know.
I've had very little experience with serial interfaces so far, and the code that I was provided with worked right away.

The code that I got to define the serial interface is:
Code:
Adafruit_GPS GPS(&Serial2);
(I only changed it to Serial1, to match my pin connections)

Then in my setup() and loop() I can call it by using GPS.valueIwant

I think(!) the reason why the #define doesnt work, is because a #define can't hold variables, only static information... (if anyone can confirm this, please do)
 
The #define DOES work. It's the variable assignment that doesn't work.

Thanks for the tips. Now, let's see if I can parse some data.
 
Ah my bad... (it's almost midnight here)

Anytime, grats on getting it to work!

Another tip, in case you run into the same thing I did when I started.

My GPS module outputs all data in NMEA format.
Since I wanted to be able to use decimal degrees, I had to find a way to convert NMEA to decimal
I found this snippet online and it works excellent:
Code:
// convert NMEA coordinate to decimal degrees
float decimalDegrees(float nmeaCoord) {
  uint16_t wholeDegrees = 0.01*nmeaCoord;
  return wholeDegrees + (nmeaCoord - 100.0*wholeDegrees)/60.0;
}
 
Status
Not open for further replies.
Back
Top