Not receiving data from GPS shield

Hello,

I recently got a GPS shield for arduino, and trying to make it work with my arduino uno


I am using this code that uses TinyGPS++ library

#include <TinyGPS++.h>
#include <SoftwareSerial.h>
/*
 This example uses software serial and the TinyGPS++ library by Mikal Hart
 Based on TinyGPSPlus/DeviceExample.ino by Mikal Hart
 Modified by acavis
*/

// Choose two Arduino pins to use for software serial
// The GPS Shield uses D2 and D3 by default when in DLINE mode
int RXPin = 2;
int TXPin = 3;

// The Skytaq EM-506 GPS module included in the GPS Shield Kit
// uses 4800 baud by default
int GPSBaud = 4800;

// Create a TinyGPS++ object called "gps"
TinyGPSPlus gps;

// Create a software serial port called "gpsSerial"
SoftwareSerial gpsSerial(RXPin, TXPin);

void setup()
{
  // Start the Arduino hardware serial port at 9600 baud
  Serial.begin(9600);

  // Start the software serial port at the GPS's default baud
  gpsSerial.begin(GPSBaud);

  Serial.println(F("DeviceExample.ino"));
  Serial.println(F("A simple demonstration of TinyGPS++ with an attached GPS module"));
  Serial.print(F("Testing TinyGPS++ library v. ")); Serial.println(TinyGPSPlus::libraryVersion());
  Serial.println(F("by Mikal Hart"));
  Serial.println();
}

void loop()
{
  // This sketch displays information every time a new sentence is correctly encoded.
  while (gpsSerial.available() > 0)
    if (gps.encode(gpsSerial.read()))
      displayInfo();

  // If 5000 milliseconds pass and there are no characters coming in
  // over the software serial port, show a "No GPS detected" error
  if (millis() > 5000 && gps.charsProcessed() < 10)
  {
    Serial.println(F("No GPS detected"));
    while(true);
  }
}

void displayInfo()
{
  Serial.print(F("Location: ")); 
  if (gps.location.isValid())
  {
    Serial.print(gps.location.lat(), 6);
    Serial.print(F(","));
    Serial.print(gps.location.lng(), 6);
  }
  else
  {
    Serial.print(F("INVALID"));
  }

  Serial.print(F("  Date/Time: "));
  if (gps.date.isValid())
  {
    Serial.print(gps.date.month());
    Serial.print(F("/"));
    Serial.print(gps.date.day());
    Serial.print(F("/"));
    Serial.print(gps.date.year());
  }
  else
  {
    Serial.print(F("INVALID"));
  }

  Serial.print(F(" "));
  if (gps.time.isValid())
  {
    if (gps.time.hour() < 10) Serial.print(F("0"));
    Serial.print(gps.time.hour());
    Serial.print(F(":"));
    if (gps.time.minute() < 10) Serial.print(F("0"));
    Serial.print(gps.time.minute());
    Serial.print(F(":"));
    if (gps.time.second() < 10) Serial.print(F("0"));
    Serial.print(gps.time.second());
    Serial.print(F("."));
    if (gps.time.centisecond() < 10) Serial.print(F("0"));
    Serial.print(gps.time.centisecond());
  }
  else
  {
    Serial.print(F("INVALID"));
  }

  Serial.println();
}

I am uploading the code while the shield is detached because apparently the pins D0,D1 must be free when uploading.

I am attaching the shield in its place and when I run it I get stuck in the “No GPS connected” message

I am not using an SD card with it yet.
I tried to change the jumpers on between pins 2,3 and 0,1 but still same problem.

Any thoughts on where the problem might be and how to solve it ?

You could start by telling us which shield. Links, etc?

And for the record it’s pins D0 & D1 which shouldn’t be connected to anything.

Sorry its D0,D1 Ill edit the post , and I thought I uploaded images of the shield I upload them again.

the shield is probably made by ITead or a replica of it.

You can use D0/D1 for the GPS... that is actually the best choice (read more here).

To use those pins, move the jumper blocks down to 0 and 1. And you only have to remove the jumper block from pin 0 to upload a new sketch. The shield can remain stacked on the UNO during the upload.

You may also be interested in my NeoGPS library. It is smaller, faster, more reliable and more accurate than all other libraries. It also has a diagnostic program that you can use, once you edit GPSport.h for your connection. If you want to try it, NeoGPS is available from the Arduino IDE Library Manager, under the menu Sketch -> Include Library -> Manage Libraries.

With all deference to slashDev, I think you need to take a couple of steps back.

Firstly I am assuming that you have the square end of the antenna somewhere where it can get a clear view of the sky?

Leave the jumpers where they are and load a simple Serial Relay sketch onto the Arduino:

#define RxPin 2
#define TxPin 3

#include <SoftwareSerial.h>

SoftwareSerial GPS(RxPin, TxPin); // RX, TX

void setup()
{
  pinMode(13, OUTPUT); 
  digitalWrite(13,LOW);  // Turn off pin 13
  GPS.begin(9600);
  Serial.begin(19200);
}

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

Now open the Serial Monitor and set the baud rate to 19200. After a few moments you should get the NMEA data appearing. If not, swap the jumpers over.

Once you you are receiving data then you can use one of the libraries to decode it (SlashDev is slightly biased but NeoGPS is very comprehensive!). The first time it may take some time to get a fix on the satellites.

I would agree with dannable, if you ever think your having problems getting data from a GPS, forget GPS libraries for the moment, use a simple GPS echo program as shown above as your very first troubleshooting step.

You can check the sentances make sense and the progress towards getting a fix.

Thank you guys for the help, I use the code to troubleshoot and solved the problem, which was a bit silly I guess.

I’ve been setting the jumpers on pins 2/3 on the shield as Rx/Tx respectively as Ive seen in the code.

SoftwareSerial gpsSerial(RXPin, TXPin);

It confused me that they named them RxPin/TxPin, these pins refers to the arduino Rx/Tx while on the GPS its the opposite.

Thank you -dev for the library I’ll check it out!

blacklight:
It confused me that they named them RxPin/TxPin, these pins refers to the arduino Rx/Tx while on the GPS its the opposite.

The pins are labeled with thier function for that device, nothing else makes sense really.

So the Arduino RX pin is the pin that the Arduino receives data on and the GPS TX pin is the pin the GPS TXs data on. You want the Arduino to receive the GPS data so you connect Arduino RX to GPS TX.

If the code was made as an example for the shield they should name the pins as on the GPS shield bcz the pins on arduino are not in use and everything is shifted to the GPS shield, but with other modules the connection is wired so it makes sense to name the pins for arduino.

blacklight:
If the code was made as an example for the shield they should name the pins as on the GPS shield bcz the pins on arduino are not in use and everything is shifted to the GPS shield, but with other modules the connection is wired so it makes sense to name the pins for arduino.

They could, but then they would need to make clear in the code that the pins are described in the opposite way to the convention that 99.9% of people expect.

If these tutorial codes were made for the beginners to understand, the comments should do also.
When it confuses me as a beginner its not doing the correct job.