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.
Distributed under the GNU General Public (Open-Source) License.
Please Attribute and Share-Alike.
This video can also be viewed at element14.com.
Here is an online visualization of the data collected in this video:
February 12, 2015 at 1:57 pm
Hi
I have
1. An Arduino
2. A GPS module (I’m using the EM-406 from Sparkfun )
3. A matching way to hook the GPS module to the Arduino (I went with Sparkfun’s GPS Shield )
4. And a microSD Sheild
would what i have work with this code
March 26, 2015 at 5:42 pm
Hi, i was trying with your code for GPS shield, but i got all this errors: I’m using Arduino 1.6.1 compiler, can you help me?
GPS_cesar.ino: In function ‘void loop()’:
GPS_cesar.ino:38:17: error: ‘class TinyGPS’ has no member named ‘satellites’
GPS_cesar.ino:38:31: error: ‘GPS_INVALID_SATELLITES’ is not a member of ‘TinyGPS’
GPS_cesar.ino:39:17: error: ‘class TinyGPS’ has no member named ‘hdop’
GPS_cesar.ino:39:25: error: ‘GPS_INVALID_HDOP’ is not a member of ‘TinyGPS’
GPS_cesar.ino:41:21: error: ‘GPS_INVALID_F_ANGLE’ is not a member of ‘TinyGPS’
GPS_cesar.ino:42:21: error: ‘GPS_INVALID_F_ANGLE’ is not a member of ‘TinyGPS’
GPS_cesar.ino:45:33: error: ‘GPS_INVALID_F_ALTITUDE’ is not a member of ‘TinyGPS’
GPS_cesar.ino:46:31: error: ‘GPS_INVALID_F_ANGLE’ is not a member of ‘TinyGPS’
GPS_cesar.ino:47:35: error: ‘GPS_INVALID_F_SPEED’ is not a member of ‘TinyGPS’
GPS_cesar.ino:48:31: error: ‘GPS_INVALID_F_ANGLE’ is not a member of ‘TinyGPS’
GPS_cesar.ino:48:71: error: ‘cardinal’ is not a member of ‘TinyGPS’
GPS_cesar.ino:49:21: error: ‘GPS_INVALID_F_ANGLE’ is not a member of ‘TinyGPS’
GPS_cesar.ino:49:80: error: ‘distance_between’ is not a member of ‘TinyGPS’
GPS_cesar.ino:50:23: error: ‘GPS_INVALID_F_ANGLE’ is not a member of ‘TinyGPS’
GPS_cesar.ino:50:54: error: ‘GPS_INVALID_F_ANGLE’ is not a member of ‘TinyGPS’
GPS_cesar.ino:50:85: error: ‘course_to’ is not a member of ‘TinyGPS’
GPS_cesar.ino:50:141: error: ‘GPS_INVALID_F_ANGLE’ is not a member of ‘TinyGPS’
GPS_cesar.ino:51:21: error: ‘GPS_INVALID_F_ANGLE’ is not a member of ‘TinyGPS’
GPS_cesar.ino:51:61: error: ‘cardinal’ is not a member of ‘TinyGPS’
GPS_cesar.ino:51:79: error: ‘course_to’ is not a member of ‘TinyGPS’
Error compiling.
April 12, 2015 at 3:31 pm
Hi, Thank you very much for posting this, I managed to get it working but for some reason the SD part does not work, I keep getting the error below even thought the CSV file is on the SD card . please help me, i need urgently help, doing this for my university project
Couldn’t open the log file!
Card Failure
April 11, 2016 at 10:51 am
Hey, how are I see that you got the code to work. Unfortunately I couldn’t. Did you have to make any adjustments?
May 6, 2016 at 9:02 am
HI, did you manage?
April 15, 2015 at 10:59 pm
i got the latitude and longitude but cant log the data in sd card.
couldn’t open the log file
help me plzzz
May 5, 2015 at 3:53 am
Thanks for sharing this, I have plan with my GPS project module. this is really help!
June 17, 2015 at 2:41 am
GPS_EM-406A is need any sim and gsm module
July 22, 2015 at 10:54 am
I could not get the test_with_gps_device code to work. I am also using a mega 2560 and set it up as per your instructions. I get the same readings you got in the video on the serial monitor, but I shouldn’t because the module has a gps fix. I verified it with adafruit’s parsing code prior to uploading the test_with_gps_device sketch. The module (an adafruit ultimate gps breakout) also has an led indicating that it has established a fix. Any ideas on what might be preventing the serial monitor from displaying the data?
July 22, 2015 at 1:26 pm
I figured it out. The baud for the adafruit gps breakout board needed to be set at 9600 (see http://forum.arduino.cc/index.php?topic=174454.15). Thank you for this great tutorial. It was very helpful.
July 30, 2015 at 3:40 pm
Hello, hi jeremy….
Nice job!!!
Hey I am working on gps REB 4216. previously I tried with following code and I am getting the result as
……………………………………………………………………………………………………………………….
“$GPGGA,030940.000,2446.5775,N,12102.6593,E,1,11,0.7,136.3,M,15.1,M,,0000*5A”
“$GPGSA,M,3,19,04,11,27,07,16,01,09,23,26,30,,1.5,0.7,1.3*38”
“$GPGSV,3,1,12,19,69,346,37,04,48,162,25,11,47,199,24,27,41,029,34*78”
“$GPGSV,3,2,12,07,38,320,40,16,30,067,35,01,27,184,21,09,27,252,23*73”
“$GPGSV,3,3,12,23,23,212,25,26,11,089,25,30,08,320,26,08,52,020,34*7A”
“$GPRMC,030940.000,A,2446.5775,N,12102.6593,E,0.00,295.95,270715,,,A*69”
“$GPGGA,030941.000,2446.5775,N,12102.6593,”
…………………………………………………………………………………………………………………………………..
this data is correct but I am not able to decode it even after using .csv format.
I found tha u did a great job as getting prety tabular formatfor the parameters latitude and longitude.
With your code I am just geting invalid data string..:(
Please help!!!
Thank you!!
August 29, 2015 at 9:54 am
Is there any sd card module for arduino leonardo ?
November 21, 2015 at 12:46 pm
You make great tutorial, but I’m not English speaking person, so for my is hard understand yours fast talk. And, can you make sketch of this devise connections, I can’t understand, what cable where have to go. Thanks
December 4, 2015 at 8:37 pm
Please Help
I am trying to track the GPS but i am not able to receive my longitude and latitude data.
I am using “Adafruit Ultimate GPS Breakout V3” GPS module and “Arduino UNO R3”
Here is my code. I have tried both
:::First Code:::
#include
#include
long flat, flon;
SoftwareSerial gpsSerial(2, 3); // Create GPS pin connection
TinyGPS gps;
void setup(){
Serial.begin(9600); // connection serial
gpsSerial.begin(9600); // gps burd rate
}
void loop(){
while(gpsSerial.available()){ // check for gps data
if(gps.encode(gpsSerial.read())){ // encode gps data
gps.get_position(&flat, &flon); // get lattitude and longitude
// display position
Serial.print(“Position: “);
Serial.print(“lat: “);Serial.println(flat);
Serial.print(“lon: “);Serial.println(flon);
}
}
}
:::Second Code:::
#include
#include
#define RXPin 3
#define TXPin 4
#define GPSBaud 9600
#define ConsoleBaud 115200
// The serial connection to the GPS device
SoftwareSerial ss(RXPin, TXPin);
// The TinyGPS++ object
TinyGPSPlus gps;
void setup()
{
Serial.begin(ConsoleBaud);
ss.begin(GPSBaud);
Serial.println(“GPS Example 2”);
Serial.println(“A simple tracker using TinyGPS++.”);
Serial.println();
}
void loop()
{
// If any characters have arrived from the GPS,
// send them to the TinyGPS++ object
while (ss.available() > 0)
gps.encode(ss.read());
// Let’s display the new location and altitude
// whenever either of them have been updated.
if (gps.location.isUpdated() || gps.altitude.isUpdated())
{
Serial.print(“Location: “);
Serial.print(gps.location.lat(), 6);
Serial.print(“,”);
Serial.print(gps.location.lng(), 6);
Serial.print(” Altitude: “);
Serial.println(gps.altitude.meters());
}
}
December 21, 2015 at 7:10 am
Hi jeremy
Im not very good in english.
I have some problem with my board.my board is 2560.i tested your third tutorial.when i defined a port as input it gets high voltage when i bring my fingers near it.plz help
Thx
February 5, 2016 at 9:55 am
Can u please explain each of the data being displayed. I am doing a project on it and I need to filter the unwanted data, to avoid stack overflow. Could you please help me out? I am using it in a drone project and i need the latitude, longitude, altitude, speed, distance to target and heading angle.
March 6, 2016 at 2:01 am
hey…. i hav a project to log the gps data in any database or cloud storage… can u help me with the codings… my gps program worked wonderfully bt now the database is a issue.. can u suggest me some links fr the codings… please….
March 6, 2016 at 2:04 am
And i want to the storage without using any wifi or ethernet shield…. and i hav device such as gsm sim900a mogule, gps module and arduino… please provide some help asap….
March 16, 2016 at 9:14 am
Hi Pratiksha
I am doing a similar thing for a student. May be this could help you. Can you ping me with your code and I can include the database part to jmkrecruitments (at) gmail (dot) com
March 9, 2016 at 9:52 am
hi
ı want to make a android project with ardiuno gps module . project is vehicle tracking system.
ı dont know How do I connect the arduino and android ?
please help me
March 16, 2016 at 9:16 am
Hi
contact me at jmkrecruitments (at) gmail (at) com. I will try my best to help out.
August 16, 2016 at 2:11 am
Hi!
I would like to ask some help.
I have an Arduino Mega 2560, I bought it from the ebay, about 5-6 years ago, but I never used it before. I borrowed from a friend of mine an Arduino Uno+ made by Hobbycomponents, and I can upload the sketches to the Uno+, but the Mega always throws programmer timeout error.
I tried it on three several computers (Win 7 ultimate 64bit, with arduino 1.6.9, Win7 enterprise 32bit, with arduino 1.0.5, 1.6.10, and 1.0.0, and Win XP SP3 with arduino 1.6.10), and I get the same errors.
I tried to google it, but I found nothing useful information, I didn’t use in the code “!!!”, or something similar errors, the sketch runs on the Uno+, but instable, uses cc 88% of the memory.
Could you help me, how can I fix it?
Can be originally damaged a brand new Arduino Mega?
When I bought it, a friend of mine bought another Mega 2560, from the same seller on ebay, and that one works fine.
Thank you for your help.
August 30, 2016 at 5:31 am
Hi
I’m using a Ublox NEO-6M GPS Module Aircraft Flight Controller according do your tutorial. But it gets a wrong time value. There is no problem with date, latitude and longitude. Any suggestions?
thank you!
November 17, 2016 at 1:53 pm
hi bro how can you make for us tutorial about how we can send locations gps to phone with gsm
December 27, 2016 at 9:25 am
Hi,
Will this code work for Arduino Uno?
I don’t have a sd card, but I have a transceiver. Is it possible to print gps data?
thanks a lot!
December 28, 2016 at 3:24 am
I tried this sketch on a CH340 based Uno compatible board, and it runs, but instable, so I think, you remove some functions from it, it could be useful, and stable.
I used a Beitian BN-880 GPS receiver, and this receiver does not support the 10Hz refresh rate for the GPS information, I used it on 4Hz with the Mega2560 R3 board (the whole sketch with my functions and features runs cc 250ms, so I could not use it on 5Hz)
December 28, 2016 at 12:10 pm
The best solution for all your troubles is to change Arduino version to 1.5 and thats all.
Pingback: Mini Controllers » Tutorial 15 for Arduino: GPS Tracking
September 16, 2017 at 2:50 am
hello Jeremy :) i have the globalsat EB 5365 RE gps shield , with an arduino uno , and i cant make it happen to work with the tinygps libraries , you have any recommendations how to make it work ?
September 20, 2017 at 9:18 pm
hello i am venkat can anyone send the GPS code for audrino uno board
September 22, 2017 at 9:59 am
To all of the commentators above ….have you got any replies from Jeremy?
Its pitiful that these queries are valid yet no answers have been posted. Im posting obviously I dont want to ask the something thats already been asked.
August 17, 2018 at 3:08 am
hey,
I am trying to do the same project but instead of using SD card, can use phone for receiving GPS data.
so any idea about the code to receive the gps data to a single phone number.