NodeMCU8266 fails to detect Neo-6M GPS module

Hi Community,

I am trying to interface a Neo-6m GPS module with a NodeMCU 8266 board.
The module is connected to the NodeMCU like below:
VCC - 3.3V
GND - GND
RX - D2
TX - D1

Here's my simple code:

#include <SoftwareSerial.h>
#include <TinyGPS++.h>
#include <ESP8266WiFi.h>

const int RXPin = D2, TXPin = D1;
SoftwareSerial gps_module(RXPin, TXPin);
TinyGPSPlus gps;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  gps_module.begin(9600);
}

void loop() {
  if (gps.charsProcessed() < 10) {
    Serial.println("GPS Error");
  }
  else Serial.println("GPS Connected");

  delay(2000);

  if (gps.location.isValid()) {
    float latitude = (gps.location.lat());
    float longitude = (gps.location.lng());
 
    Serial.print("LAT:  ");
    Serial.println(latitude, 6);
    Serial.print("LONG: ");
    Serial.println(longitude, 6);
  }
}

I have tried changing the GPS module (works fine with an Arduino) and tried different GPIO pins.

No matter what I do, it still does not detect the module and always shows "GPS Error".

I am new to the hobby and still learning. Any help understanding the issue or articles that I can read through would be helpful.

Did you forget something ?

2 Likes

My apologies. This is my first post. Just edited.

Don't you need to read bytes from your software serial when they become available and then pass them into gps.encode()?

And once you fix that, then the delay(2000) might have an impact on reading the incoming bytes.

Hi Dave,

I corrected the code to like you suggested.

#include <SoftwareSerial.h>
#include <TinyGPS++.h>
#include <ESP8266WiFi.h>

const int RXPin = D2, TXPin = D1;
SoftwareSerial gps_module(RXPin, TXPin);
TinyGPSPlus gps;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  gps_module.begin(9600);

  if (gps.charsProcessed() < 10) {
    Serial.println("GPS Error");
  }
  else Serial.println("GPS Connected");
}

void loop() {
  while (gps_module.available() > 0)
  {
    if (gps.encode(gps_module.read())) 
    {
      if (gps.location.isValid()) {
        float latitude = (gps.location.lat());
        float longitude = (gps.location.lng());
 
        Serial.print("LAT:  ");
        Serial.println(latitude, 6);
        Serial.print("LONG: ");
        Serial.println(longitude, 6);
      }
    } 
  }
}

But, this thing doesn't even detect the module.

Here are the settings that I am using

Are you basing that on this?

How can the gps possibly get any characters to process by the time of this test?

1 Like

I used this piece of code in loop too and have waited several minutes and nothing happenes. I don't know what else to do.

#include <SoftwareSerial.h>
#include <TinyGPS++.h>
#include <ESP8266WiFi.h>

const int RXPin = D2, TXPin = D1;
SoftwareSerial gps_module(RXPin, TXPin);
TinyGPSPlus gps;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  gps_module.begin(9600);
  delay(10000);
  Serial.println("Serial Printing");
}

void loop() {

  while (gps_module.available() > 0)
  {
    if (gps.encode(gps_module.read())) 
    {
      if (gps.location.isValid()) {
        float latitude = (gps.location.lat());
        float longitude = (gps.location.lng());
 
        Serial.print("LAT:  ");
        Serial.println(latitude, 6);
        Serial.print("LONG: ");
        Serial.println(longitude, 6);
      }
    } 
  }
}

Am I referencing the pin numbers incorrectly?

Do you mean that you are connecting the Neo-6M's RX port to D2 and then trying to read from it? And the Software Serial TX on D1 to the Neo-6M's TX port?

RX and TX on the Neo-6M board are Input and Output from the module:

They should cross like TX->RX and RX<-TX so the output TX of the module goes to the input of Software Serial on your board, and the output TX of your board's Software Serial goes to the input of the module.

I tried this. It still doesn't enter the while loop

That means that no Software Serial is available on D2:

Is D2 connected to the TX pin of the Neo-6M module that would emit GPS data? From what you've shown, that might not be true.
Please post pictures and schematics as per:

Also, since loop() already loops, you could change the 'while' to an 'if'.

https://randomnerdtutorials.com/esp8266-nodemcu-neo-6m-gps-module-arduino/

1 Like