I think I’m getting inaccurate NMEA messages

Using a ZED-F9P. Latitude and longitude in u-center dashboard is accurate, but the NMEA messages in u-center’s Text Console, as well as the output from my Python script in VSCode, are off by about 0.3 degrees. Any thoughts or suggestions would be appreciated!

Thanks :slight_smile:

3 Likes

Hi Jacob,

That’s a weird one! 30km of error is huge!

I’ve been doing a bit of reading on u-blox’s implementation of the NMEA protocol, could you share an example of the sentences you are receiving in the text feed, but with the actual lat/long obfuscated? Perhaps it’s some kind of correction data added to the tail end of the data? I wish I had the use case to deal with those cool ZED modules more so I could be more helpful here!

Keen to get to the bottom of this one :slight_smile:
-James

3 Likes

Some modules will output lat long without a fix. Did the GGA sentence indicate a fix was established?

2 Likes

Latitude and longitude in u-center dashboard is accurate

Is this in the box at top right of the u-center screen?

1 Like

Hi everyone,

I’ve been on Stack Overflow several times today and I have reached a solution, although my understanding of what is happening is still no better :upside_down_face:

There was a logic error in the Python script. When I posted my question this was the code:

import serial

gps = serial.Serial('com5', baudrate=9600)

while True:
    ser_bytes = gps.readline()
    decoded_bytes = ser_bytes.decode("utf-8")
    data = decoded_bytes.split(",")
    if data[0] == '$GNRMC':
        lat_nmea = (data[3],data[4])
        lat_degrees = float(lat_nmea[0][0:2])
        if lat_nmea[1] == 'S':
            lat_degrees = -lat_degrees
        lat_minutes = float(lat_nmea[0][2:])
        lat = lat_degrees + (lat_minutes/60)
        lon_nmea = (data[5],data[6])
        lon_degrees = float(lon_nmea[0][:3])
        if lon_nmea[1] == 'W':
            lon_degrees = -lon_degrees
        lon_minutes = float(lon_nmea[0][3:])
        lon = lon_degrees + (lon_minutes/60)
        print("%0.8f" %lat, "%0.8f" %lon)

Expected output, i.e. what I could see in u-center data view (Yes John74406 the black rectangle at the top right):

-12.63900217 111.85371867

Actual output:

-11.36120217 111.85371867

@James This was the GGA message (seems to me that neither the latitude or longitude match any of the outputs. Is this normal?):

$GNGGA,130038.00,1238.34708,S,11129.52477,E,1,12,0.52,11.0,M,16.6,M,*64

@Gramo The fix type had a value of 1 in the GGA message. I’m a novice but I believe that is a GPS fix without correction data? Maybe you could help me understand the significance :grin:

after help from Stack Overflow I moved the if statements to the end of the code:

import serial

gps = serial.Serial('com5', baudrate=9600)

while True:
    ser_bytes = gps.readline()
    decoded_bytes = ser_bytes.decode("utf-8")
    data = decoded_bytes.split(",")
    if data[0] == '$GNRMC':
        lat_nmea = (data[3],data[4])
        lat_degrees = float(lat_nmea[0][0:2])
        lat_minutes = float(lat_nmea[0][2:])
        lat = lat_degrees + (lat_minutes/60)
        lon_nmea = (data[5],data[6])
        lon_degrees = float(lon_nmea[0][:3])
        lon_minutes = float(lon_nmea[0][3:])
        lon = lon_degrees + (lon_minutes/60)
        if lat_nmea[1] == 'S':
            lat = -lat
        if lon_nmea[1] == 'W':
            lon = -lon
        print("%0.8f" %lat, "%0.8f" %lon)

This prints the latitude and longitude as expected (accurate).

All is well that ends well, but I’d be interested to hear your thoughts. I’m going to try and learn how to apply correction data next so I would appreciate any deeper understanding of what’s happening. Thanks! :grinning:

2 Likes

Glad to hear you are back on track!

My thoughts? You often get exactly what you coded for :slight_smile: It’s always a good idea to debug starting with the raw data, and then step through transformative logic line by line.

What correction service are you going to use - I’ve not gone down that path?

3 Likes

@Gramo I’m using the AUSCORS NTRIP Broadcaster. It’s free and there are Reference Stations all over the place. I’m not sure how to utilise it without using a desktop app like PyGPSClient or u-center. If you or anyone else can point me in the right direction, I’d appreciate your advice :grin:

3 Likes

Hi Jacob
Sorry I can’t help with your problem but as an interest are you on a boat. according to Google Earth those co-ordinates are out in the Indian ocean, somewhere south of East Java.and sort of South East of Christmas Island. Lots of water but not much in the way of buildings etc.
Cheers Bob

2 Likes

@Robert93820 Hi Robert
No I’m on land, I just didn’t want to publish my (very very accurate) location. :smile:
However, from what I’ve seen the AUSCORS reference stations near the coast could still be useful. Even beyond the recommended 10km range of the reference station (which I am) the corrections are very reliable, to the point I can tell whether the module is on the left or right side of the car roof.

I haven’t looked into options for deep sea.

4 Likes

Nice, what sort of accuracy do you expect using that service?

1 Like

Hi Jacob

Can understand that.
Cheers Bob

1 Like

There’s a simple mistake here (to someone who started programming over 50 years ago).
The intent is that S and W readings be negative and N and E readings be positive. And the first block of code sort of does that EXCEPT it adds in the minutes after doing the positive to negative conversion:
-12+0.63900217=-11.36099783 - what the original code came up with (more or less)
-12.63900217 is what should have come up.
The second scrap of code adds degrees and minutes before doing the positive to negative conversion, the problem is fixed

4 Likes

As long as I can see the sky, even by a window, ±4cm Lat and ±26cm Long.

3 Likes