EM406 providing strange readings

Hello, I am using a GPS shield with an arduino Mega2560, not mounted on the board because it doesn’t fit completely, but wired to the power (5V, 3.3V and GND), and the pin2 connected to the pin15 (RX3) of the Mega2560 with the UART/DLINE switch set to DLINE(indifferently, when I connect it to the RX pin and set it to UART it still gives me the strange readings).

I am using the TinyGPS library, but the encode function does not work, and trying to figure out what was happening, I printed the readings directly from the port, noticing that mine are way differente from the ones I have found in more than one site. Like the ones shown here.

I assume that the encode function doesn’t work because it does not “understand” the readings it is getting from the port. You can see them in the attached image.

Any idea why is this happening and how can I solve it? Or is the module just not working?

Thanks in advance.

Serial.println(Serial3.read());

There are two errors in this line. Number one: you use print() to write the read character which will print it's ASCII representation and not the character itself (so if the GPS sends a space, it prints 32). Number two: the Serial3.read() consumes the character, so the next Serial3.read() will return the character after the one you printed to the debugging serial port.

Post your sketch within code tags and don't just attach a screen shot. Additionally you should provide links to the hardware you used and to all libraries not included in the standard IDE.

Thank you very much pylon.

Using Serial.Write did print the reading that I have found online.

#include <TinyGPS.h>

TinyGPS gps;
float Latitud;
float Longitud;

void setup(){
  
  Serial.begin(9600);
  Serial3.begin(4800);      //Velocidad de transmisión del GPS EM406
  Serial3.flush();
  delay(500);

}


void loop(){
  
  while(Serial3.available()){
      Serial.write(Serial3.read());
      int c = Serial3.read();
      if(gps.encode(c)){
          Serial.println("encode");
          gps.f_get_position(&Latitud, &Longitud);
          Serial.println(Latitud,5);
          Serial.print(Longitud,5);
      }
  }
  
}

Here you can see the library usage, I almost have a copy - paste in there. and the encode function is still not working.

http://arduiniana.org/libraries/tinygps/

I am attaching the readings, but now after “writing” them, instead of “printing” them.

I am also trying to print the word “encode” to see if the program goes into the “if”, but it doesn’t

It seems you didn't understand my explanations.

Exchange these lines:

      Serial.write(Serial3.read());
      int c = Serial3.read();
      if(gps.encode(c)){

by:

      int c = Serial3.read();
      Serial.write(c);
      if(gps.encode(c)){

and encode() probably starts to work.

You're right pylon, excuse me for that, I should have seen it. Thank you very much, Now it is working correctly.