I have been trying to interface NEO-6M GPS MODULE with Arduino Mega, before I could proceed I went through all previous post regarding the same and none matches with the problem I am facing right now. So I am starting a new thread
I am using Mikal Hart gps library and the code is given below, connections are
vcc of gps to 3.3v of arduino mega 2560
gnd of gps to gnd of arduino mega 2560
rx of gps to tx3(14th pin of arduino mega 2560)// Serial3
tx of gps to rx3(15th pin of arduino mega 2560)// Serial3
Arduino Example code from library I am using is
#include <TinyGPSPlus.h>
#include <SoftwareSerial.h>
/*
This sample code demonstrates the normal use of a TinyGPSPlus (TinyGPSPlus) object.
It requires the use of SoftwareSerial, and aSerial3umes that you have a
4800-baud serial GPS device hooked up on pins 4(rx) and 3(tx).
*/
static const int RXPin = 4, TXPin = 3;
static const uint32_t GPSBaud = 9600;
// The TinyGPSPlus object
TinyGPSPlus gps;
// The serial connection to the GPS device
//SoftwareSerial Serial3(RXPin, TXPin);
void setup()
{
Serial.begin(115200);
Serial3.begin(GPSBaud);
Serial.println(F("FullExample.ino"));
Serial.println(F("An extensive example of many interesting TinyGPSPlus features"));
Serial.print(F("Testing TinyGPSPlus library v. ")); Serial.println(TinyGPSPlus::libraryVersion());
Serial.println(F("by Mikal Hart"));
Serial.println();
Serial.println(F("Sats HDOP Latitude Longitude Fix Date Time Date Alt Course Speed Card Distance Course Card Chars Sentences Checksum"));
Serial.println(F(" (deg) (deg) Age Age (m) --- from GPS ---- ---- to London ---- RX RX Fail"));
Serial.println(F("----------------------------------------------------------------------------------------------------------------------------------------"));
}
void loop()
{
static const double LONDON_LAT = 51.508131, LONDON_LON = -0.128002;
printInt(gps.satellites.value(), gps.satellites.isValid(), 5);
printFloat(gps.hdop.hdop(), gps.hdop.isValid(), 6, 1);
printFloat(gps.location.lat(), gps.location.isValid(), 11, 6);
printFloat(gps.location.lng(), gps.location.isValid(), 12, 6);
printInt(gps.location.age(), gps.location.isValid(), 5);
printDateTime(gps.date, gps.time);
printFloat(gps.altitude.meters(), gps.altitude.isValid(), 7, 2);
printFloat(gps.course.deg(), gps.course.isValid(), 7, 2);
printFloat(gps.speed.kmph(), gps.speed.isValid(), 6, 2);
printStr(gps.course.isValid() ? TinyGPSPlus::cardinal(gps.course.deg()) : "*** ", 6);
unsigned long distanceKmToLondon =
(unsigned long)TinyGPSPlus::distanceBetween(
gps.location.lat(),
gps.location.lng(),
LONDON_LAT,
LONDON_LON) / 1000;
printInt(distanceKmToLondon, gps.location.isValid(), 9);
double courseToLondon =
TinyGPSPlus::courseTo(
gps.location.lat(),
gps.location.lng(),
LONDON_LAT,
LONDON_LON);
printFloat(courseToLondon, gps.location.isValid(), 7, 2);
const char *cardinalToLondon = TinyGPSPlus::cardinal(courseToLondon);
printStr(gps.location.isValid() ? cardinalToLondon : "*** ", 6);
printInt(gps.charsProcessed(), true, 6);
printInt(gps.sentencesWithFix(), true, 10);
printInt(gps.failedChecksum(), true, 9);
Serial.println();
smartDelay(1000);
if (millis() > 5000 && gps.charsProcessed() < 10)
Serial.println(F("No GPS data received: check wiring"));
}
// This custom version of delay() ensures that the gps object
// is being "fed".
static void smartDelay(unsigned long ms)
{
unsigned long start = millis();
do
{
while (Serial3.available())
gps.encode(Serial3.read());
} while (millis() - start < ms);
}
static void printFloat(float val, bool valid, int len, int prec)
{
if (!valid)
{
while (len-- > 1)
Serial.print('*');
Serial.print(' ');
}
else
{
Serial.print(val, prec);
int vi = abs((int)val);
int flen = prec + (val < 0.0 ? 2 : 1); // . and -
flen += vi >= 1000 ? 4 : vi >= 100 ? 3 : vi >= 10 ? 2 : 1;
for (int i=flen; i<len; ++i)
Serial.print(' ');
}
smartDelay(0);
}
static void printInt(unsigned long val, bool valid, int len)
{
char sz[32] = "*****************";
if (valid)
sprintf(sz, "%ld", val);
sz[len] = 0;
for (int i=strlen(sz); i<len; ++i)
sz[i] = ' ';
if (len > 0)
sz[len-1] = ' ';
Serial.print(sz);
smartDelay(0);
}
static void printDateTime(TinyGPSDate &d, TinyGPSTime &t)
{
if (!d.isValid())
{
Serial.print(F("********** "));
}
else
{
char sz[32];
sprintf(sz, "%02d/%02d/%02d ", d.month(), d.day(), d.year());
Serial.print(sz);
}
if (!t.isValid())
{
Serial.print(F("******** "));
}
else
{
char sz[32];
sprintf(sz, "%02d:%02d:%02d ", t.hour(), t.minute(), t.second());
Serial.print(sz);
}
printInt(d.age(), d.isValid(), 5);
smartDelay(0);
}
static void printStr(const char *str, int len)
{
int slen = strlen(str);
for (int i=0; i<len; ++i)
Serial.print(i<slen ? str[i] : ' ');
smartDelay(0);
}
And the output in the serial monitor as of now is
08:06:03.079 -> FullExample.ino
08:06:03.079 -> An extensive example of many interesting TinyGPSPlus features
08:06:03.079 -> Testing TinyGPSPlus library v. 1.0.2
08:06:03.079 -> by Mikal Hart
08:06:03.112 ->
08:06:03.112 -> Sats HDOP Latitude Longitude Fix Date Time Date Alt Course Speed Card Distance Course Card Chars Sentences Checksum
08:06:03.112 -> (deg) (deg) Age Age (m) --- from GPS ---- ---- to London ---- RX RX Fail
08:06:03.112 -> ----------------------------------------------------------------------------------------------------------------------------------------
08:06:03.145 -> **** ***** ********** *********** **** ********** ******** **** ****** ****** ***** *** ******** ****** *** 0 0 0
08:06:04.146 -> 0 100.0 ********** *********** **** 00/00/2000 00:00:00 256 ****** ****** ***** *** ******** ****** *** 195 0 0
08:06:05.144 -> 0 100.0 ********** *********** **** 00/00/2000 00:00:00 261 ****** ****** ***** *** ******** ****** *** 357 0 0
08:06:06.142 -> 0 100.0 ********** *********** **** 00/00/2000 00:00:00 267 ****** ****** ***** *** ******** ****** *** 519 0 0
08:06:07.174 -> 0 100.0 ********** *********** **** 00/00/2000 00:00:00 273 ****** ****** ***** *** ******** ****** *** 681 0 0
08:06:08.173 -> 0 100.0 ********** *********** **** 00/00/2000 00:00:00 280 ****** ****** ***** *** ******** ****** *** 843 0 0
08:06:09.172 -> 0 100.0 ********** *********** **** 00/00/2000 00:00:00 286 ****** ****** ***** *** ******** ****** *** 1005 0 0
08:06:10.170 -> 0 100.0 ********** *********** **** 00/00/2000 00:00:00 292 ****** ****** ***** *** ******** ****** *** 1167 0 0
08:06:11.168 -> 0 100.0 ********** *********** **** 00/00/2000 00:00:00 298 ****** ****** ***** *** ******** ****** *** 1329 0 0
08:06:12.200 -> 0 100.0 ********** *********** **** 00/00/2000 00:00:00 303 ****** ****** ***** *** ******** ****** *** 1491 0 0
08:06:13.198 -> 0 100.0 ********** *********** **** 00/00/2000 00:00:00 308 ****** ****** ***** *** ******** ****** *** 1653 0 0
08:06:14.196 -> 0 100.0 ********** *********** **** 00/00/2000 00:00:00 315 ****** ****** ***** *** ******** ****** *** 1823 0 0
08:06:15.193 -> 0 100.0 ********** *********** **** 00/00/2000 00:00:00 321 ****** ****** ***** *** ******** ****** *** 1985 0 0
08:06:16.225 -> 0 100.0 ********** *********** **** 00/00/2000 00:00:00 326 ****** ****** ***** *** ******** ****** *** 2147 0 0
08:06:17.222 -> 0 100.0 ********** *********** **** 00/00/2000 00:00:00 334 ****** ****** ***** *** ******** ****** *** 2309 0 0
08:06:18.221 -> 0 100.0 ********** *********** **** 00/00/2000 00:00:00 342 ****** ****** ***** *** ******** ****** *** 2471 0 0
08:06:19.219 -> 0 100.0 ********** *********** **** 00/00/2000 00:00:00 346 ****** ****** ***** *** ******** ****** *** 2633 0 0
08:06:20.222 -> 0 100.0 ********** *********** **** 00/00/2000 00:00:00 353 ****** ****** ***** *** ******** ****** *** 2795 0 0
08:06:21.253 -> 0 100.0 ********** *********** **** 00/00/2000 00:00:00 358 ****** ****** ***** *** ******** ****** *** 2957 0 0
08:06:22.252 -> 0 100.0 ********** *********** **** 00/00/2000 00:00:00 364 ****** ****** ***** *** ******** ****** *** 3119 0 0
08:06:23.254 -> 0 100.0 ********** *********** **** 00/00/2000 00:00:00 368 ****** ****** ***** *** ******** ****** *** 3281 0 0
08:06:24.251 -> 0 100.0 ********** *********** **** 00/00/2000 00:00:00 377 ****** ****** ***** *** ******** ****** *** 3443 0 0
08:06:25.282 -> 0 100.0 ********** *********** **** 00/00/2000 00:00:00 383 ****** ****** ***** *** ******** ****** *** 3605 0 0
08:06:26.280 -> 0 100.0 ********** *********** **** 00/00/2000 00:00:00 389 ****** ****** ***** *** ******** ****** *** 3767 0 0
08:06:27.278 -> 0 100.0 ********** *********** **** 00/00/2000 00:00:00 395 ****** ****** ***** *** ******** ****** *** 3929 0 0
08:06:28.278 -> 0 100.0 ********** *********** **** 00/00/2000 00:00:00 401 ****** ****** ***** *** ******** ****** *** 4091 0 0
08:06:29.276 -> 0 100.0 ********** *********** **** 00/00/2000 00:00:00 408 ****** ****** ***** *** ******** ****** *** 4253 0 0
08:06:30.307 -> 0 100.0 ********** *********** **** 00/00/2000 00:00:00 413 ****** ****** ***** *** ******** ****** *** 4415 0 0
08:06:31.304 -> 0 100.0 ********** *********** **** 00/00/2000 00:00:00 420 ****** ****** ***** *** ******** ****** *** 4577 0 0
08:06:32.302 -> 0 100.0 ********** *********** **** 00/00/2000 00:00:00 425 ****** ****** ***** *** ******** ****** *** 4739 0 0
08:06:33.301 -> 0 100.0 ********** *********** **** 00/00/2000 00:00:00 431 ****** ****** ***** *** ******** ****** *** 4901 0 0
08:06:34.332 -> 0 100.0 ********** *********** **** 00/00/2000 00:00:00 439 ****** ****** ***** *** ******** ****** *** 5063 0 0
08:06:35.330 -> 0 100.0 ********** *********** **** 00/00/2000 00:00:00 443 ****** ****** ***** *** ******** ****** *** 5225 0 0
08:06:36.328 -> 0 100.0 ********** *********** **** 00/00/2000 00:00:00 449 ****** ****** ***** *** ******** ****** *** 5387 0 0
08:06:37.326 -> 0 100.0 ********** *********** **** 00/00/2000 00:00:00 456 ****** ****** ***** *** ******** ****** *** 5549 0 0
08:06:38.358 -> 0 100.0 ********** *********** **** 00/00/2000 00:00:00 462 ****** ****** ***** *** ******** ****** *** 5711 0 0
08:06:39.357 -> 0 100.0 ********** *********** **** 00/00/2000 00:00:00 468 ****** ****** ***** *** ******** ****** *** 5873 0 0
08:06:40.355 -> 0 100.0 ********** *********** **** 00/00/2000 00:00:00 474 ****** ****** ***** *** ******** ****** *** 6035 0 0
08:06:41.353 -> 0 100.0 ********** *********** **** 00/00/2000 00:00:00 480 ****** ****** ***** *** ******** ****** *** 6197 0 0
08:06:42.385 -> 0 100.0 ********** *********** **** 00/00/2000 00:00:00 487 ****** ****** ***** *** ******** ****** *** 6359 0 0
08:06:43.383 -> 0 100.0 ********** *********** **** 00/00/2000 00:00:00 493 ****** ****** ***** *** ******** ****** *** 6521 0 0
08:06:44.381 -> 0 100.0 ********** *********** **** 00/00/2000 00:00:00 498 ****** ****** ***** *** ******** ****** *** 6683 0 0
08:06:45.378 -> 0 100.0 ********** *********** **** 00/00/2000 00:00:00 505 ****** ****** ***** *** ******** ****** *** 6853 0 0
08:06:46.376 -> 0 100.0 ********** *********** **** 00/00/2000 00:00:00 510 ****** ****** ***** *** ******** ****** *** 7015 0 0
08:06:47.408 -> 0 100.0 ********** *********** **** 00/00/2000 00:00:00 517 ****** ****** ***** *** ******** ****** *** 7185 0 0
08:06:48.408 -> 0 100.0 ********** *********** **** 00/00/2000 00:00:00 522 ****** ****** ***** *** ******** ****** *** 7347 0 0
08:06:49.406 -> 0 100.0 ********** *********** **** 00/00/2000 00:00:00 529 ****** ****** ***** *** ******** ****** *** 7509 0 0
08:06:50.403 -> 0 100.0 ********** *********** **** 00/00/2000 00:00:00 535 ****** ****** ***** *** ******** ****** *** 7671 0 0
08:06:51.434 -> 0 100.0 ********** *********** **** 00/00/2000 00:00:00 542 ****** ****** ***** *** ******** ****** *** 7833 0 0
08:06:52.432 -> 0 100.0 ********** *********** **** 00/00/2000 00:00:00 548 ****** ****** ***** *** ******** ****** *** 7995 0 0
08:06:53.430 -> 0 100.0 ********** *********** **** 00/00/2000 00:00:00 553 ****** ****** ***** *** ******** ****** *** 8157 0 0
08:06:54.428 -> 0 100.0 ********** *********** **** 00/00/2000 00:00:00 559 ****** ****** ***** *** ******** ****** *** 8319 0 0
08:06:55.460 -> 0 100.0 ********** *********** **** 00/00/2000 00:00:00 564 ****** ****** ***** *** ******** ****** *** 8481 0 0
08:06:56.458 -> 0 100.0 ********** *********** **** 00/00/2000 00:00:00 571 ****** ****** ***** *** ******** ****** *** 8643 0 0
08:06:57.456 -> 0 100.0 ********** *********** **** 00/00/2000 00:00:00 577 ****** ****** ***** *** ******** ****** *** 8805 0 0
08:06:58.454 -> 0 100.0 ********** *********** **** 00/00/2000 00:00:00 583 ****** ****** ***** *** ******** ****** *** 8967 0 0
08:06:59.458 -> 0 100.0 ********** *********** **** 00/00/2000 00:00:00 590 ****** ****** ***** *** ******** ****** *** 9129 0 0
08:07:00.491 -> 0 100.0 ********** *********** **** 00/00/2000 00:00:00 595 ****** ****** ***** *** ******** ****** *** 9291 0 0
08:07:01.488 -> 0 100.0 ********** *********** **** 00/00/2000 00:00:00 602 ****** ****** ***** *** ******** ****** *** 9453 0 0
08:07:02.490 -> 0 100.0 ********** *********** **** 00/00/2000 00:00:00 608 ****** ****** ***** *** ******** ****** *** 9615 0 0
08:07:03.487 -> 0 100.0 ********** *********** **** 00/00/2000 00:00:00 615 ****** ****** ***** *** ******** ****** *** 9777 0 0
08:07:04.485 -> 0 100.0 ********** *********** **** 00/00/2000 00:00:00 619 ****** ****** ***** *** ******** ****** *** 9947 0 0
08:07:05.515 -> 0 100.0 ********** *********** **** 00/00/2000 00:00:00 625 ****** ****** ***** *** ******** ****** *** 10109 0 0
08:07:06.519 -> 0 100.0 ********** *********** **** 00/00/2000 00:00:00 633 ****** ****** ***** *** ******** ****** *** 10271 0 0
08:07:07.518 -> 0 100.0 ********** *********** **** 00/00/2000 00:00:00 637 ****** ****** ***** *** ******** ****** *** 10433 0 0
08:07:08.516 -> 0 100.0 ********** *********** **** 00/00/2000 00:00:00 644 ****** ****** ***** *** ******** ****** *** 10595 0 0
08:07:09.547 -> 0 100.0 ********** *********** **** 00/00/2000 00:00:00 650 ****** ****** ***** *** ******** ****** *** 10757 0 0
08:07:10.545 -> 0 100.0 ********** *********** **** 00/00/2000 00:00:00 656 ****** ****** ***** *** ******** ****** *** 10919 0 0
08:07:11.543 -> 0 100.0 ********** *********** **** 00/00/2000 00:00:00 661 ****** ****** ***** *** ******** ****** *** 11081 0 0
08:07:12.541 -> 0 100.0 ********** *********** **** 00/00/2000 00:00:00 668 ****** ****** ***** *** ******** ****** *** 11243 0 0
08:07:13.572 -> 0 100.0 ********** *********** **** 00/00/2000 00:00:00 674 ****** ****** ***** *** ******** ****** *** 11405 0 0
08:07:14.570 -> 0 100.0 ********** *********** **** 00/00/2000 00:00:00 680 ****** ****** ***** *** ******** ****** *** 11567 0 0
08:07:15.570 -> 0 100.0 ********** *********** **** 00/00/2000 00:00:00 686 ****** ****** ***** *** ******** ****** *** 11729 0 0
08:07:16.568 -> 0 100.0 ********** *********** **** 00/00/2000 00:00:00 693 ****** ****** ***** *** ******** ****** *** 11891 0 0
08:07:17.565 -> 0 100.0 ********** *********** **** 00/00/2000 00:00:00 699 ****** ****** ***** *** ******** ****** *** 12053 0 0
08:07:18.597 -> 0 100.0 ********** *********** **** 00/00/2000 00:00:00 705 ****** ****** ***** *** ******** ****** *** 12215 0 0
08:07:19.595 -> 0 100.0 ********** *********** **** 00/00/2000 00:00:00 711 ****** ****** ***** *** ******** ****** *** 12377 0 0
08:07:20.594 -> 0 100.0 ********** *********** **** 00/00/2000 00:00:00 716 ****** ****** ***** *** ******** ****** *** 12539 0 0
08:07:21.592 -> 0 100.0 ********** *********** **** 00/00/2000 00:00:00 722 ****** ****** ***** *** ******** ****** *** 12701 0 0
08:07:22.601 -> 0 100.0 ********** *********** **** 00/00/2000 00:00:00 730 ****** ****** ***** *** ******** ****** *** 12863 0 0
08:07:23.633 -> 0 100.0 ********** *********** **** 00/00/2000 00:00:00 734 ****** ****** ***** *** ******** ****** *** 13025 0 0
08:07:24.630 -> 0 100.0 ********** *********** **** 00/00/2000 00:00:00 741 ****** ****** ***** *** ******** ****** *** 13187 0 0
08:07:25.628 -> 0 100.0 ********** *********** **** 00/00/2000 00:00:00 747 ****** ****** ***** *** ******** ****** *** 13349 0 0
08:07:26.628 -> 0 100.0 ********** *********** **** 00/00/2000 00:00:00 753 ****** ****** ***** *** ******** ****** *** 13519 0 0
08:07:27.626 -> 0 100.0 ********** *********** **** 00/00/2000 00:00:00 759 ****** ****** ***** *** ******** ****** *** 13681 0 0
08:07:28.657 -> 0 100.0 ********** *********** **** 00/00/2000 00:00:00 766 ****** ****** ***** *** ******** ****** *** 13843 0 0
08:07:29.654 -> 0 100.0 ********** *********** **** 00/00/2000 00:00:00 771 ****** ****** ***** *** ******** ****** *** 14005 0 0
08:07:30.652 -> 0 100.0 ********** *********** **** 00/00/2000 00:00:00 777 ****** ****** ***** *** ******** ****** *** 14175 0 0
08:07:31.650 -> 0 100.0 ********** *********** **** 00/00/2000 00:00:00 784 ****** ****** ***** *** ******** ****** *** 14337 0 0
08:07:32.682 -> 0 100.0 ********** *********** **** 00/00/2000 00:00:00 789 ****** ****** ***** *** ******** ****** *** 14499 0 0
08:07:33.679 -> 0 100.0 ********** *********** **** 00/00/2000 00:00:00 795 ****** ****** ***** *** ******** ****** *** 14661 0 0
08:07:34.677 -> 0 100.0 ********** *********** **** 00/00/2000 00:00:00 802 ****** ****** ***** *** ******** ****** *** 14823 0 0
08:07:35.674 -> 0 100.0 ********** *********** **** 00/00/2000 00:00:00 808 ****** ****** ***** *** ******** ****** *** 14985 0 0
08:07:36.705 -> 0 100.0 ********** *********** **** 00/00/2000 00:00:00 814 ****** ****** ***** *** ******** ****** *** 15147 0 0
08:07:37.703 -> 0 100.0 ********** *********** **** 00/00/2000 00:00:00 820 ****** ****** ***** *** ******** ****** *** 15309 0 0
08:07:38.706 -> 0 100.0 ********** *********** **** 00/00/2000 00:00:00 826 ****** ****** ***** *** ******** ****** *** 15471 0 0
08:07:39.703 -> 0 100.0 ********** *********** **** 00/00/2000 00:00:00 830 ****** ****** ***** *** ******** ****** *** 15633 0 0
08:07:40.735 -> 0 100.0 ********** *********** **** 00/00/2000 00:00:00 839 ****** ****** ***** *** ******** ****** *** 15795 0 0
08:07:41.731 -> 0 100.0 ********** *********** **** 00/00/2000 00:00:00 844 ****** ****** ***** *** ******** ****** *** 15957 0
Can anyone help me in this?