ESP32 and NEO-6M

Hi everyone,

I'm trying to get GPS data using an ESP32 and a NEO-6M module. I connected everything as shown in the picture below (please see attachment).

After powering it on and going outside, I wait for a while. Eventually, the LED on the NEO-6M starts blinking, which (as I understand) means it has a GPS fix. However, the OLED display still shows "No Data", and I can't figure out why.

I'm really hoping someone can help me understand what might be going wrong. Any guidance would be greatly appreciated!

Thanks in advance!

#include <Wire.h>
#include <Adafruit_SSD1306.h>
#include <TinyGPS++.h>


#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels

//On ESP32: GPIO-21(SDA), GPIO-22(SCL)
#define OLED_RESET -1 //Reset pin # (or -1 if sharing Arduino reset pin)
#define SCREEN_ADDRESS 0x3C //See datasheet for Address
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

#define RXD2 16
#define TXD2 17
HardwareSerial neogps(1);

TinyGPSPlus gps;

void setup() {
  Serial.begin(115200);
  //Begin serial communication Arduino IDE (Serial Monitor)

  //Begin serial communication Neo6mGPS
  neogps.begin(9600, SERIAL_8N1, RXD2, TXD2);
  
  // SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally
  if(!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) {
    Serial.println(F("SSD1306 allocation failed"));
    for(;;); // Don't proceed, loop forever
  }

  display.clearDisplay();
  display.display();
  delay(2000);

}

void loop() {
    
  boolean newData = false;
  for (unsigned long start = millis(); millis() - start < 1000;)
  {
    while (neogps.available())
    {
      if (gps.encode(neogps.read()))
      {
        newData = true;
      }
    }
  }

  //If newData is true
  if(newData == true)
  {
    newData = false;
    Serial.println(gps.satellites.value());
    print_speed();
  }
  else
  {
    display.clearDisplay();
    display.setTextColor(SSD1306_WHITE);
    display.setCursor(0, 0);
    display.setTextSize(3);
    display.print("No Data");
    display.display();
  }  
  
}

void print_speed()
{
  display.clearDisplay();
  display.setTextColor(SSD1306_WHITE);
       
  if (gps.location.isValid() == 1)
  {
   //String gps_speed = String(gps.speed.kmph());
    display.setTextSize(1);
    
    display.setCursor(25, 5);
    display.print("Lat: ");
    display.setCursor(50, 5);
    display.print(gps.location.lat(),6);

    display.setCursor(25, 20);
    display.print("Lng: ");
    display.setCursor(50, 20);
    display.print(gps.location.lng(),6);

    display.setCursor(25, 35);
    display.print("Speed: ");
    display.setCursor(65, 35);
    display.print(gps.speed.kmph());
    
    display.setTextSize(1);
    display.setCursor(0, 50);
    display.print("SAT:");
    display.setCursor(25, 50);
    display.print(gps.satellites.value());

    display.setTextSize(1);
    display.setCursor(70, 50);
    display.print("ALT:");
    display.setCursor(95, 50);
    display.print(gps.altitude.meters(), 0);

    display.display();
    
  }
  else
  {
    display.clearDisplay();
    display.setTextColor(SSD1306_WHITE);
    display.setCursor(0, 0);
    display.setTextSize(3);
    display.print("No Data");
    display.display();
  }  

}

Try running this short program, it should copy the characters the GPS is putting out to the serial monitor, post the output for the forum to see.

#define RXD2 16
#define TXD2 17

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


void setup()
{
  Serial2.begin(9600, SERIAL_8N1, RXD2, TXD2);
  Serial.begin(115200);
  Serial.println();
  Serial.println("GPS_Echo_Hardware_Serial2 Starting");
}
12:23:59.340 -> $GPGSV,1,1,00*79
12:23:59.381 -> $GPGLL,,,,,,V,N*64
12:24:00.222 -> $GPRMC,,V,,,,,,,,,,N*53
12:24:00.254 -> $GPVTG,,,,,,,,,N*30
12:24:00.254 -> $GPGGA,,,,,,0,00,99.99,,,,,,*48
12:24:00.287 -> $GPGSA,A,1,,,,,,,,,,,,,99.99,99.99,99.99*30
12:24:00.351 -> $GPGSV,1,1,00*79
12:24:00.351 -> $GPGLL,,,,,,V,N*64
12:24:00.907 -> $GPTXT,01,01,02,u-blox ag - www.u-blox.com*50
12:24:00.972 -> $GPTXT,01,01,02,HW  UBX-G60xx  00040007 FF7FFFFFp*53
12:24:01.004 -> $GPTXT,01,01,02,ROM CORE 6.02 (36023) Oct 15 2009 16:52:08*56
12:24:01.068 -> $GPTXT,01,01,02,ANTSUPERV=AC SD PDoS SR*20
12:24:01.133 -> $GPTXT,01,01,02,ANTSTATUS=DONTKNOW*33
12:24:01.165 -> $GPRMC,,V,,,,,,,,,,N*53
12:24:01.197 -> $GPVTG,,,,,,,,,N*30
12:24:01.228 -> $GPGGA,,,,,,0,00,99.99,,,,,,*48
12:24:01.261 -> $GPGSA,A,1,,,,,,,,,,,,,99.99,99.99,99.99*30
12:24:01.293 -> $GPGSV,1,1,00*79
�$GPTXT,01,01,02,u-blox ag - www.u-blox.com*50
12:24:01.621 -> $GPTXT,01,01,02,HW  UBX-G60xx  00040007 FF7FFFFFp*53
12:24:01.685 -> $GPTXT,01,01,02,ROM CORE 6.02 (36023) Oct 15 2009 16:52:08*56
12:24:01.754 -> $GPTXT,01,01,02,ANTSUPERV=AC SD PDoS SR*20
12:24:01.782 -> $GPTXT,01,01,02,ANTSTATUS=DONTKNOW*33
12:24:01.815 -> $GPRMC,,V,,,,,,,,,,N*53
12:24:01.847 -> $GPVTG,,,,,,,,,N*30
12:24:01.879 -> $GPGGA,,,,,,0,00,99.99,,,,,,*48

That means no satellites in view.

The GPS needs to be outdoors with a good view of the sky.

Thats the GPS reporting a reset\powerup

I suspect the NEO-6M has a 3.3V regulator onboard, and would therefore need a 5V supply at Vcc, not 3.3V.

Improper powering may indeed be a problem, so check that out.

However, keep in mind that there are many reports of counterfeit or fake NEO-6M modules.
Please post a link to where you bought yours.