I bought a cheap USB GPS mouse and want to read the location information using a Raspberry Pi. The raw (serial) data from the GPS mouse looks like this:
$GPRMC,130312.00,A,4751.29758,N,01208.72343,E,0.067,,140721,,,A*7E
$GPVTG,,T,,M,0.067,N,0.125,K,A*24
$GPGGA,130312.00,4751.29758,N,01208.72343,E,1,08,1.46,450.1,M,45.7,M,,*5F
$GPGSA,A,3,08,21,27,32,22,01,10,03,,,,,2.79,1.46,2.37*07
$GPGSV,3,1,10,01,41,288,36,03,17,228,21,08,66,190,24,1
0,31,054,08*7B
$GPGSV,3,2,10,14,17,316,13,21,66,300,37,22,41,231,29,24,00,026,*74
$GPGSV,3,3,10,27,38,157,17,32,41,096,27*7D
$GPGLL,4751.29758,N,01208.72343,E,130312.00,A,A*67
It uses the NMEA protocol, which is documented here: https://www.ifm.com/download/files/nmea_protocol_cr3102/$file/nmea_protocol_cr3102.pdf
So for example after $GPLL in the last line there is the latitude and the longitude in degrees, minutes and seconds. So from this data we can read:
lat: 47°51'29.758''
lon: 12°08'7.2343''
These values can easily be converted to decimal degrees by adding the minutes divided by 60 to the degrees and adding the seconds divided by 60*60 to that result. So the decimal coordinates are:
lat: 47.8582661111°
lon: 12.1353428611°
There is a well known package for linux called GPSD. Is has some demo programs to display the data visually. If I run CGPS -s
in a terminal window I get the following data:
lat: 47.85485133°
lon: 12.14536133°
The problem is that both the results differ a lot and tests have shown that the data from CGPS -s
is more accurate. But how is that possible? I am reading the raw data and having worse results than a package which can also only read the raw data. Neither of the results is very accurate, but the data from CGPS -s
is way more accurate.
Does someone know why that is and how I can fix it? Thank you!
You are interpreting the NMEA data incorrectly. NMEA uses degrees plus decimal minutes, not degrees/minutes/seconds. When you see
$GPGGA,130312.00,4751.29758,N,01208.72343,E
that's actually 47 degrees, 51.29758 minutes north latitude and 12 degrees, 8.72343 minutes east longitude. Converted to decimal degrees it's 47.854959,12.145390, more or less as cgps
said.