Unable to read gps coordinates from Neo-6m gps module

Hi Team,
I am trying to read GPS coordinates from Neo-6M gps module. Tried executing multiple examples from Arduino libraries like FuGPS, TinyGPS++, NeoGPS, Neo6MGPS, NMEA Parsers etc. Program compiles and flashes successfully but serial monitor shows nothing.

Any suggestions please…!

Is the GPS outdoors with a good view of the sky ?

The simple program below will copy the GPS output to the serial monitor.

It assumes the GPS is on hardware serial port Serial1, adjust as necessary for your setup;

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

void setup()
{
  Serial1.begin(9600);
  Serial.begin(115200);
  Serial.println();
  Serial.println("GPS_Echo_Hardware_Serial Starting");
}

its been a while, but i know there is something to o with hardware and software serial… the ESP32 uses the opposite of the other boards

I have a demo on here of the GPS with AIR530 and Xiao ESP32C3
here is the code from that thread.

#include <Arduino.h>
#include <U8x8lib.h>
#include <Wire.h>

#include <TinyGPSPlus.h>
static const int RXPin = 6, TXPin = 7;          // 6, 7
static const uint32_t GPSBaud = 9600;
//TinyGPSPlus object
TinyGPSPlus gps;
//Display object
U8X8_SSD1306_128X64_NONAME_HW_I2C u8x8(/* clock=*/ PIN_WIRE_SCL, /* data=*/ PIN_WIRE_SDA, /* reset=*/ U8X8_PIN_NONE);   // OLEDs without Reset of the Display
const int pinLed = LED_BUILTIN;
float __longitude = 0;      
float __latitude  = 0;
const int ledPin = LED_BUILTIN;
int BuzzerPin = A3;                 //A3 , P0.29 PIN 4
int buzzer = BuzzerPin;

void setup(void) {
    u8x8.begin();
    u8x8.setFlipMode(1);   // set number from 1 to 3, the screen word will rotary 180
    Serial1.begin(GPSBaud);
    Serial.begin(9600);
    delay(2000);                       //relax...Get Ready for serial port
    Serial.println("Test program" __FILE__ " compiled on " __DATE__ " at " __TIME__);
    Serial.println();
    Serial.println("Processor came out of reset.");
    
   initdisplay();
   setupblink();  
}

void loop(void) {
    
    dispGPS();

    while (Serial1.available() > 0)
    if (gps.encode(Serial1.read()))
    {
        __latitude  = gps.location.lat();
        __longitude = gps.location.lng(); 
    }
}


void dispGPS()
{
       //Serial.println("getting gps");

    u8x8.setCursor(0, 0);
    u8x8.print("GPS LOCATION   ");
    u8x8.setCursor(0, 3);
    u8x8.print(__latitude, 6);
    u8x8.setCursor(0, 5);
    u8x8.print(__longitude, 6);  
}


void setupblink(){
  setLedRGB(false, false, true);  // set Blue LED 
    delay(1000);
    setLedRGB(false, true, false);  // Red
    delay(1000);
    setLedRGB(true, false, false);  // Green
    delay(1000);
    setLedRGB(false, false, false);  // OFF
}  

void initdisplay() {
 pinMode(LEDR, OUTPUT);         // initialize the LED pin as an output:
 pinMode(LEDG, OUTPUT);         // initialize the LED pin as an output:
 pinMode(LEDB, OUTPUT);
 pinMode(LED_BUILTIN, OUTPUT);      // initialize the LED pin as an output:
  u8x8.begin();
    u8x8.setFlipMode(1);   // set number from 1 to 3, the screen word will rotary 180
    u8x8.setFont(u8x8_font_8x13B_1x2_r);
    u8x8.clearDisplay();
    u8x8.setCursor(0, 0);
    u8x8.print("Power ON ");
}

void startsound() {
  tone (buzzer, 890);
    delay (220);
    noTone(buzzer);
    delay (20);
    tone (buzzer, 800);
    delay (220);
    noTone(buzzer);
    delay (20);
    tone (buzzer, 800);
    delay (220);
    noTone(buzzer);
    delay (20);
    tone (buzzer, 990);
    delay (420);
    noTone(buzzer);
    delay (20);
}

void setLedRGB(bool red, bool green, bool blue) {
   if (!red) { digitalWrite(LEDR, HIGH); } else { digitalWrite(LEDR, LOW); }
   if (!green) { digitalWrite(LEDG, HIGH); } else { digitalWrite(LEDG, LOW); }
   if (!blue) { digitalWrite(LEDB, HIGH); } else { digitalWrite(LEDB, LOW); }
}
// END

HTH
GL :slight_smile: PJ :v:

2 Likes

There are issues with software serial for sure.

Avoid doing other stuff such as Serial prints, writing to displays or using other devices if software serial is running.

Best to avoid using software serial if you can.

Hi @StuartsProjects ,
I tried your suggestion but getting junk values whether NEO-6M is connected or not.
But at least I am seeing something rather.

Regards
Bala

Hi @PJ_Glasso ,

can I try this code work on any gps module…!

So what are you seeing ?

If your GPS is on Serial1, run this code to see what output the GPS is actually producing;

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

void setup()
{
  Serial1.begin(9600);
  Serial.begin(115200);
  Serial.println();
  Serial.println("GPS_Echo_Hardware_Serial Starting");
}

Works on any GPS module, assuming its on port Serial1 and its baud rate is 9600.

Hi there,
I think it would. Neo-6M is compatible with the Serial port, but default baud rate and data AFAIK is deferent defaults. Be sure it’s set correctly.
HTH
GL :slight_smile: PJ :v:

check and make sure you dont have tx and rx reversed

have you tried the direct connect , and download Ublox, like the demo I posted with Air530 GPS, same thing should work according to this info on sales page.

About this item

  • How to use the GPS module better, the link is obtained in the Product guides and documents, please download it before use
  • Note: Please use the GT-U7 GPS module in an open place, the LED will flash after the satellite signal is found. Bad weather and indoor use will affect the accuracy of positioning
  • GPS baud needs to be set to 9600 instead of 4800; PPS pin is not needed unless using the GPS to drive a hardware high precision clock; GT-U7 main module GPS module using the original UBLOX 7th generation chip, Software is compatible with NEO-6M. GT-U7 module, with high sensitivity, low power consumption, miniaturization, its extremely high tracking sensitivity greatly expanded its positioning of the coverage
  • With a USB interface, you can directly use the phone data cable on the computer point of view positioning effect; With IPEX antenna interface, the default distribution of active antenna, can be quickly positioned
  • USB directly connected to the computer, That is, with the host computer-owned serial port function, no need for external serial module, send IPX interface active antenna

HTH
GL :slight_smile: PJ

Thank you all for the support. I am able to read gps coordinates now.

1 Like

thanks for letting us know!

Can you say what fixed your problem ?

One of the issue might be power supply. I changed the battery.
Second thing is that I changed the baudrate to 9600, missed it somehow all the time before.

2 Likes