SparkFun Forums 

Where electronics enthusiasts find answers.

Have questions about a SparkFun product or board? This is the place to be.
By jmbc
#193880
Used with a Raspberry 4.4.8, GPS TX port on RPI RX port :
Code: Select all
import serial
import sys
ser = serial.Serial(port='/dev/ttyS0', baudrate=9600, timeout=None,parity=serial.PARITY_NONE, stopbits=serial.STOPBITS_ONE,rtscts=False,xonxoff=False,dsrdtr=False)
while True :
    try:
        data=ser.readline()
        print data,
    except:
        print "Unexpected error:", sys.exc_info()
        sys.exit()
which gives :
Code: Select all
PRMC,1$GPRMC,183902.00,A,4852.08237,N,00238.17086,E,0.101,,140317,,,A*75
$GPVTG,,T,,M,0.101,N,0.187,K,A*2D
$GPGGA,183902.00,4852.08237,N,00238.17086,E,1,10,0.80,40.2,M,46.2,M,,*66
$GPGSA,A,3,29,31,25,26,02,14,21,12,05,23,,,1.31,0.80,1.04*05
$GPGSV,4,1,13,02,18,042,25,04,43,294,30,05,06,077,30,12,12,101,29*70
and so on...
So long chaps
By jmbc
#193896
Actually don't work well.
Looks ok at a glance, but the data is false
The following code
Code: Select all
import serial
ser = serial.Serial(port='/dev/ttyS0', baudrate=9600, timeout=None,parity=serial.PARITY_NONE, stopbits=serial.STOPBITS_ONE,rtscts=False,xonxoff=False,dsrdtr=False) #9600bps, 8 bit data, 1 stop bit, no parity
while True :
    w = ser.readline()
    data = w.split(',')
    if data[0] == '$GPGGA':
        msgID,UTC,Latitude,NSindicator,Longitude,EWindicator,PosFixInd,NbSatellites,HDOP,Altitude,Units,Gsep,Units,w,checksum = data
        hh = UTC[0:2]
        mm = UTC[2:4]
        ss = UTC[4:6]
        print 'UTC time = %s:%s:%s, Latitude = %s%s, Longitude = %s%s, altitude = %s%s, %s satellites' % (hh,mm,ss,Latitude,NSindicator,Longitude,EWindicator,Altitude,Units,NbSatellites)
gives
Code: Select all
UTC time = 15:27:31, Latitude = 4852.08163N, Longitude = 00238.16877E, altitude = 34.6M, 10 satellites
UTC time = 15:27:32, Latitude = 4852.08162N, Longitude = 00238.16873E, altitude = 34.6M, 10 satellites
UTC time = 15:27:33, Latitude = 4852.08155N, Longitude = 00238.16884E, altitude = 34.8M, 10 satellites
UTC time = 15:27:34, Latitude = 4852.08161N, Longitude = 00238.16861E, altitude = 34.6M, 10 satellites
UTC time = 15:27:35, Latitude = 4852.08163N, Longitude = 00238.16857E, altitude = 34.7M, 10 satellites
UTC time = 15:27:36, Latitude = 4852.08164N, Longitude = 00238.16874E, altitude = 35.0M, 10 satellites
UTC time = 15:27:37, Latitude = 4852.08179N, Longitude = 00238.16881E, altitude = 35.4M, 10 satellites
UTC time = 15:27:38, Latitude = 4852.08179N, Longitude = 00238.16855E, altitude = 35.1M, 10 satellites
UTC time = 15:27:39, Latitude = 4852.08184N, Longitude = 00238.16858E, altitude = 35.4M, 10 satellites
The time is ok, but the position is false. A check with gmap show a position at less 50 kilometers too far.
Not acceptable.
I checked the NMEA 0183 reference, and did find a solution.
Work in progress...