This tutorial will teach you how to connect the LS20031 GPS Receiver, to an Arduino and use some basic libraries to gather and view data from this module.
The LS20031 is a great module for beginners. It has great documentation and is used in lots of projects around the world (EZOSD to name an example). It also comes with some great, easy to use software to configure it, which you can find on the product page. It supports 66-channel GPS, and has a max update rate of 10Hz! The module runs at 3.3V and requires only four wires to get it connected using a simple USART interface.
What You Will Need:
For this tutorial you will need a LS20031 GPS Receiver, and an Arduino Pro Mini, with an FTDI Serial to USB Converter for programming (you can use both the 3.3V and 5V version in this tutorial even though the GPS is a 3.3V device, don’t worry we will show you how). You will also need a strip of right and straight angle headers, jumper wires, and a breadboard.
The tools you will need are a basic soldering iron with a good clean tip, tweezers, and a cutter to cut the headers into the correct lengths.
Step 1: Cut Headers
Above, you can see the pieces you will need to connect everything together. Most headers come in lengths of 40, so you should have plenty left over for some of your other projects!
Step 2: Assembly
Step 3: Assembly (cont.)
Step 4: Assembly (cont. 2)
Step 5: Finished GPS Module
*Also remember to switch over your FTDI board to 3.3V if you are using a 5V version, otherwise you will kill the GPS module!
You can go ahead and mount the Arduino Pro Mini and the GPS module on your breadboard. If you are not sure how breadboards work, you can checkout our previous Power Supply Tutorial explaining how breadboards work.
Step 6: GPS Configuration
Connect the FTDI to the GPS directly using the above diagram, and then follow the steps to configure your GPS to a 1 Hz update rate with GPGGA and GPRMC sentences enabled. This step is required if you want to use the TinyGPS library like we did in this tutorial. The 1Hz update rate is the only optional part, since we wanted to slow it down to ensure everything was working well.
1) Connect the FTDI to your computer and Run Realterm (http://realterm.sourceforge.net/index.html#downloads_Download) and open the port your FTDI is on.
2) Make sure you have the +CR and +LF check boxes marked.
3) To change the update rate to 1 Hz the command looks like: $PMTK220,1000*1F
Type the command into the first white box under the send tab. The 1F is the check sum you calculate using the bytes between "$" and ‘*’. Here is a handy calculator you can use to get that check sum easily!
4) Then click the "Send ASCII" button next to the white box you typed into.
5) To enable/disable sentences, you will use the PMTK314 command. This example turns off all sentences except GGA and RMC. $PMTK314,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*28 (reference first datasheet to see how it works)
Step 7: Wiring
For this tutorial we will connect all four pins, but the “RX” pin of the GPS will not be used in our program, and can be left off.
This illustration shows the 4 connections.
We will start by connecting the 3.3V pin with our red jumper wire. Connect this pin to the pin labeled “VCC” on the Pro Mini. Connect Rx -> 3 (Yellow), TX -> 2 (Blue), and GND to the GND (Black).
Step 8: Completed Wiring
Step 9: Test Code
We need to change pins 10 and 11 to pins 2 and 3 and match the default baud rate of the GPS module, to that of the software serial port. Since the default GPS is set to 57600 we doubled the hardware serial port to prevent any overflows. These changes have been made in the code above. Go ahead and program up the Pro Mini (5V/16Mhz 328P for us) and open up a terminal window to view the GPS sentences.
Step 10: Test Code (cont.)
Step 11: Parsing NEMA Strings
Once again, there are only two lines that need editing. Make sure the software serial port is opened on pins 2 and 3 "SoftwareSerial ss(2, 3)". The second change is to set the softwareserial ("ss" in this case) to the default baud rate of the GPS module. Once you have done that, upload the new code to your Arduino and open up the serial terminal.
It will take some time before the parser begins to give some valid output, so be patient. I have saved the output and shortened it using the dots to make it easier to read. You can see all the strings are neatly parsed, unlike the previous test code. Now you can use the TinyGPS functions to get the data you need for your project. For example, if you need to know your position, you would simply call the built in function gps.f_get_position(&flat, &flon, &fix_age) and pass it the variables to store latitude and longitude. For our example we got 28.112035 Lat and -80.671600 Long. Enter this in Google Search and you will get...
Step 12: You're Finished!
That concludes our getting started with a GPS tutorial. Now you are ready to build your own GPS tracker. If you have any questions about this tutorial, don't hesitate to contact us.
Thanks for reading! Click on our profile to check out more Instructables!