Ubuntu: Using a GPS Dongle
This blog explains how to connect a GPS Dongle to your laptop and how to use the position information.
For this blog, I will be using the uBlox based GPS receiver module. Though we will be discussing about a specific GPS receiver, the discussion is applicable to other GPS receivers also.
Here is a snapshot of the GPS receiver that we will be using in this discussion.
The uBlox receiver has 6 pins for connections:[table “” not found /]
Notice that uBox has a TTL based UART output. This cannot be connected directly to your laptop. You will need either of the following:
- TTL to RS232 convertor
- TTL to USB convertor
Since I am using this device on my laptop, I have selected “TTL to USB Convertor” due to the absence of RS232 ports on my laptop.
You can connect this module (GPS -> TTL -> USB) to your laptop.
Once you connect the USB device to your laptop, it will appear as a serial port, for example, /dev/ttyUSB0.
In order to test the GPS module, launch minicom or any other software that you have for reading a serial port. Notice that the GPS module works with a baud rate of 9600 bauds. Hence, launch minicom with the following options:
sudo minicom -b 9600 -o -D /dev/ttyUSB0
Note: Since we are only interested in reading the GPS receiver output, you can also use the following command:
sudo cat /dev/ttyUSB0
Once you have launched minicom, you will see some text scrolling. Wait for some time till the GPS receiver acquires a lock. Once the device has obtained a successful lock, you will see some text like this.
$GPRMC,093010.00,A,1255.23533,N,07735.22950,E,0.414,,190714,,,A*7D $GPVTG,,T,,M,0.414,N,0.766,K,A*25 $GPGGA,093010.00,1255.23533,N,07735.22950,E,1,04,5.13,887.2,M,-86.5,M,,*7A $GPGSA,A,3,26,02,05,06,,,,,,,,,7.04,5.13,4.82*0D $GPGSV,2,1,06,02,57,228,35,05,09,193,32,06,82,355,27,20,02,052,*79 $GPGSV,2,2,06,26,16,220,35,39,29,260,33*7F $GPGLL,1255.23533,N,07735.22950,E,093010.00,A,A*6F
Let us take the line starting with “$GPGLL” and understand what it means.
The GPGLL information provides the “Geographic Position, Latitude / Longitude and time”. Notice that there are 7 entries separated by commas. Consider the GPGLL in the above line, here is a description of what they mean.[table “” not found /]
You can refer to the http://aprs.gids.nl/nmea/ link for more information on the NMEA strings outputed by the GPS receiver.
GPS Plot on Map:
In order to plot the above GPS information on a map, open the http://itouchmap.com/latlong.html link. At the bottom right of the page, you will notice “Show Point from Latitude and Longitude“, as shown in the below picture.
Let us convert the latitude and longitude information that we obtained above with respect to the format expected by the site.[table “” not found /]
If you enter the above ‘D,M,S’ information on the site and click on the “Show Point” button, you should see the GPS location plotted on the Google Maps. You can zoom into the map to see the location.
Note: Based on the GPS receiver you are using, the GPS receiver will give you a data which is close to a few meters away from your exact location.