Introduction: Getting Started With the LS20031 GPS Receiver
GPS is an amazing thing. We use it in our day to day lives, and never give it much thought. It can help you get to your 8 o’clock in the morning meeting, or guide your robot to the finish line at a competition. In the past few years, GPS technology has become very simple, and affordable enough to be built into all our smart phones. Lots of modules have also become available for hobbyists to add GPS to their projects!
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
The first thing we are going to do, is cut all the headers to the different sizes we will need. We will need a 1 x 6 pin right angle, 1 x 5 pin right angle, 2 x 12 pin straight, and one right angle female header, which should come with your Serial to USB converter.
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
It's time to connect some headers to our GPS module. This one looks harder than the other two, but don’t worry, it’s a cinch. Start by cleaning your tip and applying some solder to the first pad (of your choice).
Step 3: Assembly (cont.)
Next, grab your favorite pair of tweezers and connect the header to the module, while applying some heat to the already soldered pad. Hold the header steady while the solder cools, and in a few seconds you can let the header go. It’s that simple!
Step 4: Assembly (cont. 2)
Next, go ahead and solder the 4 remaining pins to the module.
Step 5: Finished GPS Module
And voila! The finished GPS module should look something like this. You will also need to assemble the Pro Mini and the FTDI board if you don't have them assembled. We have written a separate how to guide for both of them (Pro Mini Assembly Guide and FTDI USB to Serial Converter Guide).
*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
Before we connect the GPS module to the Arduino, we will need to configure the GPS module to a slower update rate for this tutorial, and turn off any unused data from the module.
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
Now you are ready to connect the GPS Module to the Arduino and begin coding! Unlike the previous diagram, there are only three connections you need to make between the Arduino, and the GPS module (unless you want to send commands to the GPS module from the Pro Mini).
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
Your completed wiring should look something like our picture above. Time for some programming! We are going to begin by testing our setup and get some data from our module. Our test code will use a software serial port to gather data from the GPS module, and stream it to the computer over the FTDI.
Step 9: Test Code
To do this, we will start with a software serial example and edit it. Open up a new Arduino Sketch, and go to File>Example>SoftwareSerial>SoftwareSerialExample. This example will open up two serial ports. The first will be the hardware serial port connected to the computer with the FTDI, and the second will be the software serial port called mySerial on pins 10 and 11.
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.)
Above you can see a snapshot of my Arduino Serial Terminal. If this is the first time you have turned on your GPS module in your area, it will take some time for the GPS to get a fix on your location. In the snap shot you can see the GPS strings that we have enabled transition from the unlock state to the lock state. Once locked, all the fields are populated instead of being empty ("$GPGGA,,,,,"). Once the GPS has locked, the little red LED on the GPS module will start to flash. You now have valid data, and are ready to begin parsing!
Step 11: Parsing NEMA Strings
If you are code savvy, you can start writing up some code to start parsing these NEMA strings, and get the data you need out of them. On the other hand, if you are just getting started and don't want to write a GPS parser, there is another solution! Mikal Hart over at Arduiniana has already written a compact Arduino GPS/NMEA parser for everyone to use. You can download the library here. Once you have downloaded the library and installed the TinyGps library, open up the "test_with_gps_device" example.
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!
401 N. Wickham Melbourne FL which is our address here at our office!
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!
We have a be nice policy.
Please be positive and constructive.