Created
April 20, 2021 07:58
-
-
Save farhangnaderi/c21e9d42c8ce41ee3559c59469a0c9d4 to your computer and use it in GitHub Desktop.
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 | |
import pynmea2 | |
serialPort = serial.Serial("/dev/ttyUSB0", 9600, timeout=0.5) | |
def parseGPS(str): | |
if str.find("GPGGA") > 0: | |
msg = pynmea2.parse(str) | |
print (msg) | |
print ("Timestamp: %s -- Lat: %s %s -- Lon: %s %s -- Altitude: %s %s" % (msg.timestamp,msg.lat,msg.lat_dir,msg.lon,msg.lon_dir,msg.altitude,msg.altitude_units)) | |
while True: | |
str = serialPort.readline() | |
str2 = str.decode("utf-8") | |
parseGPS(str2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment