PyRaspBeta

← All practice problems

Raspberry Pi practice problem · I²C, SPI, UART & 1-Wire

Which way?

MediumBudget $20Python · gpiozero

While moving, a GPS reports its course over ground in degrees (0 = north, 90 = east), in the $GPRMC sentence (true_course in pynmea2).

Build: a GPS module on the UART (TX → RXD/GPIO15, RX → TXD, 3V3).

Program: for every $GPRMC sentence with a fix (status A), print the course as one of the 8 compass points, each covering 45° centred on its direction (N is 337.5°–22.5°, NE is 22.5°–67.5°, E is 67.5°–112.5°, and so on through SE, S, SW, W, NW):

Heading: E

The test car drives a circle at 40 km/h with an instant fix; it starts heading due east and turns left, so the course drops by about 3° each second.

More in I²C, SPI, UART & 1-Wire