Raspberry Pi practice problem · I²C, SPI, UART & 1-Wire
Satellite clock
EasyBudget $20Python · gpiozero
A GPS module prints NMEA sentences on the UART once a second. Even before it has found its position, the $GPRMC sentence carries the UTC time.
Build: a GPS module powered from 3V3, its TX to the Pi's RXD (GPIO15) and its RX to TXD (GPIO14).
Program: open /dev/serial0 at 9600 baud, and for every $GPRMC line print its time:
UTC 09:00:03
The module has no fix during the test (it is still searching for satellites). The test's clock starts at 09:00:00 UTC.
Tip: pynmea2.parse(line) gives an object whose .timestamp is a datetime.time; strftime("%H:%M:%S") formats it.