325 字
2 分钟
Connecting a GPS Module to RPi

Preparation#

The RPi GPS Add-on V2.0 module communicates via the UART interface. You need to enable the UART interface first, otherwise you won’t receive any data

sudo raspi-config

5 Interfacing Options -> P6 Serial — disable both (this operation disables the serial port!)

sudo nano /boot/config.txt

Scroll to the very bottom and change enable_uart=0 to enable_uart=1

Add a line: dtoverlay=pi3-miniuart-bt

After reboot

ls /dev -la |grep serial

pi@RAAZ:~ $ ls /dev -la | grep serial

lrwxrwxrwx 1 root root 7 Feb 12 16:19 serial1 -> ttyAMA0

Find where your GPS module is. Mine is /dev/ttyAMA0; you may need to change it

Then cat /dev/ttyAMA0

You should then see a stream of data; press Ctrl+C to stop.

If there’s no output, the operation may have been wrong, or the module is damaged

GPSD#

Installing GPSD#

sudo apt-get install gpsd gpsd-clients python-gps

Changing the port#

sudo nano /etc/default/gpsd

USBAUTO="false"
DEVICES="/dev/ttyAMA0"
GPSD_OPTIONS="-n"

After making the changes above, reboot the system

cgps

cgps is a client resembling xgps, but without the pictorial satellite display and able to run on a serial terminal or terminal emulator.

The -s option prevents cgps from displaying the data coming from the daemon. This display can also be toggled with the s command.

The -m option will display your magnetic heading (as opposed to your true heading). This is a calculated value, not a measured value, and is subject to a potential error of up to two degrees in the areas for which the calculation is valid (currently Western Europe, Alaska, and Lower 48 in the USA). The formulas used are those found in the Aviation Formulary v1.43.

cgps terminates when you send it a SIGHUP or SIGINT; given default terminal settings this will happen when you type Ctrl-C at it. It will also terminate on ‘q’

Type cgps -s

! If you’re using a GUI rather than a command line, try xgps!

You should be able to see the results

Cold start takes a while

If the number after NO FIX isn’t changing, check whether /dev/ttyAMA0 is producing output

If it takes a long time to get a fix, the GPS signal may be weak

Connecting a GPS Module to RPi
https://tski.uk/blog/en/rpi-gps/
作者
Tokisaki Galaxy
发布于
2020-02-12
许可协议
CC BY