ESP32 and NEO-6M
Posted: Fri May 02, 2025 8:27 am
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!

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!

Code: Select all
#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();
}
}