<< Summary

Connect and read an external GPS Raspberry PI

The GPS Connection

We are talking about this one.
There are two possibilities.
With a USB Adapter, or with the GPIO connector.
Either one works fine.
If you are using a USB Adapter, you will bve reading the port /dev/ttyUSB0. If you are using the GPIO connector, you will be using the port /dev/ttyAMA0.
For both, the Baud Rate will be 9600.
In the pictures, we show the colors usually used by the USB Adapter.
On the GPS, we are interested in the pins VIN (red), GND (black), RX (green), TX (white).
And if you are using the USB Adapter, just plug the connectors on the GPS itself (bypass the breadboard), using the same wire colors on the same pins. And plug the USB socket on the Raspberry PI.

Click to enlarge

The Raspberry PI Connection

Here is a description of the GPIO Connector on the Raspberry PI:

Click to enlarge

The GPS VIN (red) goes on GPIO pin #1, 3.3 VDC Power.
The GPS GND (black) goes on GPIO pin #6, 0V (Ground).
The GPS RX (green) goes on GPIO pin #8, TxD.
The GPS TX (white) goes on GPIO pin #10, RxD.

Click to enlarge

Remember: The GPS data are to be read with a Baud Rate of 9600.

 Prompt> CP=./classes:/home/pi/pi4j/pi4j-distribution/target/distro-contents/lib/pi4j-core.jar
 Prompt> sudo java -cp $CP readserialport.NMEAReader 9600
Read serial port
Usage ./run [BaudRate] (default 4800)
Try 2400, 4800, 9600, 19200, 38400, 57600, 115200, ...
Serial Communication.
 ... connect using settings: 9600, N, 8, 1.
 ... data received on serial port should be displayed below.
Opening port [/dev/ttyAMA0] 
$GPGSA,A,3,23,20,07,32,16,06,,,,,,,1.64,1.38,0.88*0F
$GPRMC,020623.000,A,3744.9334,N,12230.4154,W,0.20,114.89,140114,,,D*75
$GPVTG,114.89,T,,M,0.20,N,0.38,K,D*34
$GPGGA,020624.000,3744.9334,N,12230.4154,W,2,6,1.38,11.9,M,-25.5,M,0000,0000*5A
$GPGSA,A,3,23,20,07,32,16,06,,,,,,,1.64,1.38,0.88*0F
$GPRMC,020624.000,A,3744.9334,N,12230.4154,W,0.20,114.89,140114,,,D*72
$GPVTG,114.89,T,,M,0.20,N,0.37,K,D*3B
$GPGGA,020625.000,3744.9334,N,12230.4153,W,2,6,1.38,11.9,M,-25.5,M,0000,0000*5C
$GPGSA,A,3,23,20,07,32,16,06,,,,,,,1.64,1.38,0.88*0F
$GPGSV,4,1,13,23,71,010,17,16,53,093,23,20,52,183,26,13,48,312,*71
$GPGSV,4,2,13,07,30,246,17,32,24,154,17,10,19,316,,04,14,285,*7D
$GPGSV,4,3,13,06,06,111,14,03,06,135,,08,02,236,,27,02,119,*79
$GPGSV,4,4,13,37,,,*7F
$GPRMC,020625.000,A,3744.9334,N,12230.4153,W,0.27,114.89,140114,,,D*73
$GPVTG,114.89,T,,M,0.27,N,0.50,K,D*3D
$GPGGA,020626.000,3744.9334,N,12230.4152,W,2,6,1.38,11.9,M,-25.5,M,0000,0000*5E
$GPGSA,A,3,23,20,07,32,16,06,,,,,,,1.64,1.38,0.88*0F
$GPRMC,020626.000,A,3744.9334,N,12230.4152,W,0.26,114.89,140114,,,D*70
$GPVTG,114.89,T,,M,0.26,N,0.47,K,D*3A
$GPGGA,020627.000,3744.9334,N,12230.4152,W,2,6,1.38,11.9,M,-25.5,M,0000,0000*5F
$GPGSA,A,3,23,20,07,32,16,06,,,,,,,1.64,1.38,0.88*0F
$GPRMC,020627.000,A,3744.9334,N,12230.4152,W,0.28,114.89,140114,,,D*7F
$GPVTG,114.89,T,,M,0.28,N,0.51,K,D*33
$GPGGA,020628.000,3744.9335,N,12230.4151,W,2,6,1.38,11.9,M,-25.5,M,0000,0000*52
$GPGSA,A,3,23,20,07,32,16,06,,,,,,,1.64,1.38,0.88*0F
$GPRMC,020628.000,A,3744.9335,N,12230.4151,W,0.28,114.89,140114,,,D*72
$GPVTG,114.89,T,,M,0.28,N,0.51,K,D*33
$GPGGA,020629.000,3744.9335,N,12230.4150,W,2,6,1.38,11.9,M,-25.5,M,0000,0000*52
$GPGSA,A,3,23,20,07,32,16,06,,,,,,,1.64,1.38,0.88*0F
$GPRMC,020629.000,A,3744.9335,N,12230.4150,W,0.30,114.89,140114,,,D*7B
$GPVTG,114.89,T,,M,0.30,N,0.55,K,D*3E
$GPGGA,020630.000,3744.9336,N,12230.4149,W,2,6,1.38,11.9,M,-25.5,M,0000,0000*51
$GPGSA,A,3,23,20,07,32,16,06,,,,,,,1.64,1.38,0.88*0F
$GPGSV,4,1,13,23,71,010,17,16,53,093,23,20,52,183,25,13,48,312,*72
$GPGSV,4,2,13,07,30,246,17,32,24,154,17,10,19,316,,04,14,285,*7D
$GPGSV,4,3,13,06,06,111,14,03,06,135,,08,02,236,,27,02,119,*79
$GPGSV,4,4,13,37,,,*7F
$GPRMC,020630.000,A,3744.9336,N,12230.4149,W,0.28,114.89,140114,,,D*71
$GPVTG,114.89,T,,M,0.28,N,0.52,K,D*30
$GPGGA,020631.000,3744.9336,N,12230.4148,W,2,6,1.38,11.9,M,-25.5,M,0000,0000*51
$GPGSA,A,3,23,20,07,32,16,06,,,,,,,1.64,1.38,0.88*0F
$GPRMC,020631.000,A,3744.9336,N,12230.4148,W,0.33,114.89,140114,,,D*7B
$GPVTG,114.89,T,,M,0.33,N,0.62,K,D*39
$GPGGA,020632.000,3744.9336,N,12230.4147,W,2,6,1.38,11.9,M,-25.5,M,0000,0000*5D
$GPGSA,A,3,23,20,07,32,16,06,,,,,,,1.64,1.38,0.88*0F
$GPRMC,020632.000,A,3744.9336,N,12230.4147,W,0.28,114.89,140114,,,D*7D
$GPVTG,114.89,T,,M,0.28,N,0.52,K,D*30
$GPGGA,020633.000,3744.9337,N,12230.4147,W,2,6,1.38,11.9,M,-25.5,M,0000,0000*5D
$GPGSA,A,3,23,20,07,32,16,06,,,,,,,1.64,1.38,0.88*0F
$GPRMC,020633.000,A,3744.9337,N,12230.4147,W,0.29,114.89,140114,,,D*7C
$GPVTG,114.89,T,,M,0.29,N,0.54,K,D*37
$GPGGA,020634.000,3744.9337,N,12230.4146,W,2,6,1.38,11.9,M,-25.5,M,0000,0000*5B
$GPGSA,A,3,23,20,07,32,16,06,,,,,,,1.64,1.38,0.88*0F
$GPRMC,020634.000,A,3744.9337,N,12230.4146,W,0.29,114.89,140114,,,D*7A
$GPVTG,114.89,T,,M,0.29,N,0.54,K,D*37
... etc
      


Oliv did it