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.


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(){
  Serial3.begin(4800);      //Velocidad de transmisión del GPS EM406


void loop(){
      int c = Serial3.read();
          gps.f_get_position(&Latitud, &Longitud);

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


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:

      int c = Serial3.read();


      int c = Serial3.read();

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.