Unable to get a GPS Fix

Hey guys, I'm very new to the Arduino/DIY circuit board scene.

I saw someone trying to make a GPS Speedometer but I'm unable to get any GPS fix (shown on the LCD) when everything is all connected even when sitting outside for 10min. I have tested the GPS module with a TinyGPS++ code and it works fine.

my power supply input is only from a USB power bank ( not from the circuit board pins as shown on the picture)

The serial monitor show's: ⸮⸮

I'm using the following equipment:

  • Arduino Nano 3.0
  • U-blox 6M GPS module
  • 0.96 Inch 128x64 IIC I2c White / Blue OLED LCD Display Module 3.3/5v For Arduino]

#define Program_Version "V1.2"
#define authorname "Stuart Robinson"

#include <TinyGPS++.h>                             //get library here > http://arduiniana.org/libraries/tinygpsplus/
TinyGPSPlus gps;                                   //create the TinyGPS++ object

#define RXpin A3                                   //pin number for GPS RX input into Arduino - TX from GPS
#define TXpin A2                                   //pin number for GPS TX output from Arduino- RX into GPS

#define GPSPOWER -1                                //Pin that controls power to GPS, set to -1 if not used
#define GPSONSTATE HIGH                            //logic level to turn GPS on via pin GPSPOWER 
#define GPSOFFSTATE LOW                            //logic level to turn GPS off via pin GPSPOWER 

#include <SoftwareSerial.h>
SoftwareSerial GPSserial(RXpin, TXpin);


#include <U8x8lib.h>                                      //get library here >  https://github.com/olikraus/u8g2 
U8X8_SSD1306_128X64_NONAME_HW_I2C disp(U8X8_PIN_NONE);    //use this line for standard 0.96" SSD1306
//U8X8_SH1106_128X64_NONAME_HW_I2C disp(U8X8_PIN_NONE);   //use this line for 1.3" OLED often sold as 1.3" SSD1306


float GPSLat;                                      //Latitude from GPS
float GPSLon;                                      //Longitude from GPS
float GPSAlt;                                      //Altitude from GPS
uint8_t GPSSats;                                   //number of GPS satellites in use
uint32_t GPSHdop;                                  //HDOP from GPS
float GPSSpeed;                                    //Speed of GPS, mph  

uint8_t hours, mins, secs, day, month;
uint16_t year;
uint32_t startGetFixmS;
uint32_t endFixmS;


void loop()
{
  if (gpsWaitFix(5))
  {
    Serial.println();
    Serial.println();
    Serial.print(F("Fix time "));
    Serial.print(endFixmS - startGetFixmS);
    Serial.println(F("mS"));

    GPSLat = gps.location.lat();
    GPSLon = gps.location.lng();
    GPSAlt = gps.altitude.meters();
    GPSSats = gps.satellites.value();
    GPSHdop = gps.hdop.value();
    GPSSpeed = gps.speed.mph();

    hours = gps.time.hour();
    mins = gps.time.minute();
    secs = gps.time.second();
    day = gps.date.day();
    month = gps.date.month();
    year = gps.date.year();

    printGPSfix();               //print GPS data to serial monitor
    displayscreen1();            //print GPS data on display
    startGetFixmS = millis();    //have a fix, next thing that happens is checking for a fix, so restart timer
  }
  else
  {
    disp.clearLine(0);
    disp.setCursor(0, 0);
    disp.print(F("No GPS Fix "));
    disp.print( (millis() - startGetFixmS) / 1000 );
    Serial.println();
    Serial.println();
    Serial.print(F("Timeout - No GPS Fix "));
    Serial.print( (millis() - startGetFixmS) / 1000 );
    Serial.println(F("s"));
  }
}


bool gpsWaitFix(uint16_t waitSecs)
{
  //waits a specified number of seconds for a fix, returns true for good fix
  //note that the characters from the GPS are encoded until the location, altitude and date are updated
  //this ensures that the GPGGA and GPRMC sentences have both been received and decoded. 

  uint32_t endwaitmS;
  uint8_t GPSchar;

  Serial.print(F("Wait GPS Fix "));
  Serial.print(waitSecs);
  Serial.println(F(" seconds"));

  endwaitmS = millis() + (waitSecs * 1000);

  while (millis() < endwaitmS)
  {
    if (GPSserial.available() > 0)
    {
      GPSchar = GPSserial.read();
      gps.encode(GPSchar);
      Serial.write(GPSchar);
    }

    if (gps.location.isUpdated() && gps.altitude.isUpdated() && gps.date.isUpdated())
    {
      endFixmS = millis();                                //record the time when we got a GPS fix
      return true;
    }
  }

  return false;
}


void printGPSfix()
{
  float tempfloat;

  Serial.print(F("New GPS Fix "));

  tempfloat = ( (float) GPSHdop / 100);

  Serial.print(F("Latitude,"));
  Serial.print(GPSLat, 6);
  Serial.print(F(",Longitude,"));
  Serial.print(GPSLon, 6);
  Serial.print(F(",Altitude,"));
  Serial.print(GPSAlt, 1);
  Serial.print(F("m,Speed,"));
  Serial.print(GPSSpeed, 1);
  Serial.print(F("mph,Sats,"));
  Serial.print(GPSSats);
  Serial.print(F(",HDOP,"));
  Serial.print(tempfloat, 2);
  Serial.print(F(",Time,"));

  if (hours < 10)
  {
    Serial.print(F("0"));
  }

  Serial.print(hours);
  Serial.print(F(":"));

  if (mins < 10)
  {
    Serial.print(F("0"));
  }

  Serial.print(mins);
  Serial.print(F(":"));

  if (secs < 10)
  {
    Serial.print(F("0"));
  }

  Serial.print(secs);
  Serial.print(F(",Date,"));

  Serial.print(day);
  Serial.print(F("/"));
  Serial.print(month);
  Serial.print(F("/"));
  Serial.print(year);

  Serial.println();
  Serial.println();
}


void displayscreen1()
{
  //show GPS data on display
  float tempfloat;
  tempfloat = ( (float) GPSHdop / 100);

  disp.clearLine(0);
  disp.setCursor(0, 0);
  disp.print(GPSLat, 6);
  disp.clearLine(1);
  disp.setCursor(0, 1);
  disp.print(GPSLon, 6);
  disp.clearLine(2);
  disp.setCursor(0, 2);
  disp.print(GPSAlt,0);
  disp.print(F("m"));
  disp.clearLine(3);
  disp.setCursor(0, 3);
  disp.print(GPSSpeed,0);
  disp.print(F("mph"));
  disp.clearLine(4);
  disp.setCursor(0, 4);
  disp.print(F("Sats "));
  disp.print(GPSSats);
  disp.clearLine(5);
  disp.setCursor(0, 5);
  disp.print(F("HDOP "));
  disp.print(tempfloat);
  disp.clearLine(6);
  disp.setCursor(0, 6);

  if (hours < 10)
  {
    disp.print(F("0"));
  }

  disp.print(hours);
  disp.print(F(":"));

  if (mins < 10)
  {
    disp.print(F("0"));
  }

  disp.print(mins);
  disp.print(F(":"));

  if (secs < 10)
  {
    disp.print(F("0"));
  }

  disp.print(secs);
  disp.print(F("  "));

  disp.clearLine(7);
  disp.setCursor(0, 7);

  disp.print(day);
  disp.print(F("/"));
  disp.print(month);
  disp.print(F("/"));
  disp.print(year);
}


void GPSON()
{
  if (GPSPOWER)
  {
    digitalWrite(GPSPOWER, GPSONSTATE);                         //power up GPS
  }
}


void GPSOFF()
{
  if (GPSPOWER)
  {
    digitalWrite(GPSPOWER, GPSOFFSTATE);                        //power off GPS
  }
}


void setup()
{
  if (GPSPOWER >= 0)
  {
    pinMode(GPSPOWER, OUTPUT);
    GPSON();
  }

  GPSserial.begin(9600);

  Serial.begin(115200);
  Serial.println();
  Serial.print(F(__TIME__));
  Serial.print(F(" "));
  Serial.println(F(__DATE__));
  Serial.println(F(Program_Version));
  Serial.println();

  disp.begin();
  disp.setFont(u8x8_font_chroma48medium8_r);
  disp.clear();
  disp.setCursor(0, 0);
  disp.print(F("Display Ready"));

  Serial.println(F("29_GPS_Checker_With_Display Starting"));
  Serial.println();

  startGetFixmS = millis();
}

have you opened your serial monitor at 115200 bauds?

1 Like

Hello wizard.

I reckon it's essential to have a way to easily view the NMEA sentences coming out of the GPS module. And I mean before it is processed by a custom made sketch.

You could include in yr sketch a routine to simply read the input from the GPS and send it to the monitor.

You could call this routine at the start of your current sketch for 10 seconds. Your sketch could also monitor one of the digital pins and if it goes low then call the routine. You could use a jumper wire to bring the pin low when you want to view the raw output from the GPS.

When my GPS isn't working for me I always always always check the raw output.

Good luck.

If your GPS is working with another TinyGPS++ program, but all your getting on the Serial Monitor is ⸮⸮ it is most likely you have not got your Serial Monitor set up to the right baud rate.

You should be seeing the startup messages;

  Serial.begin(115200);
  Serial.println();
  Serial.print(F(__TIME__));
  Serial.print(F(" "));
  Serial.println(F(__DATE__));
  Serial.println(F(Program_Version));
  Serial.println();

Hi J-M-L, no I have set the Arduino IDE serial monitor to 9600

Ill be trying that out, thank you

Ill check that out also, thanks :slight_smile:

Does the serial monitor rate and GPS baund rate have the be the same eg: 9600?

Are they the same thing?

Update your device. Make sure your device has the latest.
version of its navigation software and Map data.
Submit a correction through your device.
Submit a Correction Online. Wait patiently.
Understand.

No, definetly not, completly idependant.

The program you posted does start with;

  GPSserial.begin(9600);

  Serial.begin(115200);

One begin for the GPS another for the serial monitor.

No keep the gps at 9600 and set the serial monitor at 115200

Of course test outdoor and make sure the antenna is facing the sky

Aaaah, two of the most helpful words of wisdom for GPS tinkerers - patience and understanding.

Well said, Aatmia.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.