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. Hey I have some doubts.

    1) Is it possible to transmit the GPS data wirelessly to a remote terminal?
    like if GPS is attached to a vehicle, then can you get data from that GPS module wirelessly at your PC terminal?

    2) Can this wireless GPS data transmission be done without using any Internet or GPRS or GSM device, like simply using an RF module?

    Please do reply.
    And thanx for your help and this wonderful tutorial.

  2. Hi Jeremy!

    Thanks for all your awesome tutorials!

    My GPS doesn’t seem to get a fix.

    I have gotten a GPS, not the same as in your tutorial though. I am using it with Arduino Uno and set up the example sketch like you said for the uno. The gps pins are connected correctly to DP 3 and 4, aren’t swapped around, since the numbers in serial output count up only when connected properly (as I gather rightly?).

    I am at the stage where the test sketch is outputting invalid data marked as stars and let the GPS sit in my open back garden to get a fix. After about 10 minutes, still no fix.

    Since it’s not the tiny gps, does it matter at which speed (4800) it communicates with the arduino? What other effects could cause a different gps than tiny gps not get a fix?

    And as well I have the question of transmitting the gps signal wirelessly. Can I simply use an analog transmitter and receiver on the other end which outputs the received signal into an arduino port? Or does the signal somehow have to be en- and decoded specifically for this?

    I am trying to send down GPS Data from a first person view RC plane, which sends down analog video and audio signal. GPS would be sent over audio channel.

    Thank you for your answer in advance. Great to have guys like you on the www.

    Greetings from Germany,

    -Phil

  3. Hi,
    Can you please explain why the debounce function is actually needed when interfacing a tactile switch with arduino?

  4. Hi Jeremy,

    When I load your code in the 1.01 Arduino IDE I get the error “Serial3 was not declared in this scope” could you shed any light on this?

  5. Jeremy,

    I noticed that the lattitude and longitude data logged from the tutorial records to 5 decimal places. Usually when data strings are shown for NMEA data, they only go to 4 decimal places. Is the 5th decimal place a valid output, or is it a number that just got attached to the string lat/lon strings?

    great tutorials!

  6. Hi Jeremy,
    Thank you for all the work you’ve put into these great tutorials. I have a question regarding the fix confirmation LED portion of your GPS data logger from Tutorial 15. I’m working on a project where I would like to confirm when a fix is achieved after a button has been pressed by lighting up an LED. Using your example code from Tutorial 15 I get false fix data which provide a date other than “invalid” so the program assumes a fix has been achieved. The GPS module I’m using (EM-406) doesn’t seem to be fooled by this erroneous data and doesn’t start flashing its fix led until much later. Is there a way to better assure a fix has been achieved via the program?

  7. Hello Jeremy. I have been watching your videos and I love them. They are awesome. I remember sometime early this year or last year you mentioned that you are going to make a tracking tutorial of GSM/GPS (i.e. sending sms commands to the tracker to send back coordinates, geocoding, etc). When are you going to fulfill this promise :)?

      1. was this posted already? I would also like to poll GPS location using gsm, and then my gsm will text me back location when a correct code is received

  8. Hi jeremy,

    I have been playing around in your code a bit, and have made some ajustments so it can log what i like.

    now am i trying to check the code to run on my arduino uno r3 and i get the message ” ‘class TinyGPS’ has no member named ‘satellites’ ” This while the code is the same as in your video.

    i am using the latest arduino software 1.0.1 from the ardino website.

    here is the code:

    #include
    #include
    #include
    #include

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

    TinyGPS gps;
    static char dtostrfbuffer[30];
    SoftwareSerial nss(2, 3);
    int CS = 53;
    int LED = 13;

    //Define String
    String SD_date_time = “invalid”;
    String SD_lat = “invalid”;
    String SD_lon = “invalid”;
    String SD_speed_kmph = “invalid”;
    String SD_course = “invalid”;
    String SD_alt = “invalid”;
    String dataString =””;

    static void gpsdump(TinyGPS &gps);
    static bool feedgps();
    static void print_float(float val, float invalid, int len, int prec, int SD_val);
    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()
    {
    pinMode(CS, OUTPUT); //Chip Select Pin for the SD Card
    pinMode(LED, OUTPUT); //LED Indicator

    Serial.begin(115200);
    nss.begin(4800);

    //Connect to the SD Card
    if(!SD.begin(CS))
    {
    Serial.println(“Card Failure”);
    return;
    }
    Serial.print(“Testing TinyGPS library v. “); Serial.println(TinyGPS::library_version());
    Serial.println(“by Mikal Hart”);
    Serial.println();
    Serial.print(“Sizeof(gpsobject) = “); Serial.println(sizeof(TinyGPS));
    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(“————————————————————————————————————————————–“);
    }

    void loop()
    {
    bool newdata = false;
    unsigned long start = millis();

    // Every 5 seconds we print an update
    while (millis() – start < 1000)
    {
    if (feedgps())
    newdata = true;
    }
    gpsdump(gps);

    //Write the newest information to the SD Card
    dataString = SD_date_time + "," + SD_lat + "," + SD_lon + "," + SD_alt + "," + SD_course + "," + SD_speed_kmph;
    if(SD_date_time != "invalid")
    digitalWrite(LED, HIGH);
    else
    digitalWrite(LED, LOW);

    //Open the Data CSV File
    File dataFile = SD.open("LOG.csv", FILE_WRITE);
    if (dataFile)
    {
    dataFile.println(dataString);
    Serial.println(dataString);
    dataFile.close();
    }
    else
    {
    Serial.println("\nCouldn't open the log file!");
    }
    }

    static void gpsdump(TinyGPS &gps)
    {
    float flat, flon;
    unsigned long age, date, time, chars = 0;
    unsigned short sentences = 0, failed = 0;
    static const float 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, 9, 5, 1); //LATITUDE
    print_float(flon, TinyGPS::GPS_INVALID_F_ANGLE, 10, 5, 2); //LONGITUDE
    print_int(age, TinyGPS::GPS_INVALID_AGE, 5);

    print_date(gps); //DATE AND TIME

    print_float(gps.f_altitude(), TinyGPS::GPS_INVALID_F_ALTITUDE, 8, 2, 0);
    print_float(gps.f_course(), TinyGPS::GPS_INVALID_F_ANGLE, 7, 2, 0);
    print_float(gps.f_speed_kmph(), TinyGPS::GPS_INVALID_F_SPEED, 6, 2, 0);
    print_str(gps.f_course() == TinyGPS::GPS_INVALID_F_ANGLE ? "*** " : TinyGPS::cardinal(gps.f_course()), 6);
    print_int(flat == TinyGPS::GPS_INVALID_F_ANGLE ? 0UL : (unsigned long)TinyGPS::distance_between(flat, flon, LONDON_LAT, LONDON_LON) / 1000, 0xFFFFFFFF, 9);
    print_float(flat == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : TinyGPS::course_to(flat, flon, 51.508131, -0.128002), TinyGPS::GPS_INVALID_F_ANGLE, 7, 2, 0);
    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();
    }

    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);
    feedgps();
    }

    static void print_float(float val, float invalid, int len, int prec, int SD_val)
    {
    char sz[32];
    if (val == invalid)
    {
    strcpy(sz, “*******”);
    sz[len] = 0;
    if (len > 0)
    sz[len-1] = ‘ ‘;
    for (int i=7; i<len; ++i)
    sz[i] = ' ';
    Serial.print(sz);
    if(SD_val == 1) SD_lat = sz;
    else if(SD_val == 2) SD_lon = sz;
    }
    else
    {
    Serial.print(val, prec);
    if (SD_val == 1) SD_lat = dtostrf(val,10,5,dtostrfbuffer);
    else if (SD_val == 2) SD_lon = dtostrf(val,10,5,dtostrfbuffer);
    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(" ");
    }
    feedgps();
    }

    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("******* ******* ");
    SD_date_time = "invalid";
    }
    else
    {
    char sz[32];
    sprintf(sz, "%02d/%02d/%02d %02d:%02d:%02d ",
    month, day, year, hour, minute, second);
    Serial.print(sz);
    SD_date_time = sz;
    }
    print_int(age, TinyGPS::GPS_INVALID_AGE, 5);
    feedgps();
    }

    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] : ' ');
    feedgps();
    }

    static bool feedgps()
    {
    while (nss.available())
    {
    if (gps.encode(nss.read()))
    return true;
    }
    return false;
    }

    i am kind of lost, can you help?

    thanx

    Peter Groenink

      1. Hi jeremy, thanx for the reply,

        that the segments are empty is a copy paste error, the mistake i made was that by accident i installed tinygps 11 instead of 12, my mistake,

        GPS_debug now works fine on my arduino with softwareserial and a ttl type gps recever.

        all i am now weighting for is a combined gps / SD shield i orderd via ebay.

          1. I am having this same problem. i cant seem to fix it. If you figure it out could you please post back?

  9. Hey, great video and it helped me ALOT.

    Anyways, would you mind add in speed and direction heading if possible?

    And one more thing, is there any chance you are gonna do a video of menu in LCD display?

    Hope to get a reply soon :)

  10. hello iam using eb 365 gps shield..i would like to obtain gps coordinates, speed and altitude then send them via sms..might you know a gsm module that would be more suitable for stacking with the gps shield?

  11. I have been using ur tutorials to generate ideas for my projects. Very clear explanation, no confusion, to the point and detailed information. Keep it up brother.

  12. Hi Jeremy I am trying to program an Arduino BT, and I already checked that I choosed the right communication port, pair the bluetooth, but it keep saying the there is a mistake.

    avrdude: stk500_getsync(): not in sync: resp=0x00

    I don’t know which is the mistake if you can help me would be great. Thanks for your tutorial they are awesome!

  13. hello. Arduino is something new to me but I’m learning fast, anyway I’m working on this project that involves logging values from a sensor and later using a gprs shield to send a current value to a server. so far I’ve been able to capture the values and log them to the sd and also display the values on a lcd. the problem is sending the values to the server via http. i would appreciate any guidance with regards to the code a tutorial would also help a lot.
    thanks

  14. This great, so much to learn and you are perfect at applying the teaching at a great level…

    Any sign on the GSM/GPS tracker.. be nice to have SD card logging :)

    Don’t mean to be pushy.

    Thanks

  15. Dear Jeremy,
    I am a beginer and I would like to build a GPS/GSM Module similar to yours.
    First all thank and congratulation to the long video.
    I would like to know you if could answer to some question which will help me a lot to build my project.
    First, do you know an excellent and responsive GPS forum?
    Second, I bouhgt 3 elements but there a bit too big. For know it’s fine because I am working on prototyp, but would you know similar elements, the smallest possible?
    My elements are : Anduino R3: https://www.sparkfun.com/products/11021? ($30), Cellular Shield with SM5100B ($99),
    GPS Receiver : https://www.sparkfun.com/products/465? ($60), GPS Shield https://www.sparkfun.com/products/10102? ($16)

    I have a doubt about connecting all together , specialy the GPS with the GPS Shield. I suppose that the GSM Shield and the Druino
    can be weld in parallel as long as I weld all pin together (Rx, Tx, 2,3,4 etc)? But I am doubting about the connection of the
    GPS and GPS Shield?
    By the by, can I weld the GPS antena directly to the Adruino, without the GPS Shield (This to win space?)

    I would really appreciate, if you can lead me in the right direction and you can recommand me smaller elements.
    By the way I wish you an happy new year from Switzerland

  16. Jeremy,

    Your work is amazing, and thank you for sharing it open source.

    Thank you, also, for bringing clarity and some very practical solutions via these tutorials, which are light years ahead of the rest. These showcase your true professionalism and demonstrate what a masterful educator you truly are!

    Dude, you’re a Rock Star Engineer, Lecturer and Educator!

  17. Jeremy,

    I’m pretty sure I have the board wiring and code correct but I keep getting an “programmer out of sync” error. In hunting about it seems that memory may be a problem when getting this close to the limit. Here is my sketch size:

    Binary sketch size: 29,590 bytes (of a 32,256 byte maximum). Apparently the Arduino can think it has insufficient space and this causes the following:

    avrdude: stk500_paged_write(): (a) protocol error, expect=0x14, resp=0x64
    avrdude: stk500_cmd(): programmer is out of sync

    I haven’t seen this in the forums – has this come up before? My coding is not sophisticated enough to know how to go back an reduce the sketch size. I tried with Arduino 1.0.1 on one machine, Arduino 1.0.2 on another with the updated TinyGPS library installed – didn’t make any difference.

  18. Dear Jimmy,
    I would like to know if you can provide me some advise because I have difficulties to perfect my code with Arduino.
    Even if my project go ahead, I block to understanf how to collect data from incoming_char = cell.read();.

    My goal is the following. I would like to have something like a listner. cell.read must be periodicaly check in case of the network is lost or if the SIM card is removed.

    For now I have to following code, but I have difficulties to understand how
    +SIND: 1
    +SIND: 2
    etc is stored in at_buffer.

    [CODE]
    static void readATString(boolean watchTimeout = false) {

    char buffidx = 0;
    int time = millis();

    //while (strstr(at_buffer, “+SIND: 4”) == 0 && strstr(at_buffer, “+SIND: 10,\”SM\”,1,\”FD\”,1,\”LD\”,1,\”MC\”,1,\”RC\”,1,\”ME\”,1″) == 0) {
    while (1) {
    int newTime = millis();

    /*if (watchTimeout) {
    // Time out if we never receive a response
    if (newTime – time > 30000) error(ERROR_GSM_FAIL);
    }
    */

    if (cell.available() > 0) {
    incoming_char = cell.read();
    if (incoming_char == -1) {
    at_buffer[buffidx] = ”;
    Serial.print(“————————–1”);
    return;
    }

    if (incoming_char == ‘\n’) {
    Serial.println(“continue”);
    continue;
    }

    if ((buffidx == BUFFSIZE – 1) || incoming_char == ‘\r’) {
    at_buffer[buffidx] = ”;
    Serial.println(“return”);
    return;
    }

    at_buffer[buffidx++] = incoming_char;

    }else{

    }
    }
    }
    [/CODE]

    May I ask you to suggest me a code to listner cell.read()?

    For exemple, when it return me this
    while (strstr(at_buffer, “+SIND: 4”) == 0 && strstr(at_buffer, “+SIND: 10,\”SM\”,1,\”FD\”,1,\”LD\”,1,\”MC\”,1,\”RC\”,1,\”ME\”,1″) == 0) {

    the code whould not continue tracking GPS. It should wait until the GSM is ready.

    But when it’s ready and the SIM card is remove, ot the network is lost, or GPS is lost, I should get an error message and when all of those services are back to ready, my module track position, and so on.

    Then if you can provide me advise avout collecting data from cell. read() it would be very nive from you.

    Cheers

  19. i am trying to create a Arduino project with low sensor, the idea is to trigger a animation using the blow sensor or other sensors of same sort, i am kind of lost at th e moment how to execuite it , can u pl help me with some suggestions.

  20. Hello,

    Im Rowell from Philippines…
    Im newbies for arduino uno…

    Do you have an idea on how to combine the below code for GSM AND GPS… This code is taken from the internet… Im using right now the GSM-GPRS-GPS Arduino Shield made by Futura Elettronica..

    ——————–>>>>>>>>>>> this is the code for GSM:

    #include “SIM900.h”
    #include
    //If not used, is better to exclude the HTTP library,
    //for RAM saving.
    //If your sketch reboots itself proprably you have finished,
    //your memory available.
    //#include “inetGSM.h”

    //If you want to use the Arduino functions to manage SMS, uncomment the lines below.
    #include “sms.h”
    SMSGSM sms;

    //To change pins for Software Serial, use the two lines in GSM.cpp.

    //GSM Shield for Arduino
    //www.open-electronics.org
    //this code is based on the example of Arduino Labs.

    //Simple sketch to send and receive SMS.

    int numdata;
    boolean started=false;
    char smsbuffer[160];
    char n[20];

    void setup()
    {
    //Serial connection.
    Serial.begin(9600);
    Serial.println(“GSM Shield testing.”);
    //Start configuration of shield with baudrate.
    //For http uses is raccomanded to use 4800 or slower.
    if (gsm.begin(2400)){
    Serial.println(“\nstatus=READY”);
    started=true;
    }
    else Serial.println(“\nstatus=IDLE”);

    if(started){
    //Enable this two lines if you want to send an SMS.
    if (sms.SendSMS(“09072470173”, “Perfect”))
    Serial.println(“\nSMS sent OK”);
    }

    };

    void loop()
    {
    if(started){
    //Read if there are messages on SIM card and print them.
    if(gsm.readSMS(smsbuffer, 160, n, 20))
    {
    Serial.println(n);
    Serial.println(smsbuffer);
    }
    delay(1000);
    }
    };

    ——————–>>>>>>>>>> and this is the code for the GPS:

    #include “SIM900.h”
    #include
    //#include “inetGSM.h”
    //#include “sms.h”
    //#include “call.h”
    #include “gps.h”

    //To change pins for Software Serial, use the two lines in GSM.cpp.

    //GSM Shield for Arduino
    //www.open-electronics.org
    //this code is based on the example of Arduino Labs.

    //Simple sketch to start a connection as client.

    //InetGSM inet;
    //CallGSM call;
    //SMSGSM sms;
    GPSGSM gps;

    char lon[15];
    char lat[15];
    char alt[15];
    char time[20];
    char vel[15];
    char msg1[5];
    char msg2[5];

    char stat;
    char inSerial[20];
    int i=0;
    boolean started=false;

    void setup()
    {
    //Serial connection.
    Serial.begin(9600);
    Serial.println(“GSM Shield testing.”);
    //Start configuration of shield with baudrate.
    //For http uses is raccomanded to use 4800 or slower.
    if (gsm.begin(2400)){
    Serial.println(“\nstatus=READY”);
    gsm.forceON(); //To ensure that SIM908 is not only in charge mode
    started=true;
    }
    else Serial.println(“\nstatus=IDLE”);

    if(started){
    //GPS attach
    if (gps.attachGPS())
    Serial.println(“status=GPSREADY”);
    else Serial.println(“status=ERROR”);

    delay(20000); //Time for fixing
    stat=gps.getStat();
    if(stat==1)
    Serial.println(“NOT FIXED”);
    else if(stat==0)
    Serial.println(“GPS OFF”);
    else if(stat==2)
    Serial.println(“2D FIXED”);
    else if(stat==3)
    Serial.println(“3D FIXED”);
    delay(5000);
    //Get data from GPS
    gps.getPar(lon,lat,alt,time,vel);
    Serial.println(lon);
    Serial.println(lat);
    Serial.println(alt);
    Serial.println(time);
    Serial.println(vel);
    }
    };

    void loop()
    {
    //Read for new byte on serial hardware,
    //and write them on NewSoftSerial.
    serialhwread();
    //Read for new byte on NewSoftSerial.
    serialswread();
    };

    void serialhwread(){
    i=0;
    if (Serial.available() > 0){
    while (Serial.available() > 0) {
    inSerial[i]=(Serial.read());
    delay(10);
    i++;
    }

    inSerial[i]=”;
    if(!strcmp(inSerial,”/END”)){
    Serial.println(“_”);
    inSerial[0]=0x1a;
    inSerial[1]=”;
    gsm.SimpleWriteln(inSerial);
    }
    //Send a saved AT command using serial port.
    if(!strcmp(inSerial,”TEST”)){
    // Serial.println(“BATTERY TEST 1”);
    // gps.getBattInf(msg1,msg2);
    // Serial.println(msg1);
    // Serial.println(msg2);
    // Serial.println(“BATTERY TEST 2”);
    // gps.getBattTVol(msg1);
    // Serial.println(msg1);
    stat=gps.getStat();
    if(stat==1)
    Serial.println(“NOT FIXED”);
    else if(stat==0)
    Serial.println(“GPS OFF”);
    else if(stat==2)
    Serial.println(“2D FIXED”);
    else if(stat==3)
    Serial.println(“3D FIXED”);
    }
    //Read last message saved.
    if(!strcmp(inSerial,”MSG”)){
    Serial.println(msg1);
    }
    else{
    Serial.println(inSerial);
    gsm.SimpleWriteln(inSerial);
    }
    inSerial[0]=”;
    }
    }

    void serialswread(){
    gsm.SimpleRead();
    }

  21. Hi Jeremy,
    What I could make out is we are syoring the data on SD card and displaying.
    Is there any way we can plot LIVE data on to the google earth?
    Need your help
    Thanx in anticipation
    Hemant

  22. Can you give a rough estimate as to how long the battery would last on one of these if you were travelling to somewhere without regular access to a plug?

      1. ormally our GPS for eg. EM406A consumes 80-90 mA of current from Arduino.So we can add it to current requirement of arduino.then is based on what AH batter we are using. Correct me if I am wrong

  23. Hey Jeremy,

    I really like your tutorial so i tried it and the SD card doesn’t interface with the the arduino. It gave error message like “Card failure… couldn’t open the log file” Any suggestion. Thanks.

  24. hi can you tell me how to connect to the satallite this arduino thing??? i dont get that part,,, its really awasom.. is there free satalite gps tracking facilities available??
    [email protected]

  25. Hi, I followed all of your tutorials, they awesome. But I try your last tutorials with gps. I used
    “Skylab GPS Module MT3329 SKM53 with Embedded GPS Antenna Arduino Compatible ge ” as gps device that is I ordered from e-bay and Arduino Uno. But it doesn’t respond. I checked every connection and code. But always serial monitor shows stars. If I crossed the RX and TX only using code then respond as shown in your video tutorial. But doesn’t show any data when I’m in the outside also.
    Plz Help me. Thank you

  26. I crossed RX and TX as follows
    ——————————————————————————————–

    #include

    #include

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

    TinyGPS gps;
    SoftwareSerial nss(1, 0);
    //SoftwareSerial nss(0, 1);//According to arduino sample code

    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_date(TinyGPS &gps);
    static void print_str(const char *str, int len);

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

    Serial.print(“Testing TinyGPS library v. “); Serial.println(TinyGPS::library_version());
    Serial.println(“by Mikal Hart”);
    Serial.println();
    Serial.print(“Sizeof(gpsobject) = “); Serial.println(sizeof(TinyGPS));
    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(“————————————————————————————————————————————–“);
    }

    void loop()
    {
    bool newdata = false;
    unsigned long start = millis();

    // Every second we print an update
    while (millis() – start < 1000)
    {
    if (feedgps())
    newdata = true;
    }

    gpsdump(gps);
    }

    static void gpsdump(TinyGPS &gps)
    {
    float flat, flon;
    unsigned long age, date, time, chars = 0;
    unsigned short sentences = 0, failed = 0;
    static const float 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, 9, 5);
    print_float(flon, TinyGPS::GPS_INVALID_F_ANGLE, 10, 5);
    print_int(age, TinyGPS::GPS_INVALID_AGE, 5);

    print_date(gps);

    print_float(gps.f_altitude(), TinyGPS::GPS_INVALID_F_ALTITUDE, 8, 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 ? 0UL : (unsigned long)TinyGPS::distance_between(flat, flon, LONDON_LAT, LONDON_LON) / 1000, 0xFFFFFFFF, 9);
    print_float(flat == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : TinyGPS::course_to(flat, flon, 51.508131, -0.128002), 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();
    }

    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);
    feedgps();
    }

    static void print_float(float val, float invalid, int len, int prec)
    {
    char sz[32];
    if (val == invalid)
    {
    strcpy(sz, “*******”);
    sz[len] = 0;
    if (len > 0)
    sz[len-1] = ‘ ‘;
    for (int i=7; i<len; ++i)
    sz[i] = ' ';
    Serial.print(sz);
    }
    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(" ");
    }
    feedgps();
    }

    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);
    feedgps();
    }

    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] : ' ');
    feedgps();
    }

    static bool feedgps()
    {
    while (nss.available())
    {
    if (gps.encode(nss.read()))
    return true;
    }
    return false;
    }

  27. Above code has small copy paste mistake
    I correctly include above two libraries as follows
    ——————————————————————————
    #include

    #include

  28. Hi friends..I tried this project wit Arduino uno r3 and 15xh-w gps (4800).. No responce in serial monitor.. if i simply read n print the gps output i am getting a sequence of numerical output repeatedly.. eg 246….. 165. WHY SO? i didt get NMEA protocol format. but the same gps gives accurate positions in UART connection with pc in its interface software.. Am sure my gps working good. i tried all codes regard arduino gps. will this arduino work well with PMB-248 alone?? pls help me am in middle of my academic project..

  29. Hey Jeremy

    I’m trying to make a GPS tracker myself but when I tried to use the code of your tutorial my serial monitor gave some weird output and I don’t know what it means or what the problem is.

    This is an example of what my console output is giving me back with some weird squares in between them…
    žžžrŸ¨ä’j”ž(0ÚÓØÙT)( “ÛÛÙyyyyyy$$À8–H…

    I’m using an Arduino Uno and a Adafruit GPS breakoutboard with an internal antenna.

    I hope you can give me some advice

    Thanks

  30. Hi Jeremy , i have arduino uno and gps receiver (nmea) and gsm module (sim900) and i want to make gps tracking which send gps data by sms to my cellphone but i do not know how to convert gps data to google maps form and send it as google maps link to cellphone , please help me …

  31. Thanks for the great tutorial which helps in my final year project.

    I wish to ask whether the software work with all kinds of GPS devices ?
    As currently i am using 3DR GPS uBlox LEA-6 with Arduino Leonardo…
    But i cant get any data from the gps even the fix led is blinking .

    Thanks for the help.

    Regards,
    Hong Ping

      1. jeremy do you have a program to send a message latitude longitudeof GPS shield 1.1 using sim900 arduino mega2560

  32. Pingback: Tutorial 15 for Arduino: GPS Tracking | JeremyBlum.comGPS employee tracking | GPS employee tracking

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