This is what I am seeing from the device (data is going for now to webhook.site for testing)
“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 (hiddenvision.co.uk)
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 Everything I have ever used has given decimal!
This little function seems to work, you pass in loc for latitiude, loc 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
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 gps.py 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!