GPS Help - Not Getting Expected Data Out

I put lots of comments in the Sketch so... they should explain most below.
I'm working with a high school solar car team. They have elected to build their own telemetry system ground up. We have tried to copy and paste Sketches but still run into problems. So we have decided to learn the code and write the Sketches ourselves. I have never programmed before so I'm learning along with them. The GPS data is one of our first stages. There will eventually be additional inputs and we will eventually be transmitting all data from a moving solar car to a laptop in a chase vehicle. We would greatly appreciate any advice/input.

//Sketch Status: LED is coming on for 1.5sec indicating data. RETURNING ONLY 1 & 0 values in the Serial Monitor

/* This is an attempt to write a Sketch that
will read the data from an EM-406a GPS and Sparkfun GPS Shield and post it to the Serial Monitor.
The Hardware set up on the GPS, GPS shield, and Arduino Mega 2560 is as follows: 

There are shield stacking headers connecting the GPS Shield and 2560 to allow for additional hardware
later.

The slide switch on the GPS Shield set to DLINE.  This should make the
default pins on the GPS Shield RX = 2 and TX = 3

Jumpers are running from Shield stacking header pin 2 on the Shield to pin 14 on the 
2560 and from Shield stacking header pin 3 on the Shield to pin 15 on the 
2560.  These Jumpers connect the TX pin from the GPS and connected it to a 
RX pin on the 2560. And Vise Versa.  The intention is to allow communication 
between the two.
*/


int gpsRX = 14;//identifying the pins on the 2560
int gpsTX = 15;

void setup()
{
  Serial.begin(115200);//starts serial communication with the computer
  pinMode(gpsRX,OUTPUT);//sets pin as output
  pinMode(gpsTX,INPUT);//sets pin as input
  pinMode(LED_BUILTIN,OUTPUT);//sets built in LED to output
}

void loop()
{
  int gpsData = digitalRead(gpsTX);
  Serial.println(gpsData);
    if (gpsData >0)//allows built in LED to turn ON if data is received
  {
    digitalWrite(LED_BUILTIN, HIGH);   
  }
  delay(1500);//waits for 1.5 sec
  digitalWrite(LED_BUILTIN,LOW);//allows built in LED to turn off 
  delay(500);//waits another .5 sec for a total of 2 sec between readings
}

What's the problem with it?

Mark

The problem is that we are expecting standard gps NMEA data string in the Serial Monitor and are only getting ones and zeros.

int gpsData = digitalRead(gpsTX); is the problem. You need to use the Serial library routines to read the data.

Not sure but sounds like a promising lead we will run that down......
Thanks for the direction will let you know if solves our issue.

is the problem. You need to use the Serial library routines to read the data.

O.K. so I'm still having trouble...I've been chasing down the Serial library lead.

I used the Serial Event Tutorial directly from this site. So the code is below. I only slightly modified it due to my hardware set up as listed above. Since I'm using pins 14 and 15 (Serial3). I'm getting nothing coming up on the Serial Monitor.

/*
  Serial Event example
 
 When new serial data arrives, this sketch adds it to a String.
 When a newline is received, the loop prints the string and 
 clears it.
 
 A good test for this is to try it with a GPS receiver 
 that sends out NMEA 0183 sentences. 
 
 Created 9 May 2011
 by Tom Igoe
 
 This example code is in the public domain.
 
 http://www.arduino.cc/en/Tutorial/SerialEvent
 
 */

String inputString = "";         // a string to hold incoming data
boolean stringComplete = false;  // whether the string is complete

void setup() {
  // initialize serial:
  Serial3.begin(115200);
  // reserve 200 bytes for the inputString:
  inputString.reserve(200);
}

void loop() {
  // print the string when a newline arrives:
  if (stringComplete) {
    Serial3.println(inputString); 
    // clear the string:
    inputString = "";
    stringComplete = false;
  }
}

/*
  SerialEvent occurs whenever a new data comes in the
 hardware serial RX.  This routine is run between each
 time loop() runs, so using delay inside loop can delay
 response.  Multiple bytes of data may be available.
 */
void serialEvent3() {
  while (Serial3.available()) {
    // get the new byte:
    char inChar = (char)Serial3.read(); 
    // add it to the inputString:
    inputString += inChar;
    // if the incoming character is a newline, set a flag
    // so the main loop can do something about it:
    if (inChar == '\n') {
      stringComplete = true;
    } 
  }
}

I know I'm new to this but it doesn't seem like this particular task is so difficult. I feel like there is something really simple that I'm missing and am just not familiar enough with the coding to know what I'm missing. Please Help.

Perhaps I'm missing it, but where do you connect to the monitor? If you mean Serial Monitor, then you need Serial.begin(), Serial.print(), etc.

Have you tried something really simply just to see what is coming out of the GPS? Something like:

char a;

void setup()
{
  Serial3.begin(115200);
  Serial.begin(115200);
}
void loop()
{
  while(Serial3.available())
  {
    a = Serial3.read();
    Serial.print(a);
  }
}

Perhaps I'm missing it, but where do you connect to the monitor? If you mean Serial Monitor, then you need Serial.begin(), Serial.print(), etc.

I did have the Serial3.println () in the Sketch but I did not actually connect to the Serial Monitor in the Setup (). I did add that to no avail. Same results. and I did change the Serial3.println() to Serial.println().

Have you tried something really simply just to see what is coming out of the GPS? Something like:

I tried exactly that and got nothing on the Serial Monitor. In the original post I was getting ones and Zeros to my Serial Monitor. Which I believe indicated that I was getting some data into those pins. my errors there was using digital.read instead of Serial routines.

And in case anyone is wondering the gps power light is on and so is the power switch and the satellite light on the gps is blinking indicating (according to its specks) It is receiving satellite information.

If anyone thinks I may have hardware setup issues please read the comments in the original Sketch posted 1st.

In the original post I was getting ones and Zeros to my Serial Monitor. Which I believe indicated that I was getting some data into those pins. my errors there was using digital.read instead of Serial routines.

You were printing the "1"s and "0"s that the digital input provides.

Go back to the code you used for that post and instead of using digitalRead(gpsTX), use an appropriately modified form of the following (where Serial3 is assigned in Setup to the GPS unit):

  while(Serial3.available())
  {
    a = Serial3.read();
    Serial.print(a);
  }

Have you tried this (overly complicated) tutorial? Arduino Playground - HomePage

Go back to the code you used for that post and instead of using digitalRead(gpsTX), use an appropriately modified form of the following (where Serial3 is assigned in Setup to the GPS unit):

Getting the following error when compiling .

error: 'a' was not declared in this scope

after I go this error I tried putting the following into setup() but got same error message.

int a = 0

ChefK:

Go back to the code you used for that post and instead of using digitalRead(gpsTX), use an appropriately modified form of the following (where Serial3 is assigned in Setup to the GPS unit):

Getting the following error when compiling .

error: 'a' was not declared in this scope

after I go this error I tried putting the following into setup() but got same error message.

int a = 0

you don't put it in setup. Put it before setup. Also it isn't an int. It should be a character.
you need:

char a;

I've never used the mega but I am guessing that if you have the GPS connected to TX3 and RX3 properly then my simple sketch that I posted above should be streaming out NMEA strings through the serial monitor as soon as you turn it on. Make sure you have GPS TX to Mega RX3 and GPS RX to Mega TX3. Can you post a picture of your setup?

you don't put it in setup. Put it before setup. Also it isn't an int. It should be a character.
you need:

Sorry about last post. I should have read more first. I learned what I needed to do for the declaration part but I missed the char part instead of an int. Which makes total sense to me now.

Working of that physical setup pic. SOON

Can you post a picture of your setup?

I've attached picture

Thank you all for the comments and steering me in the right direction. I'm trying to figure most of this out on my own so I'll be better equipped to deal with any errors that come up in the future and possibly contribute to others. Thank you again for taking the time!!!

I'm still have issues.

Current code below is returning the following data "ÿ" that's all I'm getting over and over. The code also includes several comments of code I have been trying. I think this is telling me that most of the Sketch is correct. Is it possible I should be using some sort of string data type? I really don't even know what that means. but I do know when an earlier version contained digitalRead () I was getting a lines of ones and the LED_BUILTIN was working. Now I'm using serial.Read() and I'm getting lines of the "ÿ" and the LED_BUILTIN is not working. The LED portion of those two senarios makes sense to me as one is returing and integer and the other is not. Just wondering how to get the entire NMEA (183) standard gps data instead of these other data outputs. I believe it has to do with the variable type but not really sure if that is it or what to try next.

int gpsRX = 14;//identifing the pins on the Mega
int gpsTX = 15;
//char a;//new
//char gpsData;//new

void setup()
{
  Serial.begin(115200);//starts serial communication with the computer
  Serial3.begin(4800);//starts serial communication with the gps //new
  //pinMode(gpsRX,OUTPUT);//sets pin as output //OLD
  //pinMode(gpsTX,INPUT);//sets pin as input //OLD
  pinMode(LED_BUILTIN,OUTPUT);//sets built in LED to output
}

void loop()
{
   /* while(Serial3.available())//new
  {
    a = Serial3.read();//new
    Serial.print(a);//new
  }*/
    char gpsData = Serial3.read();//new
    //int gpsData = digitalRead(gpsTX);//OLD
    //Serial.print(gpsData);//NEW
    Serial.println(gpsData);//OLD
    if (gpsData >0)//allows built in LED to come on if data is recieved
  {
    digitalWrite(LED_BUILTIN, HIGH);   
  }
  delay(1500);//waits for 1.5 sec
  digitalWrite(LED_BUILTIN,LOW);//allows built in LED to turn off 
  delay(500);//waits another .5 sec for a total of 2 sec between readings
}

ChefK:
I've attached picture

Unfortunately Sparkfun doesn't link that board to the correct user manual online. The link goes to the newer board that they sell. Not sure how that makes any sense. The manual on the newer board: GPS Shield Hookup Guide - SparkFun Learn says that there is a solder jumper that has to be desoldered to use DLINE. Not sure if the board that you have needs that. Also, are you using D2 and D3 on the arduino for any other purposes? Have you tried a simple sketch just to make sure that you are getting what you expect to get out of the UART on the Arduino. Something like "Hello World"?

void setup()
{
  Serial.begin(115200);
}

void loop()
{
  Serial.println("Hello World!");
  delay(1000);
}

If you aren't seeing the words "Hello World" repeating every second on your serial monitor then you need to fix that first before moving on to reading the GPS strings. Seriously you need to do this…..open up a new sketch, copy the hello world sketch into it, compile, program, and run and verify that you are getting the words "Hello World" on your screen.

    char gpsData = Serial3.read();//new

If there is nothing to read, what is stored in gpsData?

Current code below is returning the following data "ÿ" that's all I'm getting over and over.

Hopefully, now you know why.

What position is the DLINE/UART switch in? It needs to be in DLINE.