Skip to content

Instantly share code, notes, and snippets.

@konsumer
Last active December 17, 2021 09:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save konsumer/1a1fffbeb874e95bea6b64ad63b7e02f to your computer and use it in GitHub Desktop.
Save konsumer/1a1fffbeb874e95bea6b64ad63b7e02f to your computer and use it in GitHub Desktop.
import serial
port = serial.Serial('/dev/ttyTHS1', baudrate=115200, timeout=1)
# Turn on the GPS
port.write(b'AT+CGNSPWR=1')
# Ask for the navigation info parsed from NMEA sentences
port.write(b'AT+CGNSINF')
# Get coordinates
port.write(b'AT+CMGF=1')
latitude, longitude = port.readline().decode('utf8').split(',')
port.close()
print(latitude, longitude)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment