Datasheet
7
import serial, time
import smbus
import math
import RPi.GPIO as GPIO
import struct
import sys
ser = serial.Serial('/dev/ttyAMA0', 9600, timeout = 0) #Open the serial
port at 9600 baud
ser.flush()
class GPS:
#The GPS module used is a Grove GPS module
http://www.seeedstudio.com/depot/Grove-GPS-p-959.html
inp=[]
# Refer to SIM28 NMEA spec file
http://www.seeedstudio.com/wiki/images/a/a0/SIM28_DATA_File.zip
GGA=[]
#Read data from the GPS
def read(self):
while True:
GPS.inp=ser.readline()
if GPS.inp[:6] =='$GPGGA': # GGA data , packet 1, has all the
data we need
break
time.sleep(0.1)
try:
ind=GPS.inp.index('$GPGGA',5,len(GPS.inp)) #Sometimes multiple
GPS data packets come into the stream. Take the data only after the last
'$GPGGA' is seen
GPS.inp=GPS.inp[ind:]
except ValueError:
print ""
GPS.GGA=GPS.inp.split(",") #Split the stream into individual
parts
return [GPS.GGA]
#Split the data into individual elements
def vals(self):
time=GPS.GGA[1]
lat=GPS.GGA[2]