Esp32 and NEO-6m getting invalid location

Hi! I'm working with an esp32 and gps module. I dont seem to get a proper reading from the gps when Im running test.

Here is my code

#include <TinyGPS++.h>

// The TinyGPS++ object
TinyGPSPlus gps;

#define RXD2 16
#define TXD2 17

void setup(){
  Serial2.begin(9600, SERIAL_8N1,RXD2,TXD2);
  Serial.begin(115200);
  delay(500);

  Serial.println(F("DeviceExample.ino"));
  Serial.println(F("A simple demonstration of TinyGPS++ with an attached GPS module"));
  Serial.print(F("Testing TinyGPS++ library v. ")); Serial.println(TinyGPSPlus::libraryVersion());
  Serial.println();
}

void loop()
{

  // This sketch displays information every time a new sentence is correctly encoded.
  while (Serial2.available() > 0)
    if (gps.encode(Serial2.read()))
      displayInfo();

  if (millis() > 5000 && gps.charsProcessed() < 10)
  {
    Serial.println(F("No GPS detected: check wiring."));
    while(true);
  }

void displayInfo()
{
  Serial.print(F("Location: ")); 
  if (gps.location.isValid())
  {
    Serial.print(gps.location.lat(), 6);
    Serial.print(F(","));
    Serial.print(gps.location.lng(), 6);
  }
  else
  {
    Serial.print(F("INVALID"));
  }

  Serial.print(F("  Date/Time: "));
  if (gps.date.isValid())
  {
    Serial.print(gps.date.month());
    Serial.print(F("/"));
    Serial.print(gps.date.day());
    Serial.print(F("/"));
    Serial.print(gps.date.year());
  }
  else
  {
    Serial.print(F("INVALID"));
  }

  Serial.print(F(" "));
  if (gps.time.isValid())
  {
    if (gps.time.hour() < 10) Serial.print(F("0"));
    Serial.print(gps.time.hour());
    Serial.print(F(":"));
    if (gps.time.minute() < 10) Serial.print(F("0"));
    Serial.print(gps.time.minute());
    Serial.print(F(":"));
    if (gps.time.second() < 10) Serial.print(F("0"));
    Serial.print(gps.time.second());
    Serial.print(F("."));
    if (gps.time.centisecond() < 10) Serial.print(F("0"));
    Serial.print(gps.time.centisecond());
  }
  else
  {
    Serial.print(F("INVALID"));
  }

  Serial.println();
}

What do your NMEA sentences look like?

I don't get a good output a lot of ,,,,,,,,, 90 30 no real data on there.

sorry I don't have a screenshot

All those commas means there's no satellite data in the sentences. That's described as invalid.

Your sketch won't produce anything useful until the sentences are populated with satellite data.

If your aerial is working you should see some sat data, even if you don't have a great view of the sky.

do you mean my pinouts? or my board?

How may I resolve this issue?

Thank you!

I don't understand what you are referring to.

With a methodical approach and patience.

Do you have the u-center software from u-blox? That is far more useful than the TinyGPS++ example.

Here is a very simple test code that will confirm communication with the GPS unit. This is tested and works with my ESP32 devkit board.

//gps test

#define RXD2 16
#define TXD2 17

void setup()
{
   // Open serial communications
   Serial.begin(115200);
   Serial.println("Neo6M GPS module test code");
   // set the data rate for the SoftwareSerial port
   Serial2.begin(9600, SERIAL_8N1, RXD2, TXD2);
}

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

This should show something like this in serial monitor:

$GPRMC,142708.00,V,,,,,,,040522,,,N74
$GPVTG,,,,,,,,,N
30
$GPGGA,142708.00,,,,,0,03,8.60,,,,,,53
$GPGSA,A,1,27,07,09,,,,,,,,,,8.66,8.60,1.00
0C
$GPGSV,3,1,12,04,05,153,,05,07,294,14,07,67,046,27,08,38,053,72
$GPGSV,3,2,12,09,34,168,19,13,13,320,21,14,51,265,23,17,16,193,20
79
$GPGSV,3,3,12,20,05,267,,21,12,095,,27,06,036,18,30,61,335,227C
$GPGLL,,,,,142708.00,V,N
42

This GPS does not have a lock, but it is getting the time (142708.00). Actual output from my Neo6M GPS.

I do not have the software u-center since I am using a mac. I can use my virtual environment and install u-center, but Im not sure which to download, and I also have a ublox NEO-6m which I wasn't able to find on their site.

Hi, I tested the code you provided and this is the output I get.

Well done. Now you're in a position to monitor the actual data coming out of the GPS module.

The thing about the TinyGPS++ examples is that they are not a good starting point to learn and understand GPS.

You now need to focus on your reception. A photo of your setup would be useful.

OK, the GPS is talking to the ESP32 but does not have a lock.

Is the GPS outdoors with a clear view of the sky (no trees or heavy clouds)?

What version of the TinyGPS++ library are you using? There is a TinyGPSPlus-ESP32 version in the IDE library manager.

The gps is indoors but I have it near the window I will be posting a picture of it above.

I have TinyGPSPlus 1.0.3 by Mikal Hart installed.

This is a picture of what I currently have.

What are those shutters made of? What is above you?

Your GPS does not seem to be picking up any satellites. If it were picking up any satellites, you should, at least, see the time in the $GPRMC sentence. I think you need to get the GPS outside with a clear view of the sky to see if it will work. If it still won't start to get a lock, after a few minutes, there may be a problem with the antenna or GPS unit.

@groundFungus In front of me is a building. I then decided to go to my roof top and was able to get data readings at first I got this:

I then re-upload a code with readable location and I got this:
92DC2063-156E-4B5D-9B0D-ADDE1A539BCC

had to cover some of the data points.

Does that mean that the gps doesn't work well indoors? and is there any other gps that works well in/outdoors?

All right. Looks like it is working.

Yes. The signals from the GPS satellites are very weak. They do not penetrate much at all.

None that I know of, but my experience is limited.

What are you wanting to do? Perhaps there are other ways to do it.

I think the indoor gps tracking system might be something that's not possible.

I want to use LoRa to send gps data to a rpi that connects to an app. I haven't been able to get the esp32 to send data to the rpi yet.

"esp32 rssi indoor tracking" might be some words that could be searched on.

Hi @Idahowalker for the LoRa connection between a Heltec LoRa32 and a RPi Dragino LoRa Hat?

Congrats on getting it going. Thanks for the pic -- it definitely helped.

That type of antenna needs care. I've ruined quite a few. The cable connection to the antenna itself is not at all strong. If left dangling sooner or later it will snag on something and break clean off.

I don't know the recommended way to attach it to the GPS board, if that is the design intent. It can be soldered to those metal pads but that isn't easy to do. I've used rubber bands, elec tape and stiif wire looped thru the corner holes on each board.

1 Like