MikesRaspberry
Posts: 6
Joined: Wed Jun 10, 2020 9:22 am

GPS NEO-6M GY-NEO6MV2 records missing?

Wed Jul 01, 2020 9:08 am

Hi, I have purchased a "GPS NEO-6M GY-NEO6MV2 " card and attached to my Raspberry Pi; for this effort in home electronics I can obtain from the "$GPRMC" records Date/Time, Latitude and Longitude. From "$GPGSV" records I can obtain the number of satellites used in calculating position information. ……… All good so far, but what I would really like to complete the information set is "Altitude" which should be obtainable from ""$GPGGA" records; the trouble is that I never seem to get any "$GPGGA" records!
Appreciate if anybody could explain for me the logic for what/when records are sent and why I don't see these "$GPGGA" records, or indeed if it is possible to do something to get them?
Many thanks.

User avatar
topguy
Posts: 6425
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: GPS NEO-6M GY-NEO6MV2 records missing?

Wed Jul 01, 2020 9:44 am

You can send commands to the GPS to select which records that will be sent.
To find those commands you need to look in a techincal manual for the specific GPS model.

https://www.waveshare.com/w/upload/a/a9 ... cation.pdf
As you can see from such a document, that protocol for sending these commands can be rather complex..

Which is why uBlox created the software "u-center" for Windows to let people configure their GPS device. Which is why you only get guides like this:
https://www.handheldgroup.com/knowledge ... ps-module/ if you try to google your problem.

... but how to connect your module to a windows computer IDK.

User avatar
rpiMike
Posts: 1310
Joined: Fri Aug 10, 2012 12:38 pm
Location: Cumbria, UK

Re: GPS NEO-6M GY-NEO6MV2 records missing?

Wed Jul 01, 2020 10:00 am

What code are you using to output the GPS records?

MikesRaspberry
Posts: 6
Joined: Wed Jun 10, 2020 9:22 am

Re: GPS NEO-6M GY-NEO6MV2 records missing?

Wed Jul 01, 2020 10:57 am

Basically I have used Pynmea2 to collect and parse the $GPRMC records for Date/Time, Lat and Long; for the $GPGSV records I have simply pulled the NSats string out of the ourput string by position count. As to the Altitude informationm I have made no attempt to parse it yet as I am clearly not getting any $GPGGA records to parse, i.e. nothing gets printed to show I have one.

------------------------------------------------------------------------

Code: Select all

[import serial
import time
from time import *
import string
import sys
sys.path.append("/home/pi/Projects/Library")
import pynmea2
import lcddriver
encoding = 'utf-8'

# on initialise le lcd
lcd = lcddriver.lcd()
# on reinitialise le lcd
lcd.lcd_clear()
ns = "--" #initialise with null

while True:
    port="/dev/ttyAMA0"
    ser=serial.Serial(port, baudrate=9600, timeout=0.5)
    dataout = pynmea2.NMEAStreamReader()
    newdata=ser.readline()
    udata=newdata.decode(encoding)

    if udata[0:6] == "$GPGGA":
        print(udata)
   
    if udata[0:6] == "$GPGSV":
        ns = udata[11:13]
         
    if udata[0:6] == "$GPRMC":
        newmsg=pynmea2.parse(udata)
        lcd.lcd_display_string(str(newmsg.datestamp) + "  NSat: " + ns, 1)
        lcd.lcd_display_string("UTC Time:   " + str(newmsg.timestamp), 2)
        lcd.lcd_display_string("Latitude:    " + str(newmsg.latitude)[:7], 3)
        lcd.lcd_display_string("Longitude:   " + str(newmsg.longitude)[:7], 4)code]
[/code]

User avatar
rpiMike
Posts: 1310
Joined: Fri Aug 10, 2012 12:38 pm
Location: Cumbria, UK

Re: GPS NEO-6M GY-NEO6MV2 records missing?

Wed Jul 01, 2020 11:13 am

What does the following return?

Do you not want the GNGGA message?

Code: Select all

import serial,time,pynmea2

port = '/dev/ttyAMA0'
baud = 9600

serialPort = serial.Serial(port, baudrate = baud, timeout = 0.5)
while True:
    str = serialPort.readline().decode().strip()
    print(str)
    if str.find('GGA') > 0:
        msg = pynmea2.parse(str)
        print("  Timestamp: %s -- Lat: %s %s -- Lon: %s %s -- Altitude: %s %s -- Satellites: %s" % (msg.timestamp,msg.lat,msg.lat_dir,msg.lon,msg.lon_dir,msg.altitude,msg.altitude_units,msg.num_sats))
    time.sleep(0.1)

User avatar
topguy
Posts: 6425
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: GPS NEO-6M GY-NEO6MV2 records missing?

Wed Jul 01, 2020 1:32 pm

Just to be sure you could do "cat /dev/ttyAMA0" in the terminal and look at the raw NMEA.

MikesRaspberry
Posts: 6
Joined: Wed Jun 10, 2020 9:22 am

Re: GPS NEO-6M GY-NEO6MV2 records missing?

Wed Jul 01, 2020 2:36 pm

rpiMike wrote:
Wed Jul 01, 2020 11:13 am
What does the following return?

Do you not want the GNGGA message?

Code: Select all

import serial,time,pynmea2

port = '/dev/ttyAMA0'
baud = 9600

serialPort = serial.Serial(port, baudrate = baud, timeout = 0.5)
while True:
    str = serialPort.readline().decode().strip()
    print(str)
    if str.find('GGA') > 0:
        msg = pynmea2.parse(str)
        print("  Timestamp: %s -- Lat: %s %s -- Lon: %s %s -- Altitude: %s %s -- Satellites: %s" % (msg.timestamp,msg.lat,msg.lat_dir,msg.lon,msg.lon_dir,msg.altitude,msg.altitude_units,msg.num_sats))
    time.sleep(0.1)
Thanks RPiMike, Yes I have now got some usable field data. Clearly I have not understood the structure of these records, not sure that I still do but I have got something to work with and work backwards from now.
Your code above now works for me albeit it in waves; I gets a block or sequence of records where all the fields have been completed and then a block where only Time/Date and Nsat are complete with Lat/Long/Alt having non values. But good enough I can now work with this and work back to understand what gives.
Thanks on a second count for a "master class" in some example of how to do slick python code; as a newbee to python this is very welcome; all I need to do now is work it back to unpick the rules for why it does what it does ;- )

User avatar
rpiMike
Posts: 1310
Joined: Fri Aug 10, 2012 12:38 pm
Location: Cumbria, UK

Re: GPS NEO-6M GY-NEO6MV2 records missing?

Wed Jul 01, 2020 2:40 pm

How is your GPS connected? Have you got the correct baud rate?

Has your GPS got a clear view of the sky?

MikesRaspberry
Posts: 6
Joined: Wed Jun 10, 2020 9:22 am

Re: GPS NEO-6M GY-NEO6MV2 records missing?

Wed Jul 01, 2020 2:46 pm

rpiMike wrote:
Wed Jul 01, 2020 2:40 pm
How is your GPS connected? Have you got the correct baud rate?

Has your GPS got a clear view of the sky?
Its a lower floor room with room above, so yes very likely the intermittent nature is down to poor signal.

Return to “Other projects”