0

Ultimate GPS - ZDA weirdness
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Ultimate GPS - ZDA weirdness

by whoneyc on Fri Jan 11, 2019 1:07 pm

TLDR: I built a project that made use of the Ultimate GPS on the GPIO of a RasPi. I prototyped it and wrote code in one location, then deployed it in a national park 40mi/64km southwest from my location in the central US. I got different NMEA sentences in different locations. Why?

The story: Part of the use of this GPS is to get accurate time for a remote project with spotty power in the field instead of using an RTC. I had some trouble getting the GPS to play nicely with the RasPi 2, so I hacked it together by manually reading the strings output from the /dev/ttyAMA0 and parsing the text of the string. In my prototyping location, I had no problems getting the ZDA sentence, which gives corrected time in an easily parsed format. However, at the field site I stopped getting the ZDA sentence. All of the other sentences appear to be the same (e.g. GGA is still present). What's going on here? Am I getting a different satellite?

Version info: I think I had the v3, but I bought it through the Amazon site, and I didn't pay close attention to the silkscreen. The RasPi is version 2 with current Raspbian build. The python code reads directly from the serial output of the /dev/ttyAMA0.

Github repo will full project code: https://github.com/BlueNalgene/Beep_Inn

Relevant code snippet:
Code: Select all | TOGGLE FULL SIZE
def gpscoord(self):
'''Checks if GPS is enabled in the system.
If it is, gets coordinates from gpsd.
Sends as string.
'''
import calendar
import datetime
import serial

gptime = ''
gplong = ''
gplati = ''
while not (gptime and gplong and gplati):
   with serial.Serial('/dev/ttyAMA0', 9600, timeout=1) as ser:
      line = ser.readline()
      line = str(line.decode('utf-8'))
      print(line)
      result = [x.strip() for x in line.split(',')]
      if "GPZDA" in result[0]:
         convunix = result[1]
         convunix = convunix[0:2] + ',' + convunix[2:4] + ',' + convunix[4:] +  ',' +\
            result[2] +  ',' + result[3] +  ',' + result[4]
         gptime = calendar.timegm(datetime.datetime.strptime(convunix,\
            "%H,%M,%S.%f,%d,%m,%Y").timetuple())
      elif "GPGGA" in result[0]:
         gplati = result[2] + result[3]
         gplong = result[4] + result[5]
      else:
         pass
   if gptime:
      print(gptime)
   else:
      print("WAITING...")
   if gplong:
      print(gplong)
   else:
      print("WAITING...")
   if gplati:
      print(gplati)
   else:
      print("WAITING...")
with open(str(self.cfg.localpath() + '/temp.csv'), 'w') as fff:
   fff.write("Latitude, Longitude, Corrected Start Time\n")
   relinf = str(gplati) + ',' + str(gplong) + ',' + str(gptime) + '\n'
   fff.write(relinf)
   fff.write('Time(s, UTC, unix), Scan Freq(Hz), Peak Freq(Hz), Amp_baseline(dB), Amp_Hit(dB)\n')
self.gpstimestart = gptime
return


Reference text: https://www.gpsinformation.org/dale/nmea.htm

whoneyc
 
Posts: 6
Joined: Fri Jan 11, 2019 12:49 pm

Re: Ultimate GPS - ZDA weirdness

by franklin97355 on Fri Jan 11, 2019 2:08 pm

Have you tried just reading the raw data to see what the GPS is sending to your program? If so can you post some of that?

franklin97355
 
Posts: 19728
Joined: Mon Apr 21, 2008 2:33 pm
Location: Lacomb, OR.

Re: Ultimate GPS - ZDA weirdness

by whoneyc on Fri Jan 11, 2019 2:42 pm

franklin97355 wrote:Have you tried just reading the raw data to see what the GPS is sending to your program? If so can you post some of that?


I can't post that, because the GPS is currently at the field site and I am not. I can tell you what I remember seeing. I will omit the actual content of the sentences, because they were normal. My grad student out there is not the computer wizard, so asking her to pull the data for me would be a challenge.

At prototype site:
GPGGA
GPGSA
GPGSV
GPRMC
GPZDA

At field site:
GPGGA
GPGSA
GPGSV
GPRMC

whoneyc
 
Posts: 6
Joined: Fri Jan 11, 2019 12:49 pm

Re: Ultimate GPS - ZDA weirdness

by adafruit2 on Fri Jan 11, 2019 3:50 pm

i think something is odd with what you're doing because we've never seen ZDA output from the ultimate GPS - perhaps its another GPS they're using? either way, its a nonstandard sentence - we recommend RMC or other 'common' NMEAs!

adafruit2
Site Admin
 
Posts: 17879
Joined: Fri Mar 11, 2005 7:36 pm

Re: Ultimate GPS - ZDA weirdness

by whoneyc on Fri Jan 11, 2019 4:00 pm

adafruit2 wrote:i think something is odd with what you're doing because we've never seen ZDA output from the ultimate GPS - perhaps its another GPS they're using? either way, its a nonstandard sentence - we recommend RMC or other 'common' NMEAs!


Yep, I switched to RMC in the code today. I expect that will work fine.

Still the ZDA is a mystery. The MTK3339 should not even output that according to the specs (which I should have read first rather than guessing based on the output codes). Perhaps there was some malformed info going in or out.

In lieu of a better answer, I say we chalk this one up to ghosts and angered gods of geodesy. Issue closed unless I see it again.

whoneyc
 
Posts: 6
Joined: Fri Jan 11, 2019 12:49 pm

Re: Ultimate GPS - ZDA weirdness

by MikeBarela on Fri Jan 11, 2019 4:01 pm

If you bought it off Amazon it might not be the same module as the one Adafruit sells thus different behavior.

MikeBarela
 
Posts: 705
Joined: Sat Mar 24, 2012 8:56 pm
Location: Mid-Atlantic

Re: Ultimate GPS - ZDA weirdness

by whoneyc on Fri Jan 11, 2019 4:05 pm

MikeBarela wrote:If you bought it off Amazon it might not be the same module as the one Adafruit sells thus different behavior.


Uh oh, the Chinese might be tracking my super sensitive bird counting robot!

On a serious note, has anyone encountered knock-offs? Are there tells on the packaging? Everything from the Amazon box was like I expect to see from Adafruit, and the seller on Amazon prime is Adafruit. If there is a man in the middle operation happening, I think everyone would be very interested to hear about it.

whoneyc
 
Posts: 6
Joined: Fri Jan 11, 2019 12:49 pm

Re: Ultimate GPS - ZDA weirdness

by MikeBarela on Fri Jan 11, 2019 4:29 pm

Adafruit does not sell off of Amazon, if you have a link to the product page, it can be looked at.

As user Adafruit2 said, maybe look at the other NMEA data?

MikeBarela
 
Posts: 705
Joined: Sat Mar 24, 2012 8:56 pm
Location: Mid-Atlantic

Re: Ultimate GPS - ZDA weirdness

by franklin97355 on Fri Jan 11, 2019 4:43 pm

There are independent distributors that sell on Amazon but you have to be careful when buying from an unknown source. We support our hardware and distributors but you need to deal with the seller when possible. Technical questions are always welcome here.

franklin97355
 
Posts: 19728
Joined: Mon Apr 21, 2008 2:33 pm
Location: Lacomb, OR.

Re: Ultimate GPS - ZDA weirdness

by MikeBarela on Fri Jan 11, 2019 4:43 pm

Here is the guide page Adafruit has for interfacing the Adafruit Ultimate GPS to the Raspberry Pi with Python code
https://learn.adafruit.com/adafruit-ult ... on-parsing

MikeBarela
 
Posts: 705
Joined: Sat Mar 24, 2012 8:56 pm
Location: Mid-Atlantic

Re: Ultimate GPS - ZDA weirdness

by whoneyc on Fri Jan 11, 2019 6:48 pm

franklin97355 wrote:There are independent distributors that sell on Amazon but you have to be careful when buying from an unknown source. We support our hardware and distributors but you need to deal with the seller when possible. Technical questions are always welcome here.


I am going to check who fulfilled the Amazon order. I have to get the receipt from the PI who made the purchase. Is there someone I can contact to verify if the dealer was legit?

whoneyc
 
Posts: 6
Joined: Fri Jan 11, 2019 12:49 pm

Re: Ultimate GPS - ZDA weirdness

by whoneyc on Fri Jan 11, 2019 7:01 pm

MikeBarela wrote:Here is the guide page Adafruit has for interfacing the Adafruit Ultimate GPS to the Raspberry Pi with Python code
https://learn.adafruit.com/adafruit-ult ... on-parsing


Thanks for the suggestion Mike. That is what I used originally when constructing the program, and I chose to take a different path. I would like to avoid using a Python package crutch early on, because this project is going to transition from the Raspberry Pi to a lower power ATMega/Arduino version. Yet, the program is still in Python due to time constraints.

I wanted to simply pull in the values as text strings as a way to teach myself the NMEA protocol. The guides are useful for that, but I am one of those folks that has to try it, break it, and un-break it to really grok what is happening. Plus, the Circuit Python framework struck me as a bloaty overkill solution for something which could be solved in a quick script. The irony of worrying about bloat while using Python is not lost on me. So I just did some simple read/parse commands from the /dev output.

whoneyc
 
Posts: 6
Joined: Fri Jan 11, 2019 12:49 pm

Re: Ultimate GPS - ZDA weirdness

by franklin97355 on Fri Jan 11, 2019 8:38 pm

We have a list of distributors on our site but I don't know if it includes those that only do business online.

franklin97355
 
Posts: 19728
Joined: Mon Apr 21, 2008 2:33 pm
Location: Lacomb, OR.

Re: Ultimate GPS - ZDA weirdness

by MikeBarela on Fri Jan 11, 2019 11:08 pm

whoneyc wrote:
MikeBarela wrote:Here is the guide page Adafruit has for interfacing the Adafruit Ultimate GPS to the Raspberry Pi with Python code
https://learn.adafruit.com/adafruit-ult ... on-parsing


Thanks for the suggestion Mike. That is what I used originally when constructing the program, and I chose to take a different path. I would like to avoid using a Python package crutch early on, because this project is going to transition from the Raspberry Pi to a lower power ATMega/Arduino version. Yet, the program is still in Python due to time constraints.

I wanted to simply pull in the values as text strings as a way to teach myself the NMEA protocol. The guides are useful for that, but I am one of those folks that has to try it, break it, and un-break it to really grok what is happening. Plus, the Circuit Python framework struck me as a bloaty overkill solution for something which could be solved in a quick script. The irony of worrying about bloat while using Python is not lost on me. So I just did some simple read/parse commands from the /dev output.


Understood but if you want to test your hardware, I suggest loading up Adafruit's code to see if it works (use a working program then try a suspect program). If your hardware works, you can debug your program. If your hardware does not work, you can further see about if the module is from Adafruit or possibly not.

MikeBarela
 
Posts: 705
Joined: Sat Mar 24, 2012 8:56 pm
Location: Mid-Atlantic

Please be positive and constructive with your questions and comments.