Created
July 26, 2018 09:50
-
-
Save pixelatedpic/4993ad76a4dbf1ec359afe2a86aa691c to your computer and use it in GitHub Desktop.
Raspberry PI interfaced GPS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import serial | |
from time import sleep | |
gpsport = serial.Serial("/dev/ttyAMA0",bytesize=8, parity='N', stopbits=1, timeout=None, xonxoff=0, rtscts=0) | |
#gpsport.flush() | |
#sleep(5) | |
while True: | |
# sleep(.5) | |
# gpsport.flush() | |
raw = gpsport.readline() | |
# print(raw) | |
if raw != 0xff: | |
rxgps = raw.decode('utf-8')[:-1] | |
else: | |
rxgps = "" | |
# rxgps = gpsport.readline().decode('utf-8')[:-1] | |
#rxgps = gpsport.readline() | |
#line = .decode('utf-8')[:-1] | |
data = rxgps.split(',') | |
#print(data[1]) | |
# print(rxgps) | |
if data[0] == "$GPGGA": | |
print(rxgps) | |
# print(data[1]) | |
UTCtime = data[1] | |
Latitude = data[2] | |
Longitude = data[4] | |
SAT = data[7] | |
FIX = data[6] | |
print("UTC: " + UTCtime) | |
print("SAT: " + SAT) | |
print("FIX: " + FIX) | |
print("LAT: " + Latitude) | |
print("LON: " + Longitude) | |
gpsport.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment