unable to get my GPS module to output valid coordinates

Hi there.

I’m using this Sparkfun Venus GPS module with the same SMA connector -

And I’ve attached the connector to this ANT-555 antenna module:

Now I’ve attached the connections as follows:

Arduino GND - GPS GND
Arduino 3.3V - GPS 3.3V
Arduino pin 10 - GPS TX (10 is the RX pin of the software serial in my code)

And I’ve connected the Arduino Uno with a 5V usb cable to my laptop.

And here is the code I’m currently using, taken from an example in the GPS

#include <SoftwareSerial.h>

#include <TinyGPS.h>

/* This sample code demonstrates the normal use of a TinyGPS object.
   It requires the use of SoftwareSerial, and assumes that you have a
   4800-baud serial GPS device hooked up on pins 4(rx) and 3(tx).
*/

TinyGPS gps;
SoftwareSerial ss(10, 11);

void setup()
{
  Serial.begin(115200);
  ss.begin(4800);
  
  Serial.print("Simple TinyGPS library v. "); Serial.println(TinyGPS::library_version());
  Serial.println("by Mikal Hart");
  Serial.println();
}

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

  // For one second we parse GPS data and report some key values
  for (unsigned long start = millis(); millis() - start < 1000;)
  {
    while (ss.available())
    {
      char c = ss.read();
      // Serial.write(c); // uncomment this line if you want to see the GPS data flowing
      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);
    Serial.print("LAT=");
    Serial.print(flat == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : flat, 6);
    Serial.print(" LON=");
    Serial.print(flon == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : flon, 6);
    Serial.print(" SAT=");
    Serial.print(gps.satellites() == TinyGPS::GPS_INVALID_SATELLITES ? 0 : gps.satellites());
    Serial.print(" PREC=");
    Serial.print(gps.hdop() == TinyGPS::GPS_INVALID_HDOP ? 0 : gps.hdop());
  }
  
  gps.stats(&chars, &sentences, &failed);
  Serial.print(" CHARS=");
  Serial.print(chars);
  Serial.print(" SENTENCES=");
  Serial.print(sentences);
  Serial.print(" CSUM ERR=");
  Serial.println(failed);
  if (chars == 0)
    Serial.println("** No characters received from GPS: check wiring **");
}

I don’t receive LAT or LONG output. This is what I get:

I’ve taken my setup outside but the result is exactly the same. I then tried another code over here and while the output for that guy seems to be fine, I get 0000 and 0000 for both the LAT and LONG.

Lastly, I tried with this GPS software but that didn’t seem to give any output either.

Any idea what could possibly be wrong here? I’m confused and you’re help would greatly be appreciated!

According to the output, the sketch is receiving characters, but they aren't NMEA sentences. It could be the wrong baud rate. The Sparkfun page says the baud rate defaults to 9600, not 4800.

My NeoGPS library has a diagnostic program that might help. More info here.

BTW, this is a 3.3V module, so the GPS TX pin output voltage (~2.9V) is slightly under the Arduino RX pin input voltage for a logic 1 (3.0V). It works for many people, but it could also be causing problems with the Arduino receiving the chars correctly. Search for "level shifting". I prefer level-shifting modules, because they're cheap, reliable and will also work for high-speed interfaces like an SD card reader. Here's a do-it-yourself schematic for those modules. Or, for this (relatively) low-speed serial interface, here's my previous reply that uses a few resistors and a diode.

Cheers,
/dev

I'm more confused now.

I made the level shifting circuit exactly as you mentioned (with the resistors and diode) and I believe I've done it correct since I get ~3.2 volts on both the RX and TX pins. Then I tried the NMEAdiagnostic.ino code and it yielded the message "Check GPS device and/or connections. No data received." Baud rate is 9600.

I've connected RX on pin 4 and TX on pin 3 of my Arduino Uno and I've checked the wiring multiple times. Tried 2 other antenna's also. No difference.

Anyways, I tried without the level-shifting circuit and it seemed to get past that message and receive characters but get this message for pretty much every baud rate:

No valid sentences, but characters are being received.
Check baud rate or device protocol configuration.

Received data:
F8

I checked the baud rate on the datasheet and it seems to be 9600 by default.

It can take 15 minutes or more, when out of doors with a clear view of the sky, for a factory fresh GPS module to get a “cold start fix”.

You are much better off just using a terminal program to verify that your GPS is working, than trying to use any library to interpret invalid data.

Or try this code (noting that there are much better options than SoftwareSerial):

#include <SoftwareSerial.h>

/*
   This reads the GPS and echos characters to the serial monitor.
   It requires the use of SoftwareSerial, and assumes that you have a
   4800-baud serial GPS device hooked up on pins 4(rx) and 3(tx).
*/

SoftwareSerial ss(4, 3);

void setup()
{
  Serial.begin(115200);  //must match serial monitor setting
 
  ss.begin(4800);  //must match GPS setting
}

void loop()
{
    while (ss.available())
      Serial.print(ss.read());
}

jremington:
It can take 15 minutes or more, when out of doors with a clear view of the sky, for a factory fresh GPS module to get a "cold start fix".

Before they get a fix, all GPS devices I've seen will send empty fields in the enabled sentences. He should be getting some data, even if it's mostly commas. :slight_smile:

You are much better off just using a terminal program to verify that your GPS is working, than trying to use any library to interpret invalid data.

Uh... thanks? I assume you haven't looked at the program or tried it. In the last step, it performs the simple "echo test" you suggested. It also displays the characters as HEX values:

Received data:
884A0C4C8C480C8808884A0C8C480C4A4CC80A0C027759495995A5084C0A4C88 .J.L.H....J..H.JL....wYIY...L.L

This is very useful for seeing a lot of 0xFF or 0x00 characters when the baud rate is wildly off, or for seeing binary protocol packets if the GPS device is not sending NMEA sentences. After one second of not receiving data, the program stops.

FYI,
/dev

inkosi:
… I get this message for pretty much every baud rate:

No valid sentences, but characters are being received.
Check baud rate or device protocol configuration.

Received data:
F8

Well, that’s all it sent in one second. :frowning:

Like jremington suggested, perhaps you should try AltSoftSerial instead of SoftwareSerial. You have to connect the GPS TX pin to Arduino pin 8. Force the diagnostic program to use it by changing these lines:

 #include <AltSoftSerial.h>
  //#include <NeoSWSerial.h>

BTW, NeoSWSerial only works at 9600, 19200 and 38400, so perhaps other baud rates have not been tried yet. Receiving just a single 0xF8 character can imply the baud rate is much higher than 9600.

…it yielded the message “Check GPS device and/or connections. No data received.” Baud rate is 9600.

Ok, just to be sure about your baud rate comment, did it say this:

Checking baud 9600...
Received GLL
Received RMC
   ...
Received GSA
Received GSV


**** NMEA sentence(s) detected!  ****
Received data:
   <up to 8 lines of echo test characters>

Device baud rate is 9600

GPS data fields received:

  Status,UTC Date/Time,Lat,Lon,Hdg,Spd,Alt,Sats,Rx ok,Rx err,Rx chars,
  3,2016-11-05 13:07:53.00,12.3456,123.4567,,1250,14770,10,21,0,2388,

** NMEAdiagnostic completed **

The message “Device baud rate is 9600” only appears when NMEA sentences are being received (3 seconds worth or 20 complete sentences). That’s good, if that’s what you saw. That means the GPS is really running at 9600, but you are not reading consistently good characters.

And if you saw “data fields received:”, is the next to last field > 0? That’s the NMEA checksum error count (Rx err). If it’s > 0, then the GPS TX line is noisy (or a marginal voltage). Try shorter connecting wires, and make sure they’re secure and positioned away from electrical noise sources.

Looking back at your Original Post, I see that you did get sentences with the doctormonk program:

inkosi:
I then tried another code over here and while the output for that guy seems to be fine, I get 0000 and 0000 for both the LAT and LONG.

That really points to an antenna problem, a power problem, or an impatience problem. :wink: However, the TinyGPS messages point to an incorrect baud rate or a noisy GPS TX wire.

You’ve tried two antennas, so that leaves power and time. The Arduino 3V3 pin is only good for 50mA, but this module needs up to 68mA. It could be that the power is not quite enough. Not using level shifting can use more power (the 3V3 voltage will sag), which may keep it from getting a fix.

When you hooked it up to a PC to use the GPS viewer, did you use a USB-to-TTL Serial (3.3V) converter? That should have enough power, but you still have to give it time to get a fix. Like jremington said, it can take more than 15 minutes to get that first fix.

Cheers,
/dev

No, I haven’t tried NeoGPS. I wrote my own years ago.

For initial testing of device functionality, nothing beats the flexibility of a good terminal program. I recommend Bray terminal for its amazing capabilities.

Hi all,

A real beginner here. This topic maybe a year ago but would just like to help newbies like me, those searching for answers to newbies mistakes.

In my learning process, I have tested this code and found that indeed, the problem was caused by GPS source not having a valid fix. I have tested in a NMEA simulator and NewData will be printed when fix is valid.