Problem with my GPS module NEO-6m

Hello everyone !

I write this new subject because I have a very specific problem with my GPS module “NEO-6M GY-GPS6MV2”.

I started to use this module to get a GPS positon thanks to the RX0 and TX0 pin of my mega2560. After 15 or 20min, i get a GPGLL position (I upload no code on my mega2560 to get this position).

But now, I want to use this code that I found on the internet :

#include <SoftwareSerial.h>

// setup gps serial
int gpsTxPin = 8;
int gpsRxPin = 9;
SoftwareSerial gpsSerial(gpsTxPin, gpsRxPin);

void setup()
{
  Serial.begin(9600);  //set monitor to 9600
 
  gpsSerial.begin(9600); //adjust for GPS unit

  Serial.println("Ready!");
}

void loop()
{
  while(gpsSerial.available())
  {
    char c = gpsSerial.read();
    Serial.print(c);
  }
}

But “gpsSerial.available()” always return 0 and I really don’t know why. I do a lot of research on the Internet, verify my wire a multiple of time, connect the VCC pin to the 3,3V of my mega2560 and GND pin of my mega2560 with no success. I don’t know why the GPS work with no code on pin RX0 and TX0 but doesn’t work on my pin 8 and 9 with SoftwareSerial.

Please if you know what is the problem answer me :slight_smile:

Why in the world would you want to use software serial on a Mega that has 3 extra hardware serial ports?

SoftwareSerial gpsSerial(gpsTxPin, gpsRxPin);

The syntax for the software serial constructor is

SoftwareSerial mySerial(RX, TX);

The first parameter is always RX, no matter what name you give it. So which Mega pin is the GPS TX pin connected?

Try this code that uses Serial1 instead of software serial. Tested on my Mega with NEO6M on Serial1 (pin 19 = RX1) GPS RX not connected nor necessary.

//gps test
// connect GPS TX to Mega pin 19 (RX1).  GPS RX not connected.

void setup()
{
   // Open serial communications
   Serial.begin(9600);  
   Serial1.begin(9600);
   Serial.print("Mega up");
}

void loop()
{
   if (Serial1.available())
   {
      Serial.print(char(Serial1.read()));
   }
}

Good evening groundFungus !

Thank you for your quick answer. I’ll do the modification when I’ll be back home and give you some news as soon as i can.

Donel:
int gpsTxPin = 8;
int gpsRxPin = 9;
SoftwareSerial gpsSerial(gpsTxPin, gpsRxPin);

But "gpsSerial.available()" always return 0 and I really don't know why. I do a lot of research on the Internet

I don't know why the GPS work with no code on pin RX0 and TX0 but doesn't work on my pin 8 and 9 with SoftwareSerial.

Always worth checking the documentation.

So softwareserial is not working on the ATmega, so check the reference, found by a Google search on 'Arduino softwareserial reference' ;

https://www.arduino.cc/en/Reference/softwareSerial

And you will clearly see that softwareserial (receive) will not work on pin 9 on a Mega ...........

But as mentioned, why use softwareserial on the Mega in the first place.

Hi and thank you both for your return.

Indeed, I'm a beginner in arduino programmation and I didn't realize that I have a lot of communication pin on my mega2560 (the example that I saw was with an arduino uno). My bad :frowning:

Now I have a lot of NMEA sentences, but do you know how long it takes to have a full correct position ? For the moment I have a lot of sentences but they didn't gave me a postion ( I have a lot of blink inside the sentences).

Thank you very much for your attention

Is the GPS outdoors with a clear view of the sky? if not, it is unlikely to get a fix. Mine will get a fix in my home office. The GPS is by a window and my house is one story wood framed and it will take 15 to 30 minutes to get a good fix if I haven’t used it in a few weeks.

Donel:
Now I have a lot of NMEA sentences, but do you know how long it takes to have a full correct position ?

If the GPS is outdoors, with a good view of the sky, then if its working correctly, it should get a fix in 45 to 60 seconds.

Thats from cold, new and direct out of the factory.

If it takes longer the GPS or its antenna are faulty.