Search code examples
pythonubunturaspberry-piraspbiangpsd

Weird strings when reading the GPS data from the receiver


I tried to read the GPS data from the receiver. I got strange strings as a result. Where is the problem?

import serial

port = "/dev/ttyUSB0"    # Raspberry Pi 3

def parseGPS(data):
        print(data)
        #...

ser = serial.Serial(port, baudrate = 9600, timeout = 0.5)
while True:
    data = ser.readline()
    parseGPS(data)

result


Solution

  • The Problem was the wrong baud rate. Next example works problem-free:

    import serial
    
    port = "/dev/ttyUSB0"  # Raspberry Pi 3
    
    def parseGPS(data):
       print(data)
       # ...
    
    ser = serial.Serial(port, baudrate=4800, timeout=0.5)
    while True:
       data = ser.readline()
       parseGPS(data)