Gps.location.isupdated() condition does not work

I recently set up a GY-NEO6MV2 gps module with an Arduino Uno. I followed the basic scripts out there which used the gps.location.isUpdated() line as an "if" condition. However this never worked for some reason and nothing was printed to my serial. So I added a condition that printed out the raw NMEA sentences my gps spits out to see if my gps was even working. It is as the 3rd field in the $GPRMC line shows "A" which means the gps data is valid, and also I checked the $GPGSA field. However the gps.location.isUpdated() line still doesn't work. I don't know if something is wrong with my condition statements or something's up with my gps module. Also I checked that my TX and RX pins are connected properly to the arduino (TX to RX of arduino and vice versa) so the software serial connection isn't the problem.

#include <Arduino.h>
#include <TinyGPS++.h>
#include <TinyGPS.h>
#include <SoftwareSerial.h>
#define RXpin 11
#define TXpin 10

TinyGPSPlus gps;
SoftwareSerial ss(RXpin,TXpin);
String GPS_nmea;

void setup() {
  Serial.begin(9600);
  ss.begin(9600);
  Serial.println("begin script");
}


void loop()
{

    while (ss.available())
    {
      gps.encode(ss.read());
      if (gps.location.isUpdated())
      {
        Serial.print("Latitude:");
        Serial.println((gps.location.lat()));
        Serial.print("Longitude:");
        Serial.println((gps.location.lng()));
      }

      else
      {
        GPS_nmea = ss.readStringUntil(13);
        if(GPS_nmea.startsWith("$GPRMC"))
        {
          Serial.println(GPS_nmea);
        }
      }

    }

}

Very strange program logic.

And the softwareserial output appears to show a situation where the GPS library is never seeing the $GPRMC sentence, so it will have problems updating location, it needs to see both $GPGGA and $GPRMC

Did you really try the library example; 'DeviceExample.ino' as it does work ?

It could be a parsing problem, have you looked at this thread? GPS.encode always return false - Using Arduino / Programming Questions - Arduino Forum

That thread refers to a very old version of TinyGPS++ which would not parse the $GNGGA and $GNRMC senetences output by default on some Ublox GPSs.

The TinyGPS++ library was updated some years ago to correct that issue.

But in any case the OPs GPS is putting out standard $GP sentences, so the GPS will work with the older TinyGPS++ library.

1 Like

Both??

yea I left it there by accident when I didn't know about TinyGPS++.h but it's not doing any harm just being there so I let it be.

If you say so.

Try one of the examples that came with the TinyGPS++ library. If it works, compare it to your sketch to see where they differ. If the example doesn't work, I would suspect a problem with your GPS.

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