BLOG > Tutorial 15 for Arduino: GPS Tracking

This tutorial was featured on the Cooking-Hacks website on 07/18/2012

This was easily the most time I’ve spent producing an Arduino Tutorial.  I’ve been sporadically walking around NYC with this GPS for weeks as I’ve tweaked the code and gotten it just right.  If it wasn’t obvious from the title, this tutorial will teach you how to use an Arduino paired with a GPS Module and an SD Card Module to log your latitude and longitude over the course of a day.  As a bonus, I’ll also show you how to easily overlay this data onto a map using services like Google Earth and Google Fusion Tables (NOTE: Fusion Tables is being phased out by Google, so I recommend against using it – Edit from February 2019). I added a short “history lesson” to this episode to explain how GPS came to be; it’s the first time I’ve done that, so please let me know if you like the extra knowledge. Grab some popcorn and your Arduino, because this tutorial is pretty long – GPS is complicated! The schematics, programs, parts list, sample data, and important links are available for download below.

I used the tinyGPS library to decode the NMEA GPS Data.  Cooking-Hacks generously supplied both the GPS shield and SD Card shield that I used in this tutorial.

You can download the files associated with this episode here: Arduino Tutorial 15 Files

Source materials for all my Arduino tutorials can be found in my github repository.
GNU GPL License Distributed under the GNU General Public (Open-Source) License.
Please Attribute and Share-Alike.

This video can also be viewed at element14.com.

250 comments

  1. Greetings,

    I followed this tutorial. I want to put the datastring to be sent in a different uno board using rf433 modules
    dataString = RF_date_time + “,” + RF_lat + “,” + RF_lon;

    The algo I am following is…
    separate the lat, lon & date_time value (which is already done in that code)

    wrap it to a string
    {
    char Sensor1CharMsg[50];// The string that we are going to send trought RF
    ……………
    ………………….
    sprintf(Sensor1CharMsg, “%02d/%02d/%02d %02d:%02d:%02d, %f, %f”, RF_date_time, RF_lat, RF_lon);
    }

    print it on serial monitor to see if its working
    {
    Serial.println(Sensor1CharMsg)
    }

    send the string via RF module
    vw_send((uint8_t *)Sensor1CharMsg, strlen(Sensor1CharMsg));

    When I open the serial monitor, the code stops in the first loop showing only the ************ values of total strings (as defined by the code, full large string with all data).

    Any help in this regard shall be highly appreciated.
    Thanks a ton…

  2. Hey Jeremy, awesome job man,loved your tutorials,can i use SIM908c instead of tiny GPS in my project? tiny GPS is not available here and i want to add a GSM module too with my project.if yes can u tell me where will i find the library functions and what are they exactly??waiting for a reply and thanks again for your tutorials!!!

    1. What do you mean? tinyGPS is a download link. Is it not working? There are certainly other libraries that will allow you to accomplish this, but I haven’t tried most of them.

  3. hua, Outstanding video’s. I want to thank you for your time, and excellent video’s. I hope everyone understands the quality of your efforts, coming from an Engineer for 35+ years, working NASA, Missile guidance, RF analysis, GPS development, and WAAS programs. Keep up the great work for the “open source” cause.

  4. Hi Jeremy Thanks for you great tutorial series, I’ve found them very thorough and easy to follow.

    In the GPS tutorial I have very similar results to yours in creating the KML file and launching it in Google Earth. I’m trying to generate a fly-through but cannot get to a low enough altitude to make it work well … ideally I like to view all my point in Street Level view like a virtual reality tour.

    I can highlight individual points and view them in Street Level view on Google Earth and they look great, but when I activate a tour I return back to an altitude very much like the one in your example.

    I assume that since the GPS data we are storing only includes longitude and latitude, and not altitude, this could have something to do with the way the KML file runs in Google Earth. Should I store altitude data as well from my GPS to overcome this problem… or am I doing something else wrong in trying to generate a tour from our data?

    Thanks again! Martin

    1. Martin –

      I’m honestly not completely sure how to accomplish the tour mode in Google Earth. I think you set a waypoint path – it isn’t able to interpolate between discreet points, from what I can tell.

  5. Jeremy

    Many thanks for all your effort in making the tutorials.

    I’m trying to get your GPS sketch working

    This is the sketch beginning
    //Jeremy Blum’s Arduino Tutorial Series – Episode 15 – GPS Tracking
    //Sample Code 1 – Outputting GPS Data to the Serial Debug Terminal
    //https://www.jeremyblum.com
    //TinyGPS Library and Helper Functions by Mikal Hart http://arduiniana.org/libraries/tinygps/

    #include

    /* This sample code demonstrates the normal use of a TinyGPS object.
    It uses an Arduino Mega with a GPS attached to Serial3 at 4800 buad.
    */

    TinyGPS gps;

    static void gpsdump(TinyGPS &gps);
    static bool feedgps();
    static void print_float(float val, float invalid, int len, int prec);
    static void print_int(unsigned long val, unsigned long invalid, int len);
    static void print_d

    I get a compilation error

    “TinyGPS does not name a type”

    How do I correct this please?

    I’m using TinyGPS v13 and Arduino IDE 1.05

    Many thanks

    1. Hey Bazz,

      I had the same problem, you need to put the TinyGps library into your Arduino/Libraries directory.

      Hopefully this isn’t too late, or you’ve solved the issue already.

      Craig

  6. Hey Jeremy!

    Thx for this amazing Tutorial!

    I reconstructed your GPS Tutorial, with the same componets.
    I have one problem, if i load the sketch the first time it works fine. But if i disconnect the Serial Port for a short time and then plug in again then appears the Error message “Card Failure”. Some Times i have to load the sketch 2-3 Times to work it again.

    Do you have any idea why this happens?
    Many Thx!

  7. hi. i looked at your GPS tutorial. i tried to do the same, but when i try to compile the codes, its says ” too few arguments to function ‘void print_float(float,float,int,int,int’) ” on this function : static void print_float(float val, float invalid, int len, int prec, int SD_val); . what can i do in this case?, thans for helping.

  8. Hi men, good tutorial, i have a 3g-gps arduino shield,

    i want use a web server to traking the shield in orange trace gps, but i can’t.

    you have a idea like a doing? if yes, I thanks.

  9. ok so i have been messing around with this for a while now. I am using the Arduino yun, a GPS shield from SparkFun, and a GPS with the same NMEA code and baud rate as you. I figured that i couldnt go wrong if i just use the TinyGPS example to get it to read me my GPS location, but no matter what i do all i get is this-
    **** **** ********* ********** **** ********** ******** **** ****** ****** ***** *** ******* ****** *** 0 0 0
    -The GPS i have has power going to is and i have tried switching the RX and TX pins to 3, 2, along with the hardware solution you used in the video, but still nothing.

    I have tried other youtube videos and example codes, but in the end it just seems that the GPS and my serial just wont communicate. As much as i wish it was a wiring problem, im pretty certain it isnt, because the shield is pretty straight forward to install. any suggestions?

    PS all of your videos have been very informative! it really shortened the learning curve for me

    1. Kyle, Is it possible that your GPS unit has RS232 output rather than serial? I discovered this problem when I connected my serial GPS (Copernicus, from SparkFun), which works fine when connected to the Arduino, to another device whose input requires RS232. Turns out that the polarity of the two formats is opposite: when RS232 goes up, serial goes down, and vice versa. SparkFun sells a little board (cheap) that converts from one to the other. It is only a few dollars, so might be worth a try. Eric

      1. I looked back through the GPS manual and it indeed does output RS232. I find it silly that the GPS shield would have a specific input for my GPS but not be able to do the conversion already. Thankyou for your advice Eric! i will try that and see if i can move forward.

        1. Kyle, Good! The unit you want is SparkFun PRT-08780, called an RS232 Shifter SMD, no DB9. That last part means it does not have a DB9 socket to plug into (common on RS232 devices). They also sell one that has that socket on the board. The price was $9.95. Good luck! Eric

  10. I’m trying to use this code with ublox Lea 6h GPS module. I have changed the baud rate of Lea to 4800 matching this code. Also, I set Lea 6h to nmea output and input. I have the tx(Lea) to Rx(arduino). But I still don’t see coordinates on the serial monitor. Just stars. Do you have any recommendations for this? I am working on a project so I greatly appreciate any advice. Thank you.

  11. I resolved my problem with the gps coordinates on the serial monitor, but when I upload the “gps logger” I dont see any coordinates. This is my output:

    Testing TinyGPS library v. 13

    Sizeof(gpsobject) = 115

    Sats HDOP Latitude Longitude Fix Date Time Date Alt Course Speed Card Distance Course Card Chars Sentences Checksum
    (deg) (deg) Age Age (m) — from GPS —- —- to London —- RX RX Fail
    ————————————————————————————————————————————–
    6

    Do you have any recommendations as to what may be causing this problem?

  12. Hey Jeremy, love the video’s! I have a prolbem though. i downloaded your example files and put SoftwareSerial back in (replacing Serial3 with ss) because i am using the Uno, an SD shield, and EM 406 GPS. I tested it and it just repeatedly printed the header with only the latitude stars showing up. My final goal is to have it output time, lat, lon, and alt. but for some reason i cant get your example file to work on the Uno. is there anything else that i could be missing?

      1. Yup! that was it. I erased the header and that gave me enough to run it without losing functionality. Thanks!

  13. Hey Jeremy, I downloaded and tried using your example code after modifying it to work on an UNO. in other words i switched the CS pin to 8 and put SoftwareSerial.h back in set to pins 2,3 and replacing Serial3 with nss. I would think that would be all you really have to do, but for some reason it just gets stuck in the setup() as a loop. any reason this would happen?

  14. Hi Jeremy, first of all thanks a ton for putting your efforts in explaining this.
    But I am facing a problem while working on a project. I am using Arduino Mega 2560 and GPS A6B module.I tried your sample code but I see only symbols in serial monitor output. How can I correct this?
    Do I need to include any other library ?

    1. check all of your baud rates and make sure they match with both the GPS device and the Serial-Serial monitor

  15. Hello people,
    I’m in a but of a problem with a project in college, I had my own code wrote but this seems to be better. My only problem is I want to send sd_lon and sd_lat in a link to a user.. But when it sends it there’s two spaces before sd_lon and two spaces before sd_lon, I need to remove the spacing to make the link work!

    Can anyone help me in a way in getting rid of the spacing?

    Thanks

  16. Hi, Jeremy. In a previous video tutorials are you talking about wireless control via XBee. But unfortunately, these modules are very expensive and many can not afford to work with them. As an alternative, I would ask you to use one of the lessons in the future a simpler and cheaper module “433/315Mhz RF transmitter and receiver” it costs about $ 3, but found me how to work with them too complex and not suitable for beginners. Are you in your lessons quite affordable trays information that contributes to a more convenient assimilate information. I would also like to see the lessons to work with Wi Fi and GSM/GPRS modules.
    Best wishes from Russia.

  17. Thank you for the link. But the trouble is the other) The fact that I am from Russia and my English is not at a level that would fully understand, and what goes into this kind of blogs. So to say difficulties with translation of what that technical terms, etc. But there is a “way out”. Russia has the Informational site on which lay lessons Jeremy translated. With a very good translation. Here I decided to go to the fountainhead of information for help))

  18. Jeremy, or anyone that can assist,

    I’m using the sparkfun GS407 gps receiver with an arduino uno board. I’m getting checksum errors, apparently, so all I see are the asterisks. The GS407 defaults to 9600bps, and that is what I’m using, and if I do a serial.read(), I can see the NMEA data. I have the GS407 connected to digital pins 4 and 5 because I’m using this in conjuction with the sparkfun weather shield. The weather shield is setup for a gps unit on pins 4 and 5 with a soft serial. there’s an option to use the UART, but I’m new to this and not sure how to do that (If I set the switch for hard serial, which pins do I connect the GPS to). I’ve seen reference on here that there may be buffer overuns with the ss(), and it can be increased. Where do you increase the buffer at?

    1. I modified the program to just display the GPS data, and there is an issue, no idea what is causing it though. I did modify softserial to increase the buffer to 256.

      Here’s the program I used:
      #include
      #include
      /*
      This sample sketch demonstrates the normal use of a TinyGPS++ (TinyGPSPlus) object.
      It requires the use of SoftwareSerial, and assumes that you have a
      4800-baud serial GPS device hooked up on pins 4(rx) and 3(tx).
      */
      static const int RXPin = 5, TXPin = 4;
      static const uint32_t GPSBaud = 9600;

      // The TinyGPS++ object
      TinyGPSPlus gps;

      // The serial connection to the GPS device
      SoftwareSerial ss(RXPin, TXPin);

      void setup()
      {
      Serial.begin(9600);
      ss.begin(GPSBaud);

      Serial.println(F(“DeviceExample.ino”));
      Serial.println(F(“A simple demonstration of TinyGPS++ with an attached GPS module”));
      Serial.print(F(“Testing TinyGPS++ library v. “)); Serial.println(TinyGPSPlus::libraryVersion());
      Serial.println(F(“by Mikal Hart”));
      Serial.println();
      }

      void loop()
      {
      // This sketch displays information every time a new sentence is correctly encoded.
      char input = ss.read();

      Serial.write(input);
      }

      Here’s some of the output:
      ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ$GPRMC,180407.00,V,,,,,,,160414,,,N*71
      $GPVTG,,,,,,,,,N*30
      $GPGGA,180407.00,,,,,0,05,19.82,,,,,,0000*6B
      $GPGSA,A,1,02,12,25,14,29,,,,,,,,23.42,19.82,12.48*32
      $GPGSV,3,1,10,02,36,076,34,04,12,036,,12,49,082,35,14,29,239,30*7E
      $GPGSV,3,2,10,24,12,147,,25,82,354,19,29,55,210,32,31,30,309,*7B
      $GPGSV,3,3,10,33,29,209,,39,31,157,35*75
      $GPGLL,,,,,180407.00,V,N*40
      ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ$GPRMC,180408.00,V,,,,,,,160414,,,N*7E
      $GPVTG,,,,,,,,,N*30
      $GPGGA,180408.00,,,,,0,05,19.92,,,,,,0000*65
      $GPGSA,A,1,02,12,25,14,29,,,,,,,,23.54,19.92,12.53*3E
      $GPGSV,3,1,10,02,36,076,34,04,12,036,,12,49,082,35,14,29,239,30*7E
      $GPGSV,3,2,10,24,12,147,,25,82,354,19,29,55,210,32,31,30,309,*7B
      $GPGSV,3,3,10,33,29,209,,39,31,157,35*75
      $GPGLL,,,,,180408.00,V,N*4F
      ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ$GPRMC,180409.00,V,,,,,,,160414,,,N*7F
      $GPVTG,,,,,,,,,N*30
      $GPGGA,180409.00,,,,,0,05,20.02,,,,,,0000*67
      $GPGSA,A,1,02,12,25,14,29,,,,,,,,23.65,20.02,12.58*34
      $GPGSV,3,1,10,02,36,076,34,04,12,036,,12,49,082,35,14,29,239,30*7E
      $GPGSV,3,2,10,24,12,147,,25,82,354,18,29,55,210,31,31,30,309,*79
      $GPGSV,3,3,10,33,29,209,,39,31,157,35*75
      $GPGLL,,,,,180409.00,V,N*4E
      ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ$GPRMC,180410.00,V,,,,,,,160414,,,N*77
      $GPVTG,,,,,,,,,N*30
      $GPGGA,180410.00,,,,,0,05,20.12,,,,,,0000*6E
      $GPGSA,A,1,02,12,25,14,29,,,,,,,,23.76,20.12,12.63*3F
      $GPGSV,3,1,10,02,36,076,34,04,12,036,,12,49,082,35,14,29,239,30*7E
      $GPGSV,3,2,10,24,12,147,,25,82,354,19,29,55,210,31,31,30,309,*78
      $GPGSV,3,3,10,33,29,209,,39,31,157,35*75
      $GPGLL,,,,,180410.00,V,N*46
      ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ$GPRMC,180411.00,V,,,,,,,160414,,,N*76
      $GPVTG,,,,,,,,,N*30
      $GPGGA,180411.00,,,,,0,05,20.23,,,,,,0000*6D
      $GPGSA,A,1,02,12,25,14,29,,,,,,,,23.88,20.23,12.69*36

      Before every $GPRMC, there’s garbage.

  19. Is it possible to create such GPS tracking system but using SIM card that is sending location information to some server (or to my phone) through GPRS only with arduino and what modules have to use in this case.

  20. why i am converting array to float using atof, the float data doesn’t match with the array data before?
    0745.40557 in array but in float after using atof be 745,40560 or much deviation. and every change of gprmc float data after convertion doesn’t follow that changing of gprmc?

  21. Hi, can i use this on Arduino UNO? if no what i can use for tracking my arduino?

    my project is Weather Balloon that detect Temperature, Humidity, Altitude, ETC

    its all already working but i must know where is the arduino

    can you help me?

  22. hey Jeremy ,
    wts up ,,,,, i have arduino uno r3 and GPS/GPRS/GSM module v3 ……
    and i have problem in connecting them and programming also …
    do you have any idea about this…. if u plz .. ;)

  23. Hello I have a question about the code here I will just add comments to your actual code.

    if(SD_date_time != “invalid”) // SD_date_time does not = invalid
    digitalWrite(LED, HIGH); // turn the LED on but dont open the card and write the data?
    else // otherwise
    digitalWrite(LED, LOW); // turn the led off because SD_date_time == invalid

    //Open the Data CSV File // open the file to write invalid?
    File dataFile = SD.open(“LOG.csv”, FILE_WRITE); // SD_date_time == invalid yes? print to file?
    if (dataFile)
    {
    dataFile.println(dataString);
    Serial.println(dataString);
    dataFile.close();
    }
    else
    {
    Serial.println(“\nCouldn’t open the log file!”);
    }
    }

    If I am incorrect on this I am sorry it is late and I am fairly sick as well please excuse me ^_^

  24. Useful insights in this article, thanks for sharing it! I don’t know if you heard of http://gpx2kml.com/ , but it’s a good software program to use when you need to convert Google Earth kml format in gpx file and vice versa. Free of charge, quick results and there’s no installation required. Try it and see how it works, cheers!

  25. Hi Jeremy,

    Thank you so much for putting together such a great tutorial! However, when I was trying to test my gps with my Arduino Mega and same GPS board, I only received strange symbols.

    They look like:
    ӚÍÂÐþ(’,RÒ$’’’’’’ú’’’’’’ôXü8þœÉlB29 mB¾ðr !` Ð’JB Jòòòòòòòòú’,’’’’’’þ8þ’’’’’’ô’’’’’’ô’’’’’úÐ ê8þ’,’’’’àÐþ’’’’’úÐþ8†C–K”K’ÐÀ’’’’’’ôÐþ’,’’’’’ô’’’’’ú8þ’,’’’’Rà’,’’’’Òà’,’,’’’’’’’’úÐþ8þ’,’’’Ò’ÀXüX!ÿÐÒ ê8þ(†C–K”K’ðÀX ‚Xü(’’’’Pà(’’’’à’’’’’’ô’,’,’’’Ð(’’’’Pà(’’’’à’ÀX ÿÐþüÀXü(’’’’à8þ8’,’’RÒ!‚Ð

    Here is my code:
    #include

    /* This sample code demonstrates the normal use of a TinyGPS object.
    It requires the use of SoftwareSerial, and aSerial3umes that you have a
    4800-baud serial GPS device hooked up on pins 4(rx) and 3(tx).
    */

    TinyGPS gps;

    static void smartdelay(unsigned long ms);
    static void print_float(float val, float invalid, int len, int prec);
    static void print_int(unsigned long val, unsigned long invalid, int len);
    static void print_date(TinyGPS &gps);
    static void print_str(const char *str, int len);

    void setup()
    {
    Serial.begin(115200);

    Serial.print(“Testing TinyGPS library v. “); Serial.println(TinyGPS::library_version());
    Serial.println(“by Mikal Hart”);
    Serial.println();
    Serial.println(“Sats HDOP Latitude Longitude Fix Date Time Date Alt Course Speed Card Distance Course Card Chars Sentences Checksum”);
    Serial.println(” (deg) (deg) Age Age (m) — from GPS —- —- to London —- RX RX Fail”);
    Serial.println(“————————————————————————————————————————————-“);

    Serial3.begin(4800);
    }

    void loop()
    {
    float flat, flon;
    unsigned long age, date, time, chars = 0;
    unsigned short sentences = 0, failed = 0;
    static const double LONDON_LAT = 51.508131, LONDON_LON = -0.128002;

    print_int(gps.satellites(), TinyGPS::GPS_INVALID_SATELLITES, 5);
    print_int(gps.hdop(), TinyGPS::GPS_INVALID_HDOP, 5);
    gps.f_get_position(&flat, &flon, &age);
    print_float(flat, TinyGPS::GPS_INVALID_F_ANGLE, 10, 6);
    print_float(flon, TinyGPS::GPS_INVALID_F_ANGLE, 11, 6);
    print_int(age, TinyGPS::GPS_INVALID_AGE, 5);
    print_date(gps);
    print_float(gps.f_altitude(), TinyGPS::GPS_INVALID_F_ALTITUDE, 7, 2);
    print_float(gps.f_course(), TinyGPS::GPS_INVALID_F_ANGLE, 7, 2);
    print_float(gps.f_speed_kmph(), TinyGPS::GPS_INVALID_F_SPEED, 6, 2);
    print_str(gps.f_course() == TinyGPS::GPS_INVALID_F_ANGLE ? “*** ” : TinyGPS::cardinal(gps.f_course()), 6);
    print_int(flat == TinyGPS::GPS_INVALID_F_ANGLE ? 0xFFFFFFFF : (unsigned long)TinyGPS::distance_between(flat, flon, LONDON_LAT, LONDON_LON) / 1000, 0xFFFFFFFF, 9);
    print_float(flat == TinyGPS::GPS_INVALID_F_ANGLE ? TinyGPS::GPS_INVALID_F_ANGLE : TinyGPS::course_to(flat, flon, LONDON_LAT, LONDON_LON), TinyGPS::GPS_INVALID_F_ANGLE, 7, 2);
    print_str(flat == TinyGPS::GPS_INVALID_F_ANGLE ? “*** ” : TinyGPS::cardinal(TinyGPS::course_to(flat, flon, LONDON_LAT, LONDON_LON)), 6);

    gps.stats(&chars, &sentences, &failed);
    print_int(chars, 0xFFFFFFFF, 6);
    print_int(sentences, 0xFFFFFFFF, 10);
    print_int(failed, 0xFFFFFFFF, 9);
    Serial.println();

    smartdelay(1000);
    }

    static void smartdelay(unsigned long ms)
    {
    unsigned long start = millis();
    do
    {
    while (Serial3.available())
    gps.encode(Serial3.read());
    } while (millis() – start 1)
    Serial.print(‘*’);
    Serial.print(‘ ‘);
    }
    else
    {
    Serial.print(val, prec);
    int vi = abs((int)val);
    int flen = prec + (val = 1000 ? 4 : vi >= 100 ? 3 : vi >= 10 ? 2 : 1;
    for (int i=flen; i<len; ++i)
    Serial.print(' ');
    }
    smartdelay(0);
    }

    static void print_int(unsigned long val, unsigned long invalid, int len)
    {
    char sz[32];
    if (val == invalid)
    strcpy(sz, "*******");
    else
    sprintf(sz, "%ld", val);
    sz[len] = 0;
    for (int i=strlen(sz); i 0)
    sz[len-1] = ‘ ‘;
    Serial.print(sz);
    smartdelay(0);
    }

    static void print_date(TinyGPS &gps)
    {
    int year;
    byte month, day, hour, minute, second, hundredths;
    unsigned long age;
    gps.crack_datetime(&year, &month, &day, &hour, &minute, &second, &hundredths, &age);
    if (age == TinyGPS::GPS_INVALID_AGE)
    Serial.print(“********** ******** “);
    else
    {
    char sz[32];
    sprintf(sz, “%02d/%02d/%02d %02d:%02d:%02d “,
    month, day, year, hour, minute, second);
    Serial.print(sz);
    }
    print_int(age, TinyGPS::GPS_INVALID_AGE, 5);
    smartdelay(0);
    }

    static void print_str(const char *str, int len)
    {
    int slen = strlen(str);
    for (int i=0; i<len; ++i)
    Serial.print(i<slen ? str[i] : ' ');
    smartdelay(0);
    }

    I'm basically doing the exact same thing as you did in the tutorial and I'm not sure why my GPS isn't working. Can you help me with that? Thanks a lot!

  26. I’m trying to find a longer Antenna for Cooking Hacks’ GPS module. Does anyone know how to find one that is compatible with this GPS? Thanks a lot!

  27. Hai jeremy :)

    i found your website from youtube currently im in the final year and my project is about tracking the car accident by using ARDUINO. do you mind to help me, which GPS that works best with my project ?
    thank you and greetings from malaysia :)

  28. GPS Receiver – Microsoft Pharos GPS-500 GPS Receiver. I have no usb cable anymore but I know it works. Is there a way to wire it backup to the receiver it has flat pins just inside my device. It had a rather weak plug from a usb to a serial converter board that plug into the gps flat pins. Can You help.

  29. hi,
    We are working on this project for college. It is called the smart cane which automatically detects obstacles in users way and lets them know with the help of some haptic feedback. I want to integrate the sensors in a smart phone with our arduino mega. I know we can use bluetooth to integrate but i am just wandering it will be possible for me to use google maps output as its giving directions and manipulate that output so i can get back to the user and give some feedback depending on the what the google maps is outputting. For example, if google maps outputting turn left, i turn the left motor on the cane’s head to let the user know to make a left turn. Would this possible? So far we have done everything but not sure if this is possible or not since no one has tried this and i am not sure if we are able to manipulate the google maps api to send that data to a text file in the phone and then forward it to the arduino so we can make decisions.

  30. can any one write a code for
    Write code that receives the gps string using serial rx2.ino as a starting point. Once an entire string has been received, use strtok to parse the fields and print out each field.

  31. Hi Jeremy Blum! :)
    Your code works fine.
    Now I want to combine SIM900 and GPS to track vehicles location. What I want to do is:
    First, you send a code like “#loc” and the GSM sends you back correct coordinates, date/time and velocity for tracking purposes. And if you send a wrong code to the GSM, it will text you back something like “syntax error”. I’ve been sitting in front of my PC for the whole week and it couldnt make it work

  32. In case anyone on this blog is interested in realtime GPS using google earth.
    i found that you can dump NMEA data ( direct output from one of these GPS chips, crocomm, etc) to google earth GPS realtime and have it plot your location in realtime.
    The google earth realtime dialog is accessed by: Tools -> GPS -> realtime tab, check box for automatically following path.
    The connection requires a virtual com port over usb. This is what arduino ide uses. It can also be obtained by using an ftdi adaptor and other ways. i found that you can use the arduino com connection.
    Important details: (1) google earth required that the nmea data have cr/lf, (2) 4800 baud output from arduino to google earth conn, ie.. Serial.begin(4800); (3) if you do not have internet access be sure to cache the area where you will be doing the realtime, this is simply done by going there in google earth while you have internet access. By default it caches 500M on your harddrive. ( an example would be driving somewhere w/o high speed internet connection while doing realtime access) in this case google earth first checks it’s cache.
    This opens up interesting aspects of using gps and long range wifi to track something.
    Obviously there are many problems with gps signal reflection in urban areas and wifi range (only optimal on line of sight), but still an interesting project.

  33. Hello, thanks for the tutorial, but if you were writing would be better to translate by google translator, but video translation of the subtitles is horrible.

    Pena, but thanks anyway.

    Eduardo from Brazil

  34. This is one of best tutorial I ever seen on the internet. I searching for this from a very long time but I found nothing useful. But now thanks to you I found what I want. Now I can use Arduino paired with a GPS module. All thanks to your tutorial.

  35. Hi Jeremy, your tutorial was very helpful. I want to directly use the gps data output and plot it in google earth real-time rather than logging it in the SD card and making the path later.Can you help me with this?

  36. -> you’re awesome

    -> Thanks for your tutorial, i now have an idea about my thesis. It is a combination of c#.net and php. It tries to get the latitude and longitude as well as the speed of an object. I have a couple of questions in mind and I would be very grateful if you answer it.

    -> Questions
    1. Could i integrate the tiny gps into visual studio such that i could use its methods, If yes how?
    2. I use this gps device http://www.rapidsignalph.com/shop/gps-shield/ , could you give a diagram of how to connect this device to arduino

    Thanks,
    admin anachron

  37. Hi

    Thanks for great tutorial.
    May be my query is directly not related to your tutorial but it’s related to GPS only.
    I have connected GPS to serial port and GSM (Telit ) with Arduino board.

    I am sending GPS data to PHP server in every 20 seconds but it was not working as expected and the reason was the MCU buffer overflow(SRAM) overflow and whole program was restarted. So what i did is open the GPS serial port for 2 seconds and read the data and close it and then send data to PHP server and it works.

    But now the problem is instead of sending data in every 20 seconds it send 2 data in 40 seconds and some time 3 data after 60 seconds.

    Have you ever got this issue??
    Can you help me to find where could be the issue.

    Thanks a lot for your help!
    ~Som

  38. Hi, Jeremy! Thanks for tutorials! They are very useful for me. I want to add 2 changes to your code and scheme to:
    1. use maximum available position update rate of the GPS module (increase it from default 1 Hz);
    2. log the position data not everytime but by pressing the button (avoid bounce).
    Can you help me with this?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Advertisement