BerryGPS setup Guide for Raspberry Pi

来源:互联网 发布:11选5三角算法 编辑:程序博客网 时间:2024/04/30 15:39

BerryGPS uses the serial port on the Raspberry Pi. By default, the serial port is already assigned to the console. This can be confirmed by using;

pi@raspberrypi ~ $ dmesg | grep tty
[ 0.001609] console [tty1] enabled
[ 0.092061] 3f201000.uart: ttyAMA0 at MMIO 0x3f201000 (irq = 87, base_baud = 0) is a PL011 rev2
[ 0.594855] console [ttyAMA0] enabled

The last line above shows that the console is enabled for the serial port.
ttyS0 = Serial for Raspberry Pi 3
ttyAMA0 = Serial for all other Raspberry Pi

On new versions of Raspbian,  ‘serial0’ is assigned as an alias to either of the above devices. This makes the device a lot easier to remember.

pi@raspberrypi ~ $ ls -l /dev/serial0
lrwxrwxrwx 1 root root 5 Aug 28 12:49 /dev/serial0 -> ttyS0

 

We now need to disable the console so we can use the serial device for BerryGPS.

Setup Serial for BerryGPS

1. Update software and OS
pi@raspberrypi ~ $ sudo apt-get update
pi@raspberrypi ~ $ sudo apt-get upgrade
pi@raspberrypi ~ $ sudo reboot
2. Open raspi-config and disable serial console

The serial console needs to be disabled and then the serial port enabled.

pi@raspberrypi ~ $ sudo raspi-config

Select interfacing options -> Serial -> No -> Yes
And then Yes to reboot

 

 

 

Test and View GPS data

We can now test to see if we can see the raw GPS data, which would be outputted in NMEA sentences .

NMEA sentences contain all the requered GPS data needed to get and acruate location reading. E.g longatute, latitude, number of statilites, etc..

There are a number of ways to do this, using catMinicom or Screen and  specifying the serial device.

Cat
pi@raspberrypi ~ $ cat /dev/serial0
Minicom
pi@raspberrypi ~ $ sudo apt-get install minicom -y
pi@raspberrypi ~ $ minicom -b 9600 -o -D /dev/serial0

-b = baurdrate. BerryGPS’s default baurdrate is 9600
-d = Serial device

Here are some useful commands while using Minicom
Exit  – Ctrl+A and then q
Help, –  Ctrl+A and then z
Settings, –  Ctrl+A and then o

Screen
pi@raspberrypi ~ $ sudo apt-get install screen
pi@raspberrypi ~ $ screen /dev/serial0 9600

 

Below is two examples of what you would see.
The first image is when you GPS has been up and running for awhile and has a fix. If your GPS has a fix, you would also see the green fix LED flash.

Raspberry pi GPS NMEA

The second image is when your GPS is trying to obtain a fix. As you can see, most of the NMEA data is empty. On first power up, it can take your GPS module awhile to get a fix. It could be longer than 10 minutes in some situations, it all depends on interference and if your GPS has clear access to the sky.

Raspberry pi GPS NMEA

A summary of the default NMEA sentences that BerryGPS will output;

$GPVTGVector track and Speed over the Ground$GPGGAGGA – essential fix data which provide 3D location and accuracy data.$GPGLLGLL – Geographic Latitude and Longitude$GPGSAGSA – details on the nature of the fix. It includes the numbers of the satellites$GPGSVDetailed satelite data$GPRMCRMC – The recommended minimum

This link has  some great information on how to read NMEA sentences.

 

Viewing Meaningful GPS Data

There are number of freely available tools which we can used to view meaningful information from BerryGPS, like longitude, latitude and ground speed.

First, we will install GPSD. gpsd is a daemon that receives data from a GPS receiver, and provides the data back to multiple applications such gpsmon and cgps.

Install, gpsd, gpsmon and cgps;

pi@raspberrypi ~ $ sudo apt-get install gpsd-clients gpsd -y

If you need to stop gpsd, you can use

pi@raspberrypi ~ $ sudo killall gpsd

Be default, gpsd is configured to stat at boot and run in the background. If you are fine with this, you will need to edit the config file so that gpsd uses the correct serial device.

pi@raspberrypi ~ $ sudo nano /etc/default/gpsd

Look for
DEVICES=””
and change it to
DEVICES=”/dev/serial0″

Reboot once you have updated the above file.

If you want to manually run gpsd, you will need to disable it from starting at boot;

pi@raspberrypi ~ $ sudo systemctl stop gpsd.socket
pi@raspberrypi ~ $ sudo systemctl disable gpsd.socket

To force it to autostart again at boot;

pi@raspberrypi ~ $ sudo systemctl enable gpsd.socket
pi@raspberrypi ~ $ sudo systemctl start gpsd.socket

 

If you have disabled gpsd from automatically started at boot, you will need to start if before running gpsmon or cgps

pi@raspberrypi ~ $ sudo gpsd /dev/serial0 -F /var/run/gpsd.sock

 

You can now use gpsmon or cgps to view GPS data.

pi@raspberrypi ~ $ gpsmon

gpsmon raspberrypi

pi@raspberrypi ~ $ cgps

gps raspberry pi

When gpsd is running, you will not be able to see the raw NMEA data on /dev/serial0 as the serial device will show as busy.
You can use gpspipe to view this data while gpsd is running.

pi@raspberrypi ~ $ gpspipe -r

 

Other Tools

gpsprof  performs accuracy, latency, and time drift profiling on a GPS. It emits to standard output a GNUPLOT scatter graph.
The command below will take 100 samples from BerryGPS and display them in a graph.

pi@raspberrypi ~ $ gpsprof | gnuplot -persist

gpsprof gps raspberry pi


原创粉丝点击