I'm using an arduino uno r3 with a gps shield duinopeak.

enter image description here

The shield is configured using RX pin 3 and Tx pin 2, as image below:

enter image description here

I'm using the TinyGPSPlus library to read NMEA data. This is my code:

  This example uses SoftwareSerial to communicate with the GPS module on
  pins 8 and 9, then communicates over SPI to log that data to a uSD card.

  It uses the TinyGPS++ library to parse the NMEA strings sent by the GPS module,
  and prints interesting GPS information - comma separated - to a newly created
  file on the SD card.

  TinyGPS++ Library  - https://github.com/mikalhart/TinyGPSPlus/releases
  SD Library (Built-in)
  SoftwareSerial Library (Built-in)

  Development/hardware environment specifics:
  Arduino IDE 1.6.7
  GPS Logger Shield v2.0 - Make sure the UART switch is set to SW-UART
  Arduino Uno, RedBoard, Pro, Mega, etc.

#include <SPI.h>
#include <SD.h>
#include <TinyGPS++.h>

#define ARDUINO_USD_CS 8 // uSD card CS pin (pin 8 on Duinopeak GPS Logger Shield)

// Log File Defintions //
// Keep in mind, the SD library has max file name lengths of 8.3 - 8 char prefix,
// and a 3 char suffix.
// Our log files are called "gpslogXX.csv, so "gpslog99.csv" is our max file.
#define LOG_FILE_PREFIX "gpslog" // Name of the log file.
#define MAX_LOG_FILES 100 // Number of log files that can be made
#define LOG_FILE_SUFFIX "csv" // Suffix of the log file
char logFileName[13]; // Char string to store the log file name
// Data to be logged:
char * log_col_names[LOG_COLUMN_COUNT] = {
  "longitude", "latitude", "altitude", "speed", "course", "date", "time", "satellites"
}; // log_col_names is printed at the top of the file.

// Log Rate Control //
#define LOG_RATE 5000 // Log every 5 seconds
unsigned long lastLog = 0; // Global var to keep of last time we logged

// TinyGPS Definitions //
TinyGPSPlus tinyGPS; // tinyGPSPlus object to be used throughout
#define GPS_BAUD 9600 // GPS module's default baud rate

// Arduino GPS Shield Serial Port Definitions //
// If you're using an Arduino Uno, Mega, RedBoard, or any board that uses the
// 0/1 UART for programming/Serial monitor-ing, use SoftwareSerial:
#include <SoftwareSerial.h>
#define ARDUINO_GPS_RX 3 // GPS TX, Arduino RX pin
#define ARDUINO_GPS_TX 2 // GPS RX, Arduino TX pin
SoftwareSerial ssGPS(ARDUINO_GPS_TX, ARDUINO_GPS_RX); // Create a SoftwareSerial

// Set gpsPort to either ssGPS if using SoftwareSerial or Serial1 if using an
// Arduino with a dedicated hardware serial port
#define gpsPort ssGPS  // Alternatively, use Serial1 on the Leonardo

// Define the serial monitor port. On the Uno, Mega, and Leonardo this is 'Serial'
//  on other boards this may be 'SerialUSB'
#define SerialMonitor Serial

void setup()

  SerialMonitor.println("Setting up SD card.");
  // see if the card is present and can be initialized:
  if (!SD.begin(ARDUINO_USD_CS))
    SerialMonitor.println("Error initializing SD card.");
  updateFileName(); // Each time we start, create a new file, increment the number
  printHeader(); // Print a header at the top of the new file

void loop()
  if ((lastLog + LOG_RATE) <= millis())
  { // If it's been LOG_RATE milliseconds since the last log:
    if (tinyGPS.location.isUpdated()) // If the GPS data is vaild
      if (logGPSData()) // Log the GPS data
        SerialMonitor.println("GPS logged."); // Print a debug message
        lastLog = millis(); // Update the lastLog variable
      else // If we failed to log GPS
      { // Print an error, don't update lastLog
        SerialMonitor.println("Failed to log new GPS data.");
    else // If GPS data isn't valid
      // Print a debug message. Maybe we don't have enough satellites yet.
      SerialMonitor.print("No GPS data. Sats: ");

  // If we're not logging, continue to "feed" the tinyGPS object:
  while (gpsPort.available())

byte logGPSData()
  File logFile = SD.open(logFileName, FILE_WRITE); // Open the log file

  if (logFile)
  { // Print longitude, latitude, altitude (in feet), speed (in mph), course
    // in (degrees), date, time, and number of satellites.
    logFile.print(tinyGPS.location.lng(), 6);
    logFile.print(tinyGPS.location.lat(), 6);
    logFile.print(tinyGPS.altitude.feet(), 1);
    logFile.print(tinyGPS.speed.mph(), 1);
    logFile.print(tinyGPS.course.deg(), 1);

    return 1; // Return success

  return 0; // If we failed to open the file, return fail

// printHeader() - prints our eight column names to the top of our log file
void printHeader()
  File logFile = SD.open(logFileName, FILE_WRITE); // Open the log file

  if (logFile) // If the log file opened, print our column names to the file
    int i = 0;
    for (; i < LOG_COLUMN_COUNT; i++)
      if (i < LOG_COLUMN_COUNT - 1) // If it's anything but the last column
        logFile.print(','); // print a comma
      else // If it's the last column
        logFile.println(); // print a new line
    logFile.close(); // close the file

// updateFileName() - Looks through the log files already present on a card,
// and creates a new file with an incremented file index.
void updateFileName()
  int i = 0;
  for (; i < MAX_LOG_FILES; i++)
    memset(logFileName, 0, strlen(logFileName)); // Clear logFileName string
    // Set logFileName to "gpslogXX.csv":
    sprintf(logFileName, "%s%d.%s", LOG_FILE_PREFIX, i, LOG_FILE_SUFFIX);
    if (!SD.exists(logFileName)) // If a file doesn't exist
      break; // Break out of this loop. We found our index
    else // Otherwise:
      SerialMonitor.println(" exists"); // Print a debug statement
  SerialMonitor.print("File name: ");
  SerialMonitor.println(logFileName); // Debug print the file name

Basically the code get the values os lat, long, alt, etc and log into csv file on sdcard. Unfortunately I'm always get no gps data. What's wrong with my code?


Test serial connection with this code:

#include <AltSoftSerial.h>

// AltSoftSerial always uses these pins:
// Board          Transmit  Receive   PWM Unusable
// -----          --------  -------   ------------
// Teensy 3.0 & 3.1  21        20         22
// Teensy 2.0         9        10       (none)
// Teensy++ 2.0      25         4       26, 27
// Arduino Uno        9         8         10
// Arduino Leonardo   5        13       (none)
// Arduino Mega      46        48       44, 45
// Wiring-S           5         6          4
// Sanguino          13        14         12

AltSoftSerial altSerial;

void setup() {
  while (!Serial) ; // wait for Arduino Serial Monitor to open
  Serial.println("AltSoftSerial Test Begin");
  altSerial.println("Hello World");

void loop() {
  char c;

  if (Serial.available()) {
    c = Serial.read();
  if (altSerial.available()) {
    c = altSerial.read();

I just receive the menssage "AltSoftSerial Test Begin", so the problem may be the serial port?

  • Hi How do you adjust the date and time to be the same in my country? I am from the Philippines. thanks!
    – John M.
    Commented Oct 25, 2018 at 13:35

1 Answer 1


The comments in the AltSoftSerial Test say that you have to connect the GPS to pins 8 (RX for GPS TX) and 9 (TX for GPS RX). Your shield does not have jumpers for those pins, but you could use a jumper wire to connect any of the TX pins (0-7) to Arduino pin 8 (on the edge of the shield).

I would also recommend looking at my NeoGPS library. It's smaller, faster, more accurate and more reliable than all other GPS libraries. Even if you don't use it, there are lots of tips on the Troubleshooting page.

Be sure to read about choosing a serial port for the GPS device. That's especially important. In your case, you could use pins 0 and 1. SoftwareSerial is the worst choice and is NOT recommended.

There is also an NMEASDlog example. Unlike examples from other libraries, the NeoGPS examples will reliably work at high update rates and with slow SD cards.

NeoGPS is also available from the Arduino IDE Library Manager, under the menu Sketch -> Include Library -> Manage Libraries.

  • Please see my update with a image of my shield, so the pin 0 and 1 already are connected, ok? I opened the file GPSPort.h in the NeoGPS library and uncomment the line #include <NeoHWSerial.h> // NeoSerial or NeoSerial1 Interrupt-style processing, but a receive the menssage h:159:84: fatal error: NeoHWSerial.h: No such file or directory Commented Sep 22, 2017 at 3:03
  • The images above show pins 2 & 3 are connected. That would require downloading NeoSWSerial for all examples. If you want to use Arduino pins 0 & 1, most examples should work on Serial. Start with NMEA.ino and NMEAorder.ino. Before trying to run the NMEASDlog example, you should try NMEA_isr.ino. You will need to download NeoHWSerial and enable NMEAGPS_INTERRUPT_PROCESSING in Arduino/Libraries/NeoGPS/src/NMEAGPS_cfg.h. When that works, you can try NMEASDlog.ino
    – slash-dev
    Commented Sep 22, 2017 at 14:49
  • Thank you for help, I'm very newbie on arduino, in my case I don't know how to do the connection/wiring on ports 0 and 1 using that shield. Commented Sep 23, 2017 at 23:45
  • Put one jumper block connecting the TX / Digital at column 0, and one on the RX / Digital to column 1 (or vice versa). From your picture, just move the 2 yellow jumper block rectangles to the right by 2 spaces.
    – slash-dev
    Commented Sep 25, 2017 at 14:02
  • 1
    The RX/TX pins do not line up with the Arduino pins, so RX/TX pins 0 and 1 are the two columns at the right side, under Arduino pins 2 & 3. That's confusing, but that should connect the GPS to Arduino pins 0 and 1, as I described earlier.
    – slash-dev
    Commented Sep 27, 2017 at 3:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.