GPS Help

I've never used a GPS before but need one for a weather balloon project I'm working on. I bought the shield from Sparkfun but can't seem to get it up and running.

Details:
They don't really have a datasheet for the GPS but it's the GPS4OEM (up to 84 kM). Uses NMEA 0183 sentences at 4800 baud 1Hz.
GPS Pinout:
1.GND
2.VCC (3.3-5V)
3.TTL Tx
4.RS-232 Rx
5.RS-232 Tx
6.TTL Rx

GPS Shield: http://www.sparkfun.com/products/10710

The GPS fits int the EM406 connector on the shield and I'm using this code:

/*
  6-8-10
  Aaron Weiss
  SparkFun Electronics
  
  Example GPS Parser based off of arduiniana.org TinyGPS examples.
  
  Parses NMEA sentences from an EM406 running at 4800bps into readable 
  values for latitude, longitude, elevation, date, time, course, and 
  speed. 
  
  For the SparkFun GPS Shield. Make sure the switch is set to DLINE.
  
  Once you get your longitude and latitude you can paste your 
  coordinates from the terminal window into Google Maps. Here is the 
  link for SparkFun's location.  
  http://maps.google.com/maps?q=40.06477,+-105.20997
  
  Uses the NewSoftSerial library for serial communication with your GPS, 
  so connect your GPS TX and RX pin to any digital pin on the Arduino, 
  just be sure to define which pins you are using on the Arduino to 
  communicate with the GPS module. 
  
  REVISIONS:
  1-17-11 
    changed values to RXPIN = 2 and TXPIN = to correspond with
    hardware v14+. Hardware v13 used RXPIN = 3 and TXPIN = 2.
  
*/ 

// In order for this sketch to work, you will need to download 
// NewSoftSerial and TinyGPS libraries from arduiniana.org and put them 
// into the hardware->libraries folder in your ardiuno directory.
// Here are the lines of code that point to those libraries.
#include <SoftwareSerial.h>
#include <TinyGPS.h>

// Define which pins you will use on the Arduino to communicate with your 
// GPS. In this case, the GPS module's TX pin will connect to the 
// Arduino's RXPIN which is pin 3.
#define RXPIN 2
#define TXPIN 3
//Set this value equal to the baud rate of your GPS
#define GPSBAUD 4800

// Create an instance of the TinyGPS object
TinyGPS gps;
// Initialize the NewSoftSerial library to the pins you defined above
SoftwareSerial uart_gps(RXPIN, TXPIN);

// This is where you declare prototypes for the functions that will be 
// using the TinyGPS library.
void getgps(TinyGPS &gps);

// In the setup function, you need to initialize two serial ports; the 
// standard hardware serial port (Serial()) to communicate with your 
// terminal program an another serial port (NewSoftSerial()) for your 
// GPS.
void setup()
{
  // This is the serial rate for your terminal program. It must be this 
  // fast because we need to print everything before a new sentence 
  // comes in. If you slow it down, the messages might not be valid and 
  // you will likely get checksum errors.
  Serial.begin(115200);
  //Sets baud rate of your GPS
  uart_gps.begin(GPSBAUD);
  
  Serial.println("");
  Serial.println("GPS Shield QuickStart Example Sketch v12");
  Serial.println("       ...waiting for lock...           ");
  Serial.println("");
}

// This is the main loop of the code. All it does is check for data on 
// the RX pin of the ardiuno, makes sure the data is valid NMEA sentences, 
// then jumps to the getgps() function.
void loop()
{
  while(uart_gps.available())     // While there is data on the RX pin...
  {
      int c = uart_gps.read();    // load the data into a variable...
      if(gps.encode(c))      // if there is a new valid sentence...
      {
        getgps(gps);         // then grab the data.
      }
  }
}

// The getgps function will get and print the values we want.
void getgps(TinyGPS &gps)
{
  // To get all of the data into varialbes that you can use in your code, 
  // all you need to do is define variables and query the object for the 
  // data. To see the complete list of functions see keywords.txt file in 
  // the TinyGPS and NewSoftSerial libs.
  
  // Define the variables that will be used
  float latitude, longitude;
  // Then call this function
  gps.f_get_position(&latitude, &longitude);
  // You can now print variables latitude and longitude
  Serial.print("Lat/Long: "); 
  Serial.print(latitude,5); 
  Serial.print(", "); 
  Serial.println(longitude,5);
  
  // Same goes for date and time
  int year;
  byte month, day, hour, minute, second, hundredths;
  gps.crack_datetime(&year,&month,&day,&hour,&minute,&second,&hundredths);
  // Print data and time
  Serial.print("Date: "); Serial.print(month, DEC); Serial.print("/"); 
  Serial.print(day, DEC); Serial.print("/"); Serial.print(year);
  Serial.print("  Time: "); Serial.print(hour, DEC); Serial.print(":"); 
  Serial.print(minute, DEC); Serial.print(":"); Serial.print(second, DEC); 
  Serial.print("."); Serial.println(hundredths, DEC);
  //Since month, day, hour, minute, second, and hundr
  
  // Here you can print the altitude and course values directly since 
  // there is only one value for the function
  Serial.print("Altitude (meters): "); Serial.println(gps.f_altitude());  
  // Same goes for course
  Serial.print("Course (degrees): "); Serial.println(gps.f_course()); 
  // And same goes for speed
  Serial.print("Speed(kmph): "); Serial.println(gps.f_speed_kmph());
  Serial.println();
  
  // Here you can print statistics on the sentences.
  unsigned long chars;
  unsigned short sentences, failed_checksum;
  gps.stats(&chars, &sentences, &failed_checksum);
  //Serial.print("Failed Checksums: ");Serial.print(failed_checksum);
  //Serial.println(); Serial.println();
}

I'm able to flash the arduino without a problem and when I open the serial monitor it just keeps saying "...waiting for lock..." without ever locking and displaying the information.

Can anyone tell me why I can't lock on and start displaying the information? Thanks ahead of time for any help.

Does your GPS antenna have a clear view of the sky? Have you given it an hour or so of clear sky view to download the satellite ephemeris data?

No, I'm inside. Is that the noob mistake? Do I need to be outside?

Have you given it an hour or so of clear sky view to download the satellite ephemeris data?

I'm not sure what that means. :frowning:

No, I'm inside. Is that the noob mistake? Do I need to be outside?

No. But, if not, then you need to bring the satellites inside, too.

No. But, if not, then you need to bring the satellites inside, too.

I'll have to give that a shot. :slight_smile:

I took my GPS outside, and let it sit for about three hours, but all the LED does is blink.

If there is a command you can send to the GPS to initiate a cold start then you can try that.

With my gps receiver a flashing led means a lock but thats not true for every receiver,
maybe try setting Serial.begin(4800);
you should be using the TTL pins of gps
dumb question but have you got tx & rx the right way round?
Here is some basic code i used to test mine, dont worry if the screen is blank for a few minutes, it' doesn't display anything until it gets a lock, if you cant get a lock try echo'ing the gps sentence back to your serial monitor to check your getting data

#include <LiquidCrystal.h>
#include <TinyGPS.h>

TinyGPS gps;

LiquidCrystal lcd(8, 9, 4, 5, 6, 7);


void setup()
{
  Serial.begin(4800);
  lcd.begin(16, 2);
  lcd.setCursor(0,0);
}

void loop()
{
  bool newData = false;
  unsigned long chars;
  unsigned short sentences, failed;

  for (unsigned long start = millis(); millis() - start < 1000;)
  {
    while (Serial.available())
    {
      char c = Serial.read();
      if (gps.encode(c)) // Did a new valid sentence come in?
        newData = true;
    }
  }

  if (newData)
  {
    float flat, flon;
    unsigned long age;
    gps.f_get_position(&flat, &flon, &age);
    lcd.setCursor(0,0);
    lcd.print("LAT=");
    lcd.print(flat == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : flat, 6);
    lcd.setCursor(0,1);
    lcd.print("LON=");
    lcd.print(flon == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : flon, 6);
  }
}

If there is a command you can send to the GPS to initiate a cold start then you can try that.

I don't know if there is or not, unfortunately the documentation is really poor on it.

you should be using the TTL pins of gps
dumb question but have you got tx & rx the right way round?

Yes I am using the TTL pins, actually just the Tx. I'm using the EM406 connector on the shield, which doesn't exactly match the pinout of my GPS, but the 5V, Gnd, and Tx line up. After looking over the example code from Sparkfun, I saw there's no writing to the GPS at all, so I figured I was fine using that. I'll have to give that code a shot though, see if I can get it working.

Figured I'd give an update, the problem I was having is this is the first time I used the Arduino Mega, and it doesn't like SoftwareSerial, when I used one of the secondary hardware serial pins, I was able to get the GPS to receive.