Realtime GPS Tracker w. SD Card Logger

This article shows how to build a GPS tracker that sends NMEA GPS sentences to a remote device in realtime. At the same time it logs position information onto a SD card.

A while ago I got a bunch of SIM900 GSM shields, the GPRS Shield V2.0 from seed [1]. Looking for project ideas I thought a realtime GPS tracker would be a great idea. It is a derrivative of my Simple Arduino SD-Card GPS/NMEA Datalogger. It is essentially the same circuit, except this time it adds GSM text messaging.


I developed this project on the Arduino Due but converted it to the Uno platform as more of my readers are likely working with it. The only difference in code is that the Uno only has one UART while the Due has 4. But thanks to the software serial library it’s an easy conversion. Be certain to set the jumpers on the GPRS shield to hardware serial. The soft serial is used for the GPS receiver instead.

GPS receivers spit out GPS information in a format called NMEA 0183, or NMEA for short. It is a standardized format for all kinds of navigation related instruments [2]. It’s primarily used in the marine world. Nearly any GPS module on the market can spit out NMEA sentences. The Arduino takes in NMEA sentences via Serial1, which is the software serial on the Uno or actual Serial 1 on a Due. Out of all the NMEA sentences the Arduino extracts the GPRMC sentence, a basic sentence sufficient for tracking purposes, and stores it on the SD card. It also takes the same sentence and sends it via text message. This happens about every 5 minutes.

The code is quite simple:

Realtime GSM GPS Tracker

Created: 01/22/2016
by Sebastian Westerhold

This example code is in the public domain.

SD Card uses SEED SD Card Shield v. 4.0
CS - pin 4

Connect GPS Module to PIN 7 on UNO
Connect GPS Module to Serial 1 RX on Due



// Soft Serial for UNO
// Comment out for Due
SoftwareSerial Serial1(7, 8);

// Set up necessary variables
const int chipSelect = 4;
char SerRead = 0;

// Setup routine
void setup() {

// Initiate Serial at 19200 for GSM900 module
// Wait until serial is ready
while (!Serial) {

// Begin GPS Serial

// Initialize the SD card
Serial.print("Initializing SD card...");
if (!SD.begin(chipSelect)) {
Serial.println("Card failed, or not present");

// Set mode to text

// function to send text message
void sendSMS(String message)
// Initiate text message
// Set target phone number
Serial.println("AT + CMGS = \"+15015559350\"");
// send message
// send termination character

// Main routine
void loop() {

// our buffer for serial data
String dataString = "";

// If there's serial data int he buffer, add to dataString
while(Serial1.available() >0)
// read a line on the serial port
dataString = Serial1.readStringUntil('\n');

// If there's data in dataString, dump to SD card and send text message
if (dataString.length() >0) {

// Open file on SD Card
File dataFile ="NMEA.txt", FILE_WRITE);

// Dump data to file and serial port as well
if (dataFile) {
if (!dataString.indexOf("$GPRMC"))


// send text message

// Wait for about 5 minutes before next message

// If there's any errors, so say via serial.
else {
Serial.println("error opening NMEA.txt");

If everything is connected correctly, you should receive text messages about every 5 minutes with the current $GPRMC NMEA sentence.


The idea behind this is to take another Arduino to receive the NMEA sentence and blurt it out over its serial port to spoof a GPS receiver to a PC. That way any mapping software that accepts GPRMC sentences can be used without any modification.

Links and Sources:

[1] GPRS Shield V2.0, SEED:

[2] NMEA 0183, Wikipedia:

Leave a Reply