Using GPS Shield from with Arduino Mega

First let’s start with the hardware part.

Look at the picture I send at the bottom of this post.

As you can see on the picture, you have the Tx row and the Rx row.First, Remove the 2 jumpers from this section of the GPS board. Then, you must use 2 Dupont Jumper wires to link those 2 rows to the Serial Port1 on the Mega. One of the pins of Tx row goes to the Rx pin(19) on the Mega, and one of the pins Rx row goes to the Tx pin(18) on the Mega. You can take any one pin of each two Rows, since each pin of each Row are interconnected.

By the way, the middle Row are individualize Male connector that lead to the pin 0 to 7 on your Mega. You can use them as simple male connector for those pin. Since you use serial port1, this Row has no use in your project, at least not concerning the GPS part.


they say :

The INT0 is the broke out of the external interrupt pin of GPS module,
if not use, please set the jumper to OFF as the following figure.
The INT1 is the broke out of the 1PPS output. When the GPS module
has tracked to the GPS satellite, this pin will send a pulse per second.

So, if you want to use External Interrupt for you GPS set INT0 to ON. And if you want to use the 1PPS function on the GPS set INT1 to ON, otherwise leave them OFF. Use the 2 jumper you previously remove to set these 2 functions ON or OFF

IMPORTANT!!! They also remind that:

When install GPS shield to Arduino, please check the operation
voltage level of development board. If the voltage is 3.3V
(IFLAT32,Leaf maple), set the Operation Level Setting switch to 3.3V.
If the voltage is 5V(Arduino), set the Operation Level Setting switch to

I see, from the picture, that the proper voltage(5volts) is set on the GPS board, So unless you use a 3,3volts system(it’s not the case if you are using a Mega), DON’T change it. Cause you might burn your GPS and you will then cry. :frowning:

There could be one last hardware subject that need to be addressed, the SDCard reader. As we all know the Sdcard use the SPI port. Since the SPI port on the Mega is not at Pin 10, 11, 12 and 13, you will have to find a way to jump these to Pin 50, 51, 52 and 53 on you Mega. I recomande using Dupont jumper wires to connect those pin to the Mega SPI port.

Some will be tempted to simply cut the pins from under the shield.Think about it, if you ever want to downgrade to Uno, you will be screwed. So think twice before cutting those pins. Maybe bending the pins toward the inside would be better idea.

That was the hardware part. Now the software.

I choose the Serial Port1 because the example found, a repeater program, use this port setting. You can use any of the 3 ports on the Mega, but if you don’t use Port1, you will need to modify the code accordingly.

You might have to set the pace to 38400 bps, if it’s what you GPS need, in the example. To know check what the default is set at for your GPS board. But if you haven’t change it, it should be 38400 bps according to the documentation listed above.

Maybe, set the same pace for serial port0 It should not hurt.

Your test code should look like this

void setup() {
                      // Put the proper GPS communication speed down in those 2
  Serial.begin(38400);    // This is the port the Mega use to communicate with you computer
  Serial1.begin(38400);  // This is where your GPS is hook

void loop() {
  // read from GPS, send to IDE Serial Monitor:
  if (Serial1.available()) {
    int inByte =;
  // read from IDE Serial Monitor, send to GPS:
  if (Serial.available()) {
    int inByte =;

Finaly, upload the example to your Mega. Once it’s done it should send the GPS incoming data to your serial monitor. But make sure to put the proper pace in the IDE Serial Monitor otherwise it’s just gonna show you weird stuff or nothing at all.

If this Work you in business. You can add commands to your routines until you have the program you want or until it get so complicated that you won’t understand what is happening inside. :stuck_out_tongue:

Also, I checked the Tinygps example from TinyGPS | Arduiniana, because every one talk about it…

One thing is certain about this example, You must change all the parts about the software serial “ss” to hardware “Serial1”. And remember to set the right bitrate to Serial1. The multiple Serial Hardware is one of the reason you got the Mega, so it’s time to get the benefit for your investment, and set aside the software serial libraries.

So i look like this:

#include <TinyGPS.h>

TinyGPS gps;

void setup()
  Serial1.begin(4800);                                     //This line has been change
  Serial.print("Simple TinyGPS library v. "); Serial.println(TinyGPS::library_version());
  Serial.println("by Mikal Hart");

void loop()
  bool newData = false;
  unsigned long chars;
  unsigned short sentences, failed;

  // For one second we parse GPS data and report some key values
  for (unsigned long start = millis(); millis() - start < 1000;)
    while (Serial1.available())                                     //This line has been change
      char c =;                                     //This line has been change
      // Serial.write(c); // uncomment this line if you want to see the GPS data flowing
      if (gps.encode(c)) // Did a new valid sentence come in?
        newData = true;

  if (newData)
    float flat, flon;
    unsigned long age;
    gps.f_get_position(&flat, &flon, &age);
    Serial.print(flat == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : flat, 6);
    Serial.print(" LON=");
    Serial.print(flon == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : flon, 6);
    Serial.print(" SAT=");
    Serial.print(gps.satellites() == TinyGPS::GPS_INVALID_SATELLITES ? 0 : gps.satellites());
    Serial.print(" PREC=");
    Serial.print(gps.hdop() == TinyGPS::GPS_INVALID_HDOP ? 0 : gps.hdop());
  gps.stats(&chars, &sentences, &failed);
  Serial.print(" CHARS=");
  Serial.print(" SENTENCES=");
  Serial.print(" CSUM ERR=");

I also remove the reference to the serial software libraries, And the line where that libraries is call. This save room because there is one less libraries to load.

Oh! Are you outside, or near a Windows that is pointing East or West? Cause if you are in your basement there is good chance your GPS board catch nothing from satellite.

If’s you have any question I will be pleased to help more, but I think this explanation is completed.

Does it cover the subject? :wink:

Hi, I followed your instructions and all is Ok, but I can’t use the microSD to log data.

This is my code

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

TinyGPS gps;

void setup()

  Serial1.begin(9600);//GPS specs

// Initialize card
  Serial.print("Initializing SD card...");
  pinMode(10, OUTPUT); //I tried change to 50 (the pin  from gps Shield to Mega)
  if (!SD.begin(10)) {
   Serial.println("...initialization failed!");
    Serial.println("...initialization done.");

    File dataFile ="kklog4.txt", FILE_WRITE);
    dataFile.println("Latitud (dd.dddddd),  Longitud (-ddd.dddddd), Time (UTC-5h)");


I tried to chage the pinmode to 50 but I get the same error

Initializing SD card…initialization failed!

Any idea?