Incorrect/Odd GPS Data?

This is what I am seeing from the device (data is going for now to for testing)

“Lat-Lon”: [
“Date”: “21/09/2023 08:32:10”

The actual location is 51.52853883N and 0.12668167W (in London) … so the device is way off. What’s going on?

This is basically using the example provided.

Hi @pat.molloy. The provided example returns location data in NMEA format. Therefore, if you convert your Lat-Lon value to decimal format, you will obtain the coordinates as you specified.

You can use this site for the conversion: Simple Converter from NMEA to Decimal (

We will consider to provide GPS output in decimal format.

Ah. Thank you. That is a new one on me, I have to admit. I did not even know there was an NMEA format :slight_smile: Everything I have ever used has given decimal!

This little function seems to work, you pass in loc[0] for latitiude, loc[1] for longitude …

def nmea_to_dec (loc):

# Expects an NMEA format GPS location, converts to decimal
# NMEA is (d)ddmm.mmmm[NSEW] e.g. "5131.7131N" (which converts to float 51.528551)

if(loc[-1] == "S" or loc[-1] == "W"): 
    mult = -1.0 # negative if S or W
    mult = 1.0 # positive if N or E

a = float(loc[0:-1]) # get rid of the last character and convert to float from string
b = int(a/100) 
c = b +((a-(b*100))/60) # convert the minutes to decimal

1 Like

You’re welcome.

Yes, the function also seems correct to me.

@pat.molloy I recently came across an interesting optimization idea.
If you look in the document called “GNSS Application Note” on page 48 you would see there are six modes labeled 0 to 5. The SDK by default uses 0 (The response of AT+QGPSLOC? is the same as that of AT+QGPSLOC=0).
If you navigate to in the SDK at line 104 and modify the command to command = “AT+QGPSLOC=2” then there is no need for conversion which can help save resources on the pi.

Good point, @nigel.f.francis! We’ve already updated it in this branch. It will be merged into the master branch in the close future.

Excellent find! Thanks very much indeed!

1 Like