Strange things to serial ports Arduino Mega2560

Hello everypne! So the problem is:
I connect GPS receiver Beitian BN-880 to arduino mega 2560 pro board (as a standart scheme TX-RX3 RX-TX3 Vcc-5V and GND). Then I write Serial3.begin(9600)... so, standart code to read data, but, When I use kind of the same code on arduino nano, everything works fine, but with Mega2560 does not work at all....

PLS help me...

#include <TinyGPSPlus.h>
TinyGPSPlus gps;
float Latitude;
float Longitude;
float Altitude;
float Speed;
float Heading;
String Indicator;
void setup() {
  Serial.begin(9600);
  Serial3.begin(9600);
  FPLNNum=0;
}

void loop() {
	while (Serial3.available() > 0)
  {
		if (gps.encode(Serial3.read()))
    {
     if (gps.location.isValid())
     {
		 Latitude = gps.location.lat();
		 Longitude = gps.location.lng();
     Altitude = gps.altitude.meters();
     Speed = gps.speed.kmph();
     Heading = gps.course.deg();
     Serial.print(Latitude, 6);
     Serial.print(" ");
     Serial.println(Longitude, 6);
		}
	}
 }
}

UPD: I tried to change Serial3 to Serial1&2 in sketch without physical reconnection. It seems, that this is my board issue. So what we have:

If we enable serial one, but the module connected to serial 3, board indicators works fine

This code is incorrect and it could not work on Nano.
With this line you are trying to extract GPS data from a single received letter, and when this obviously does not work - you do not save the received character in order to collect the complete line.

Sorry for mistake, but this code is for Mega2560. On nano I use software serial, as nano does not have more than one hardware serial port...

Problem is not solved, because I changed wires to connect module, and there is the same problem...

And yep, this string is from example of TinyGPSplusplus... The module send one string in NMEA protocole, and then library decodes it and makes calculations...

Of course the problem is not solved - because the problem is not in connections.
Your code to read the GPS data is incorrect as I wrote in #2

It is not true, look to the example more closely. To extract a GPS data from the message you need to work with a full string rather than with a single char.

I think that the problem is in connection.

Lets do it step by step:

  1. I connect power suply- 5 Volts and ground. We have TX led on module flashing, and PPS flashes too.
    2)I connect RX and TX pins. From this point TX led stops flashing, and we have no data streaming from module (even raw data streaming )...

Maybe there is some code to enable serial port number 3 on Mega2560

And, one more time, code, that uses software serial works fine! I simply change Serial3 to software serial

Ok, it is up to you.
Good luck to your project.

thnks

One more thing - there are Mega boards with swapped the labels on RX & TX pins. Try to connect RX - RX and TX-TX just for the test.

tried, but that does not help at all.

That is actually correct, the library is fed one character at a time, and stores the characters in its own buffer. When a complete, valid NMEA sentence has been received, the encode() function returns TRUE, otherwise it returns FALSE.

Please post that code even if you don't think taht you have made a significant change to it

Ok, you are right

Something to be careful of, the Beitian BN-880 information that I can find shows the Rx/Tx as 3.3V logic, that might cause problems with the Tx line from the Arduino.

If you connect only +5v, GND, and the GPS Tx > Mega Rx3, leaving the Mega Tx3 disconnected, do you see the NMEA data in the serial monitor with the following sketch?

void setup() {
  Serial.begin(9600);
  Serial3.begin(9600);
}

void loop() {
  while (Serial3.available() > 0)
  {
    Serial.write(Serial3.read());
  }
}

The examples using software serial all seem to assume this:
" It requires the use of SoftwareSerial, and assumes that you have a
4800-baud serial GPS device hooked up on pins 4(rx) and 3(tx)."

Your sketch sets Serial 3 at 9600 baud. Did you try changing

Serial3.begin(9600);

to this

Serial3.begin(4800);

?

So, without having this GPS module and assuming the variable FPLNNum is an int (I don't know what it does in your sketch), I took one of the library examples and cobbled it together with yours and came up with this. If you find it useful, happy days, if not or if it doesn't work (I can't test and troubleshoot from here), sorry.
Good luck

#include <TinyGPSPlus.h>
TinyGPSPlus gps;
float Latitude;
float Longitude;
float Altitude;
float Speed;
float Heading;
String Indicator;
int FPLNNum;

void setup() {
  Serial.begin(9600);
  Serial3.begin(4800);
  FPLNNum = 0;
}

void loop() {
  while (Serial3.available() > 0)
  {
    char myGps = Serial3.read();
    if (gps.encode(myGps))
    {
      Serial.write(myGps);
      if (gps.location.isValid())
      {
        Latitude = gps.location.lat();
        Longitude = gps.location.lng();
        Altitude = gps.altitude.meters();
        Speed = gps.speed.kmph();
        Heading = gps.course.deg();
        Serial.print(Latitude, 6);
        Serial.print(" ");
        Serial.println(Longitude, 6);
      }
    }
  }
}