Datasheet

8
lat_ns=GPS.GGA[3]
long=GPS.GGA[4]
long_ew=GPS.GGA[5]
fix=GPS.GGA[6]
sats=GPS.GGA[7]
alt=GPS.GGA[9]
return [time,fix,sats,alt,lat,lat_ns,long,long_ew]
g=GPS()
f=open("gps_data.csv",'w') #Open file to log the data
f.write("name,latitude,longitude\n") #Write the header to the top of
the file
ind=0
while True:
try:
x=g.read() #Read from GPS
[t,fix,sats,alt,lat,lat_ns,long,long_ew]=g.vals() #Get the
individial values
print "Time:",t,"Fix status:",fix,"Sats in
view:",sats,"Altitude",alt,"Lat:",lat,lat_ns,"Long:",long,long_ew
s=str(t)+","+str(float(lat)/100)+","+str(float(long)/100)+"\n"
f.write(s) #Save to file
time.sleep(2)
except IndexError:
print "Unable to read"
except KeyboardInterrupt:
f.close()
print "Exiting"
sys.exit(0)
5. Run the demo.
sudo python grove_gps.py
6.Result
Note: GPS is better outdoor using, recommand you to put your raspberry pi to the window or
any place outdoor.