SerialPort for GPS Shield only returning 0 value.

I'm trying to figure out how to get a GPS shield to work. It's my first time actually using a shield but so far I haven't been able to acquire any data from the GPS shield. I'm currently using a Mega 2560 board with a NEO-6M GPS Shield. Currently I'm not sure what could be wrong. Did I forget to do something or did I configure something wrong on the shield itself? I've checked the code and it should be fine. The RX and TX ports are 3 & 4 and are set that way in the code as well.
Any help would be most appreciated. See attached image for details on the setup.

Source Code:

/*********************
 *10 to GPS Module TX*
 *09 to GPS Module RX*
 *********************/

#include <SoftwareSerial.h>
#include <TinyGPS.h>

SoftwareSerial mySerial(3, 4);
TinyGPS gps;


void gpsdump(TinyGPS &gps);
void printFloat(double f, int digits = 2);
long start = 0;
void setup()  
{
  // Oploen serial communications and wait for port to open:
  Serial.begin(9600);
  // set the data rate for the SoftwareSerial port
  mySerial.begin(9600);
  Serial.println("uBlox Neo 6M");
  Serial.print("Testing TinyGPS library v. "); Serial.println(TinyGPS::library_version());
  Serial.println("by Mikal Hart");
  Serial.println(); 
  start = millis();
}

void loop() 
{
  bool newdata = false;
  // Every 5 seconds we print an update
  if (millis() - start > 5000) 
  {
    start = millis();
    Serial.print("mySerial: ");
    Serial.println(mySerial.available());
    if (mySerial.available()) 
    
    {
      char c = mySerial.read();
      Serial.print(c);  // uncomment to see raw GPS data
      if (gps.encode(c)) 
      {
        newdata = true;
      }
    }
  }
  
  if (newdata) 
  {
    Serial.println("Acquired Data");
    Serial.println("-------------");
    gpsdump(gps);
    Serial.println("-------------");
    Serial.println();
  }
  
}

void gpsdump(TinyGPS &gps)
{
  long lat, lon;
  float flat, flon;
  unsigned long age, date, time, chars;
  int year;
  byte month, day, hour, minute, second, hundredths;
  unsigned short sentences, failed;

  gps.get_position(&lat, &lon, &age);
  Serial.print("Lat/Long(10^-5 deg): "); Serial.print(lat); Serial.print(", "); Serial.print(lon); 
  Serial.print(" Fix age: "); Serial.print(age); Serial.println("ms.");
  
  // On Arduino, GPS characters may be lost during lengthy Serial.print()
  // On Teensy, Serial prints to USB, which has large output buffering and
  //   runs very fast, so it's not necessary to worry about missing 4800
  //   baud GPS characters.

  gps.f_get_position(&flat, &flon, &age);
  Serial.print("Lat/Long(float): "); printFloat(flat, 5); Serial.print(", "); printFloat(flon, 5);
    Serial.print(" Fix age: "); Serial.print(age); Serial.println("ms.");

  gps.get_datetime(&date, &time, &age);
  Serial.print("Date(ddmmyy): "); Serial.print(date); Serial.print(" Time(hhmmsscc): ");
    Serial.print(time);
  Serial.print(" Fix age: "); Serial.print(age); Serial.println("ms.");

  gps.crack_datetime(&year, &month, &day, &hour, &minute, &second, &hundredths, &age);
  Serial.print("Date: "); Serial.print(static_cast<int>(month)); Serial.print("/"); 
    Serial.print(static_cast<int>(day)); Serial.print("/"); Serial.print(year);
  Serial.print("  Time: "); Serial.print(static_cast<int>(hour+8));  Serial.print(":"); //Serial.print("UTC +08:00 Malaysia");
    Serial.print(static_cast<int>(minute)); Serial.print(":"); Serial.print(static_cast<int>(second));
    Serial.print("."); Serial.print(static_cast<int>(hundredths)); Serial.print(" UTC +08:00 Malaysia");
  Serial.print("  Fix age: ");  Serial.print(age); Serial.println("ms.");

  Serial.print("Alt(cm): "); Serial.print(gps.altitude()); Serial.print(" Course(10^-2 deg): ");
    Serial.print(gps.course()); Serial.print(" Speed(10^-2 knots): "); Serial.println(gps.speed());
  Serial.print("Alt(float): "); printFloat(gps.f_altitude()); Serial.print(" Course(float): ");
    printFloat(gps.f_course()); Serial.println();
  Serial.print("Speed(knots): "); printFloat(gps.f_speed_knots()); Serial.print(" (mph): ");
    printFloat(gps.f_speed_mph());
  Serial.print(" (mps): "); printFloat(gps.f_speed_mps()); Serial.print(" (kmph): ");
    printFloat(gps.f_speed_kmph()); Serial.println();

  gps.stats(&chars, &sentences, &failed);
  Serial.print("Stats: characters: "); Serial.print(chars); Serial.print(" sentences: ");
    Serial.print(sentences); Serial.print(" failed checksum: "); Serial.println(failed);
}

void printFloat(double number, int digits)
{
  // Handle negative numbers
  if (number < 0.0) 
  {
     Serial.print('-');
     number = -number;
  }

  // Round correctly so that print(1.999, 2) prints as "2.00"
  double rounding = 0.5;
  for (uint8_t i=0; i<digits; ++i)
    rounding /= 10.0;
  
  number += rounding;

  // Extract the integer part of the number and print it
  unsigned long int_part = (unsigned long)number;
  double remainder = number - (double)int_part;
  Serial.print(int_part);

  // Print the decimal point, but only if there are digits beyond
  if (digits > 0)
    Serial.print("."); 

  // Extract digits from the remainder one at a time
  while (digits-- > 0) 
  {
    remainder *= 10.0;
    int toPrint = int(remainder);
    Serial.print(toPrint);
    remainder -= toPrint;
  }
}

If you are using a Mega, there is no reason to be using Software Serial !

.

Indeed, on an ATmega 2560 use one of the available hardware serial ports.

The GPS probably needs to be outside before it will get a fix, until it gets a fix there is no 'data' to give you.

I'm trying to figure out how to get a GPU shield to work.

You refer to 'GPU Shield' three times, do you mean 'GPS Shield' ?

srnet:
Indeed, on an ATmega 2560 use one of the available hardware serial ports.

The GPS probably needs to be outside before it will get a fix, until it gets a fix there is no 'data' to give you.

You refer to 'GPU Shield' three times, do you mean 'GPS Shield' ?

You're right, I meant to say GPS Shield, my bad. Also what did you mean by using one of the available hardware serial ports? I am currently using 3 and 4. On the shield I can only go up to 7. Perhaps there's something I've misunderstood?

It should work with SoftwareSerial, but hardware serial is much better.

Perhaps there's something I've misunderstood?

Yes, you should read up on using the additional serial ports of the Mega.

Take everything outside, to where you have a clear view of the sky, and plan to wait up to 15 minutes to get the first satellite fix.

If that's the case, then do I have to always wait 15 minutes just to get an update of the location of the GPS? I hope to use it on a drone, I can't have it retrieve an update of its location at intervals of 15 minutes if that's the case.

geekles:
I hope to use it on a drone

Really ?

Are you intending to use the Mega to control the drone as well ?

do I have to always wait 15 minutes just to get an update of the location of the GPS?

No, only for a factory fresh, first fix, or if you have moved the GPS unit hundreds of km.

When turned off, most GPS units maintain a battery-backed approximation to satellite locations that is valid for the current location and for some number of days. With a good approximation, fixes can often be obtained in less than 1 minute.

I've gone outside as suggested and had my program run for at least an hour. Upon checking the debug results, I had never received any value aside for 0.

Try a simple echo program like this, with the GPS unit outdoors. It simply echos whatever comes from the GPS onto the serial monitor.

Post a sample of the output.

#include <SoftwareSerial.h>

SoftwareSerial mySerial(10, 11); //(RX, TX) check correct GPS pin assignments.

void setup() {
  mySerial.begin(9600); //make sure Baud rate is correct
  Serial.begin(9600);  //make sure Baud rate is correct
  Serial.println("GPS start");
}

void loop() {
  while (mySerial.available()) {
    Serial.write(mySerial.read());
  }
}

Note: if you are using the Mega, try using Serial1 (or 2 or 3) instead of SoftwareSerial. Again, make sure RX, TX pin assignments are correct for the GPS.

This is the updated version of my code. It runs so far, however it hasn't returned any values other then 0 which makes me a bit nervous. I haven't yet though stepped outside to test it, so I'll update the post once I do.

/*********************
 *10 to GPS Module TX*
 *09 to GPS Module RX*
 *********************/

#include <SoftwareSerial.h>
#include <TinyGPS.h>

TinyGPS gps;


void gpsdump(TinyGPS &gps);
void printFloat(double f, int digits = 2);
long start = 0;
void setup()  
{
  // Oploen serial communications and wait for port to open:
  Serial.begin(9600);
  // set the data rate for the SoftwareSerial port
  Serial1.begin(9600);
  Serial.println("uBlox Neo 6M");
  Serial.print("Testing TinyGPS library v. "); Serial.println(TinyGPS::library_version());
  Serial.println("by Mikal Hart");
  Serial.println(); 
  start = millis();
}

void loop(){
  bool newdata = false;
  if (Serial1.available()){
    char c = Serial1.read();
    Serial.print(c);  // uncomment to see raw GPS data
    if (gps.encode(c)){
      newdata = true;
    }
  }
  
  
  if (newdata){
    Serial.println("Acquired Data");
    Serial.println("-------------");
    gpsdump(gps);
    Serial.println("-------------");
    Serial.println();
  }
  
}

void gpsdump(TinyGPS &gps)
{
  long lat, lon;
  float flat, flon;
  unsigned long age, date, time, chars;
  int year;
  byte month, day, hour, minute, second, hundredths;
  unsigned short sentences, failed;

  gps.get_position(&lat, &lon, &age);
  Serial.print("Lat/Long(10^-5 deg): "); Serial.print(lat); Serial.print(", "); Serial.print(lon); 
  Serial.print(" Fix age: "); Serial.print(age); Serial.println("ms.");
  
  // On Arduino, GPS characters may be lost during lengthy Serial.print()
  // On Teensy, Serial prints to USB, which has large output buffering and
  //   runs very fast, so it's not necessary to worry about missing 4800
  //   baud GPS characters.

  gps.f_get_position(&flat, &flon, &age);
  Serial.print("Lat/Long(float): "); printFloat(flat, 5); Serial.print(", "); printFloat(flon, 5);
    Serial.print(" Fix age: "); Serial.print(age); Serial.println("ms.");

  gps.get_datetime(&date, &time, &age);
  Serial.print("Date(ddmmyy): "); Serial.print(date); Serial.print(" Time(hhmmsscc): ");
    Serial.print(time);
  Serial.print(" Fix age: "); Serial.print(age); Serial.println("ms.");

  gps.crack_datetime(&year, &month, &day, &hour, &minute, &second, &hundredths, &age);
  Serial.print("Date: "); Serial.print(static_cast<int>(month)); Serial.print("/"); 
    Serial.print(static_cast<int>(day)); Serial.print("/"); Serial.print(year);
  Serial.print("  Time: "); Serial.print(static_cast<int>(hour+8));  Serial.print(":"); //Serial.print("UTC +08:00 Malaysia");
    Serial.print(static_cast<int>(minute)); Serial.print(":"); Serial.print(static_cast<int>(second));
    Serial.print("."); Serial.print(static_cast<int>(hundredths)); Serial.print(" UTC +08:00 Malaysia");
  Serial.print("  Fix age: ");  Serial.print(age); Serial.println("ms.");

  Serial.print("Alt(cm): "); Serial.print(gps.altitude()); Serial.print(" Course(10^-2 deg): ");
    Serial.print(gps.course()); Serial.print(" Speed(10^-2 knots): "); Serial.println(gps.speed());
  Serial.print("Alt(float): "); printFloat(gps.f_altitude()); Serial.print(" Course(float): ");
    printFloat(gps.f_course()); Serial.println();
  Serial.print("Speed(knots): "); printFloat(gps.f_speed_knots()); Serial.print(" (mph): ");
    printFloat(gps.f_speed_mph());
  Serial.print(" (mps): "); printFloat(gps.f_speed_mps()); Serial.print(" (kmph): ");
    printFloat(gps.f_speed_kmph()); Serial.println();

  gps.stats(&chars, &sentences, &failed);
  Serial.print("Stats: characters: "); Serial.print(chars); Serial.print(" sentences: ");
    Serial.print(sentences); Serial.print(" failed checksum: "); Serial.println(failed);
}

void printFloat(double number, int digits)
{
  // Handle negative numbers
  if (number < 0.0) 
  {
     Serial.print('-');
     number = -number;
  }

  // Round correctly so that print(1.999, 2) prints as "2.00"
  double rounding = 0.5;
  for (uint8_t i=0; i<digits; ++i)
    rounding /= 10.0;
  
  number += rounding;

  // Extract the integer part of the number and print it
  unsigned long int_part = (unsigned long)number;
  double remainder = number - (double)int_part;
  Serial.print(int_part);

  // Print the decimal point, but only if there are digits beyond
  if (digits > 0)
    Serial.print("."); 

  // Extract digits from the remainder one at a time
  while (digits-- > 0) 
  {
    remainder *= 10.0;
    int toPrint = int(remainder);
    Serial.print(toPrint);
    remainder -= toPrint;
  }
}

I haven't yet though stepped outside to test it

It will not work indoors.

So I stepped outside for about ten minutes or so. I didn't receive a signal at first so being disappointed set my computer back inside and left it temporarily with the Arduino program still running. To my surprise when I returned I was surprised to notice an abnormality in my debugging, however I still haven't yet received any raw data. It appears that the data that I'm seemingly potentially receiving isn't capable of being encoded by the TinyGPS library that I'm using, although I'm not sure. Either way, the debug showed that after 10 or so minutes, one of the multiple serials I was testing (since I wasn't sure which one would work or not being that I've tested it several times and I'm unsure if I'm just trying to read off the wrong Serial), however Serial1 and 2 would print a debug message that would only be printed when available, however would never print the raw data or the encoded data. Perhaps its a basic mistake I've overlooked? Here's my code and my debug in case anyone is interested, check below for details (ignore the "========[ NO RESPONSE YET ]========" debug, just there to ensure that the program is still in fact running throughout the process).

/*********************
 *10 to GPS Module TX*
 *09 to GPS Module RX*
 *********************/

#include <SoftwareSerial.h>
#include <TinyGPS.h>

TinyGPS gps;


void gpsdump(TinyGPS &gps);
void printFloat(double f, int digits = 2);
long start = 0;
void setup()  
{
  // Oploen serial communications and wait for port to open:
  Serial.begin(9600);
  // set the data rate for the SoftwareSerial port
  Serial1.begin(9600);
  Serial2.begin(9600);
  Serial3.begin(9600);
  Serial.println("uBlox Neo 6M");
  Serial.print("Testing TinyGPS library v. "); Serial.println(TinyGPS::library_version());
  Serial.println("by Mikal Hart");
  Serial.println(); 
  start = millis();
}

void loop(){
  bool newdata = false;
  if(millis() - start >= 10000){
    Serial.println("========[ NO RESPONSE YET ]========");
    start = millis();
  }
  if (Serial1.available() || Serial2.available() || Serial3.available()){
    char c;
    if(Serial1.available()) {
      Serial.print("Serial1 Data: ");
      c = Serial1.read();
    }
    if(Serial2.available()) {
      Serial.print("Serial2 Data: ");
      c = Serial2.read();
    }
    if(Serial3.available()) {
      Serial.print("Serial3 Data: ");
      c = Serial3.read();
    }

    Serial.print(c);  // uncomment to see raw GPS data
    if (gps.encode(c)){
      newdata = true;
    }
  }
  
  
  if (newdata){
    Serial.println("Acquired Data");
    Serial.println("-------------");
    gpsdump(gps);
    Serial.println("-------------");
    Serial.println();
  }
  
}

void gpsdump(TinyGPS &gps)
{
  long lat, lon;
  float flat, flon;
  unsigned long age, date, time, chars;
  int year;
  byte month, day, hour, minute, second, hundredths;
  unsigned short sentences, failed;

  gps.get_position(&lat, &lon, &age);
  Serial.print("Lat/Long(10^-5 deg): "); Serial.print(lat); Serial.print(", "); Serial.print(lon); 
  Serial.print(" Fix age: "); Serial.print(age); Serial.println("ms.");
  
  // On Arduino, GPS characters may be lost during lengthy Serial.print()
  // On Teensy, Serial prints to USB, which has large output buffering and
  //   runs very fast, so it's not necessary to worry about missing 4800
  //   baud GPS characters.

  gps.f_get_position(&flat, &flon, &age);
  Serial.print("Lat/Long(float): "); printFloat(flat, 5); Serial.print(", "); printFloat(flon, 5);
    Serial.print(" Fix age: "); Serial.print(age); Serial.println("ms.");

  gps.get_datetime(&date, &time, &age);
  Serial.print("Date(ddmmyy): "); Serial.print(date); Serial.print(" Time(hhmmsscc): ");
    Serial.print(time);
  Serial.print(" Fix age: "); Serial.print(age); Serial.println("ms.");

  gps.crack_datetime(&year, &month, &day, &hour, &minute, &second, &hundredths, &age);
  Serial.print("Date: "); Serial.print(static_cast<int>(month)); Serial.print("/"); 
    Serial.print(static_cast<int>(day)); Serial.print("/"); Serial.print(year);
  Serial.print("  Time: "); Serial.print(static_cast<int>(hour+8));  Serial.print(":"); //Serial.print("UTC +08:00 Malaysia");
    Serial.print(static_cast<int>(minute)); Serial.print(":"); Serial.print(static_cast<int>(second));
    Serial.print("."); Serial.print(static_cast<int>(hundredths)); Serial.print(" UTC +08:00 Malaysia");
  Serial.print("  Fix age: ");  Serial.print(age); Serial.println("ms.");

  Serial.print("Alt(cm): "); Serial.print(gps.altitude()); Serial.print(" Course(10^-2 deg): ");
    Serial.print(gps.course()); Serial.print(" Speed(10^-2 knots): "); Serial.println(gps.speed());
  Serial.print("Alt(float): "); printFloat(gps.f_altitude()); Serial.print(" Course(float): ");
    printFloat(gps.f_course()); Serial.println();
  Serial.print("Speed(knots): "); printFloat(gps.f_speed_knots()); Serial.print(" (mph): ");
    printFloat(gps.f_speed_mph());
  Serial.print(" (mps): "); printFloat(gps.f_speed_mps()); Serial.print(" (kmph): ");
    printFloat(gps.f_speed_kmph()); Serial.println();

  gps.stats(&chars, &sentences, &failed);
  Serial.print("Stats: characters: "); Serial.print(chars); Serial.print(" sentences: ");
    Serial.print(sentences); Serial.print(" failed checksum: "); Serial.println(failed);
}

void printFloat(double number, int digits)
{
  // Handle negative numbers
  if (number < 0.0) 
  {
     Serial.print('-');
     number = -number;
  }

  // Round correctly so that print(1.999, 2) prints as "2.00"
  double rounding = 0.5;
  for (uint8_t i=0; i<digits; ++i)
    rounding /= 10.0;
  
  number += rounding;

  // Extract the integer part of the number and print it
  unsigned long int_part = (unsigned long)number;
  double remainder = number - (double)int_part;
  Serial.print(int_part);

  // Print the decimal point, but only if there are digits beyond
  if (digits > 0)
    Serial.print("."); 

  // Extract digits from the remainder one at a time
  while (digits-- > 0) 
  {
    remainder *= 10.0;
    int toPrint = int(remainder);
    Serial.print(toPrint);
    remainder -= toPrint;
  }
}

See debug here - https://pastebin.com/DsF0HeuB

Perhaps its a basic mistake I've overlooked?

Yes, you seemed to have completly ignored the advice in post #9 from jremington.

Read it again, use the echo program, post the results.

srnet:
Yes, you seemed to have completly ignored the advice in post #9 from jremington.

Read it again, use the echo program, post the results.

My bad, forgot to report yesterday that I tested the echo program by using Serial1 instead of SoftwareSerial and it returned the GPS Start debug message.
EDIT: Just noticed that my phone which I checked the code with didn't fully render the entire list of code for some reason. I'll update my loop method with the code provided and check the results.

I apologize for the delay. So I updated my code, and it checks Serial1, 2, and 3. I'm not quite sure, however it seems all three of the serials get some sort of response from the GPS Shield (at least I believe that is the case). Perhaps the code and the debug messages speak for themselves better then I can.
Code:

const long COOLDOWN = 10000;
long start = 0;


bool serial1_availability = false;
bool serial2_availability = false;
bool serial3_availability = false; 

void setup() {
  start = millis();
  Serial1.begin(9600); //make sure Baud rate is correct
  Serial2.begin(9600); //make sure Baud rate is correct
  Serial3.begin(9600); //make sure Baud rate is correct
  Serial.begin(9600);  //make sure Baud rate is correct
  Serial.println("====================");
  Serial.println("  >> GPS START <<");
  Serial.println("====================");
}

void loop() {

  if(millis() - start >= COOLDOWN){
    Serial.print("*");
    start = millis();
  }
  
  while (Serial1.available()) {
    if(!serial1_availability){
      Serial.println("");
      Serial.println("Serial1 Available!");
      serial1_availability = true;
    }
    Serial.write(Serial1.read());
  }
  while (Serial2.available()) {
    if(!serial2_availability){
      Serial.println("");
      Serial.println("Serial2 Available!");
      serial2_availability = true;
    }
    Serial.write(Serial2.read());
  }
  while(Serial3.available()) {
    if(!serial3_availability){
      Serial.println("");
      Serial.println("Serial3 Available!");
      serial3_availability = true;
    }
    Serial.write(Serial3.read());
  }
  
  if(serial1_availability){
    Serial.println("Serial1 Is No Longer Available!");
    serial1_availability = false;
  }
  if(serial2_availability){
    Serial.println("Serial2 Is No Longer Available!");
    serial2_availability = false;
  }
  if(serial3_availability){
    Serial.println("Serial3 Is No Longer Available!");
    serial3_availability = false;
  }

}

Debug:

====================
  >> GPS START <<
====================
************************************
Serial3 Available!
Serial3 Is No Longer Available!
********
Serial1 Available!
Serial1 Is No Longer Available!
*****************
Serial2 Available!
Serial2 Is No Longer Available!
*********************************************************************************
Serial3 Available!
Serial3 Is No Longer Available!

Serial2 Available!
Serial2 Is No Longer Available!

Serial1 Available!
Serial1 Is No Longer Available!
****************************************************