Interfacing GPS Shield for Arduino(ublox NEO-6M-0-001) with Arduino Mega 2560

GPS Shield for Arduino (NEO-6M-0-001) can be interfaced with Arduino UNO or MEGA directly with the help of Software Serial Library, but you can use hardware serial on Mega 2560.

Here is how the connections will be:

Arduino GPS Shield NEO 6m Arduino GPS Shield NEO 6m

 

Connections and Configuration:

1. Mount “GPS Shield for Arduino Over Arduino Mega 2560” as shown in Figures below:

Arduino GPS Shield Arduino GPS Shield

 

2. Configure GPS Shield:

– Set supply voltage as 5V (Set switch on shield to 5V as shown in Figures above)
– TXD pin from GPS Shield is connected to RX1 (19 on Mega 2560)
– RXD pin from GPS Shield is connected to TX1 (18 on Mega 2560)

– Baud Rate is: 38400
– Library used is TinyGPS++
– For first time, it may take up to 30 seconds to acquire values, after that it acquire values in every two seconds
– It can also work inside a building, if antenna is connected to it.

Arduino GPS Shield connections

Code:

Here is a simple code, that doesn’t need any library, it will just show all the data received from GPS, this is the first step to knowing, is GPS working and connections are fine:

void setup()
{
Serial.begin(9600);
Serial1.begin(38400);
Serial.println(“Initialized”);
}void loop()
{
if(Serial.available())
{
char a=Serial.read();
Serial1.write(a);
}if(Serial1.available())
{
char b=Serial1.read();
Serial.write(b);
}
}

 

To get each parameter separately, I have used TinyGPS++ Library with modified code:
To use following code, you need to add TinyGPSPlus Library to Arduino: Download TinyGPSPlus Library (43.1KB)

#include <TinyGPS++.h>
TinyGPSPlus gps;void setup()
{
Serial.begin(115200);
Serial1.begin(38400);
}void loop()
{while (Serial1.available() > 0)
if (gps.encode(Serial1.read()))
displayInfo();

if (millis() > 30000 && gps.charsProcessed() < 10)
{
Serial.println(F(“No GPS detected: check wiring.”));
while(true);
}
}

Attachments:

Download TinyGPSPlus Library (43.1KB)
Download Datasheet (866 KB)

 

Leave a Reply

Your email address will not be published.