unable to get data

Hi guys,

I am using Arduino Uno,
GPS Breakout v3 from Adafruit, Tx to Rx and Rx to Tx,
on pin 0 1 (i don't want to use SoftwareSerial.h)
I do have fix on GPS, as the GPS blinks once every 15 sec.
Currently I am unable to get a reading, and Can't figure out why.

#include <TinyGPS++.h> 

TinyGPSPlus gps;


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

void loop() { 
   
while (Serial.available() > 0)
gps.encode(Serial.read());

unsigned long currentMillis = millis();
Serial.println(currentMillis);

Serial.println(gps.location.lat());

 }

Have you the GPS GND connected to the Arduino GND?

...R

Robin2:
Have you the GPS GND connected to the Arduino GND?

...R

Yes. GPS is powered from the Arduino.

How are you powering the UNO? If you still have the USB cable connected, it will interfere with the GPS since they are both trying to to do Serial I/O on the same pins.

Pete

P.S. this is usually why people use SoftwareSerial on the UNO and similar Arduinos.

Pete

Does gps.encode(...) ever return true?

Certainly you should not display latitude or longitude until it does. The code shown displays latitude on every pass through the loop() function, which could be thousands of times a second. It also shows the time from the millis() function on every pass through the loop() function.

What characters are you receiving from the GPS module? They should get displayed so that you know that the module is working and that it is properly connected to the Arduino.

(Yes, I know that the loop() function is slowed down by all of the printing that is going on. THAT is not the point!)

I have added

if (millis() > 5000 && gps.charsProcessed() < 10) // uh oh
{
  Serial.println("ERROR: not getting any GPS data!");
}

and in need i am not getting any GPS data.
The strange thing is, GPS is still blinking at every 15 seconds !, it seems there is a hardware problem.

You didn't reply to post #3.
It is hard to help if we don't know what you are up to.
Dwight

el_supremo:
How are you powering the UNO? If you still have the USB cable connected, it will interfere with the GPS since they are both trying to to do Serial I/O on the same pins.

Pete

i powered it with USB and later with a battery.
I have changed to Mega, to escape the problem you mentioned. still getting the same problem.

The GPS breakout v3 is not getting a fix, although it used to work without an issue.
and when it starts to blink for once every 15 seconds , still there is no fix !

d20237 wrote (in part):

still there is no fix

Why do you think this?

If the GPS is blinking once every 15 seconds, it has a fix.

I have changed to Mega,

What changes did you make to the code?

Pete

There is a diagnostic program in my GPS library, NeoGPS. It will try various baud rates to try and detect your GPS module.

Or, you could try this modified simple blink example that uses Serial for the GPS, and blinks the LED on pin 13 when new fix data is received, usually once per second:

#include <Arduino.h>
#include "NMEAGPS.h"

NMEAGPS          gps;
const int        led      = 13;
HardwareSerial & gps_port = Serial; // or Serial1, 2 or 3 on a Mega

//--------------------------

void setup()
{
  gps_port.begin(9600);

  pinMode(led, OUTPUT);
}

//--------------------------

void loop()
{
  while (gps_port.available()) {

    if (gps.decode( gps_port.read() ) == NMEAGPS::DECODE_COMPLETED) {

      if (gps.nmeaMessage == NMEAGPS::NMEA_RMC)
        digitalWrite( led, !digitalRead(led) ); // toggle the LED
    }
  }
}

NeoGPS is smaller and faster than other libraries, and the examples are correctly structured. Many examples from other libraries (including yours) will break when they are modified. The sketch in your original post cannot possibly work. The Troubleshooting page describes many of the common problems. On a Mega, all the NeoGPS examples will the GPS to be on Serial1, but you can change that like I did above.

If you decide to try it, be sure to follow the Installation instructions. The NeoGPS files should be copied to your sketch directory, not into a Libraries subdirectory.

Cheers,
/dev

/dev:
There is a diagnostic program in my GPS library, NeoGPS. It will try various baud rates to try and detect your GPS module.

Or, you could try this modified simple blink example that uses Serial for the GPS, and blinks the LED on pin 13 when new fix data is received, usually once per second:

#include <Arduino.h>

#include "NMEAGPS.h"

NMEAGPS          gps;
const int        led      = 13;
HardwareSerial & gps_port = Serial; // or Serial1, 2 or 3 on a Mega

//--------------------------

void setup()
{
  gps_port.begin(9600);

pinMode(led, OUTPUT);
}

//--------------------------

void loop()
{
  while (gps_port.available()) {

if (gps.decode( gps_port.read() ) == NMEAGPS::DECODE_COMPLETED) {

if (gps.nmeaMessage == NMEAGPS::NMEA_RMC)
        digitalWrite( led, !digitalRead(led) ); // toggle the LED
    }
  }
}



NeoGPS is smaller and faster than other libraries, and the examples are correctly structured. Many examples from other libraries (including yours) will break when they are modified. The sketch in your original post cannot possibly work. The [Troubleshooting](https://github.com/SlashDevin/NeoGPS/blob/master/doc/Troubleshooting.md) page describes many of the common problems. On a Mega, all the NeoGPS examples will the GPS to be on Serial1, but you can change that like I did above.

If you decide to try it, be sure to follow the [Installation](https://github.com/SlashDevin/NeoGPS/blob/master/doc/Installing.md) instructions. The NeoGPS files should be copied to your sketch directory, **not** into a Libraries subdirectory.

Cheers,
/dev

Thanks for the reply.
i have run the NMEAdiagnostic.INO; Please note that GPS is blinking once every 15 sec, meaning there is fix.
Rx to Tx and Tx to Rx.

NMEAdiagnostic.INO: started
Looking for GPS device on Serial1


Checking 9600 baud...

Check GPS device and/or connections. No data received.

** NMEAdiagnostic completed **

1 errors

After changing the serial from Tx14 RX15 to TX16 and Rx17 , it started to read again !
I am not sure why it failed to read from the port that It used to read before. any ideas ??

After changing the serial from Tx14 RX15 to TX16 and Rx17 , it started to read again !
I am not sure why it failed to read from the port that It used to read before. any ideas ??

Looking for GPS device on Serial1

Well, you said you were on an UNO, but the diagnostic program will only try Serial1 if it's on a Mega. Trying to use Serial1 won't even compile on an UNO. Trying pins 14 and 15 also implies Serial3 on a Mega. Similarly, pins 16 and 17 are Serial2. I'm totally confused.

/dev:
Well, you said you were on an UNO, but the diagnostic program will only try Serial1 if it's on a Mega. Trying to use Serial1 won't even compile on an UNO. Trying pins 14 and 15 also implies Serial3 on a Mega. Similarly, pins 16 and 17 are Serial2. I'm totally confused.

ِApologies for not being clear about all steps. I have skipped explaining few while trying to understand whats going on. To focus on the problem, Lets start with Mega.

Mega powered by Battery, Connected to USB to PC.
GPS breakout from Adafruit , connected to Mega 5v, and Ground to Mega.
The TX to Rx and Rx to Tx.

As mega has many RX and TX, when i connect to RX15 TX14 , it can't read the GPS data (in the past it used to work well), However, If i change to RX 17 TX 16 , it works perfectly.

/dev:
There is a diagnostic program in my GPS library, NeoGPS. It will try various baud rates to try and detect your GPS module.

That's good advice. If demo code or - in this case - a dignostic runs just fine, then the problem is not hardware.

Well, this is a 3.3V GPS module so the GPS TX line is specified to output 2.4V to 2.8V. The Arduinos are specified to require 3.5V for a logic one. Although many people say that it works without level shifting, maybe your GPS runs a little low and/or your Arduino really needs 3.5V.

Have you tried a simple echo test from Serial2 to Serial3? Something like:

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

void loop()
{
  if (Serial.available())
    Serial2.write( Serial.read() );

  if (Serial3.available())
    Serial.write( Serial3.read() );
}

Then connect pin 16 (TX2) to 15 (RX3). If you can type things on the Serial Monitor and they are echoed back ok, then you know that Serial3 can receive. This would imply that the GPS TX voltage is not be high enough for the Arduino.

If it doesn't echo, pin 15 might be fried. To make sure TX2 is not fried, connect pin 18 (TX1) to 15 (RX3) and change the sketch to match:

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

void loop()
{
 if (Serial.available())
    Serial1.write( Serial.read() );

  if (Serial3.available())
    Serial.write( Serial3.read() );
}

You could also try pin 0 (RX0) to 15, with this change:

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

void loop()
{
//  if (Serial.available())
//    Serial2.write( Serial.read() );

  if (Serial3.available())
    Serial.write( Serial3.read() );
}

This is all to see if the pins are damaged or if the GPS TX is too low.

Cheers,
/dev

/dev:
Well, this is a 3.3V GPS module so the GPS TX line is specified to output 2.4V to 2.8V. The Arduinos are specified to require 3.5V for a logic one. Although many people say that it works without level shifting, maybe your GPS runs a little low and/or your Arduino really needs 3.5V.

Have you tried a simple echo test from Serial2 to Serial3? Something like:

void setup()

{
  Serial.begin( 9600 );
  Serial2.begin( 9600 );
  Serial3.begin( 9600 );
}

void loop()
{
  if (Serial.available())
    Serial2.write( Serial.read() );

if (Serial3.available())
    Serial.write( Serial3.read() );
}



Then connect pin 16 (TX2) to 15 (RX3). If you can type things on the Serial Monitor and they are echoed back ok, then you know that Serial3 can receive. This would imply that the GPS TX voltage is not be high enough for the Arduino.

If it doesn't echo, pin 15 might be fried. To make sure TX2 is not fried, connect pin 18 (TX1) to 15 (RX3) and change the sketch to match:



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

void loop()
{
if (Serial.available())
    Serial1.write( Serial.read() );

if (Serial3.available())
    Serial.write( Serial3.read() );
}



You could also try pin 0 (RX0) to 15, with this change:



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

void loop()
{
//  if (Serial.available())
//    Serial2.write( Serial.read() );

if (Serial3.available())
    Serial.write( Serial3.read() );
}



This is all to see if the pins are damaged or if the GPS TX is too low.

Cheers,
/dev

Thanks alot. I have run the sketch.
I have found that all RX and TX are working today !

Maybe you should try NMEAdiagnostic again, with some changes: delete lines 22-35 and replace them with this:

    HardwareSerial & gps_port = Serial2;

You'll also have to change line 118 to this:

    DEBUG_PORT.println( F("Looking for GPS device on Serial2") );

If that doesn't work, rebuild it and try it on Serial3. If that works, I think that points to the GPS TX pin voltage level. The best solution would be a level-shifting module, but do you have a few resistors, 1k and 4.7k? Maybe a diode?

Cheers,
/dev