Gemäss Ki sollte es gehen. Hier der Python code den er vorschlägt:
import serial
import pynmea2
Configure serial port (default for L76X is 9600 baud)
Raspberry Pi 3/4/5 usually use /dev/ttyS0 or /dev/ttyAMA0
port = "/dev/ttyS0"
baud = 9600
try:
ser = serial.Serial(port, baudrate=baud, timeout=1)
print("Listening for GNSS data... (Ensure antenna is outdoors)")
while True:
line = ser.readline().decode('ascii', errors='replace').strip()
# Check for RMC (Recommended Minimum Navigation Information) sentence
if line.startswith('$GNRMC') or line.startswith('$GPRMC'):
try:
msg = pynmea2.parse(line)
if msg.status == 'A': # 'A' means the data is valid (Fixed)
# msg.timestamp is a datetime.time object
print(f"Precise UTC Time: {msg.timestamp}")
print(f"Date: {msg.datestamp}")
else:
print("Waiting for GNSS fix...")
except pynmea2.ParseError:
continue
except serial.SerialException as e:
print(f"Serial Error: {e}")
except KeyboardInterrupt:
print("\nExiting...")
Use code with caution !
Key Considerations for Precision
GNSS Fix Required: The module must have a "fix" (minimum 3-4 satellites) to provide accurate time. This can take 35+ seconds outdoors.
PPS for Microsecond Accuracy: For extreme precision (nanoseconds/microseconds), you should use the 1PPS (Pulse Per Second) signal pin. You can wire this pin to a Raspberry Pi GPIO and use tools like gpsd and chrony to synchronize the system clock.
Timezone: The time provided is UTC. You will need to apply your local offset manually in Python if needed.