GPS not working

I am using a GY-NEO6MV2 NEO-6M and an Arduino Mega, and no matter what code I use I can't get it to say anything to the arduino wiring:

VCC -> 3.3v
GND -> GND
TX -> Pin 18
RX -> Pin 19 (I have tried swapping these)

This is the second brand new GPS and I can't seem to get it to work, I tried with a arduino Leonardo and same issue, not sure what I am doing wrong here.

Using this test code:

void setup()
{
   // Open serial communications
   Serial.begin(9600);  
   Serial1.begin(9600);
   Serial.print("Mega up");
}

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

IDE Version: 1.8.19, Windows 10 Pro (if that helps)

How are your 2 posts related ?

Please post the code that you are using to read the GPS. I assume that it has got a lock on enough satellites to provide valid data

The top one, deleted other one

Code please

Its in the first post

See

Thank you but please do not edit posts that have already been commented on when it makes nonsense of the comments already made

  1. GPS is indoors (but shouldn't I still get some data, over serial)
  2. GPS is connected incorrectly (I think so I followed many online guides)
  3. Arduino program uses the wrong GPS baud rate (double checked that)
  4. GPS or its antenna is faulty (Two brand new ones but don't seem to work)
  5. GPS is a fake (possible)
  6. Arduino program is not correct (I copied it from the website)
  7. Arduino is faulty (Tried mega and leonardo)

The Mega Serial1 pins are Tx = 18 and Rx = 19 so those are definitely the wrong way round

Please correct that before you try any other tests

Are you sure that the baud rate for the GPS is correct ?

Yes from the listing

  1. Default Baud Rate: The module is set to operate at a default baud rate of 9600, which is a common communication rate for GPS modules.

Will test other way around now

Hi, @gerald1234
Welcome to the forum.

Try 4800baud.
Have you measured the 3V3 going to the GPS?

Tom... :grinning: :+1: :coffee: :australia:

The GPS TX output is 3.3V logic, which is not guaranteed to be recognized by a 5V Arduino. And the Arduino TX output can actually damage a 3.3V sensor, unless you use logic level shifters.

It is always best to use 3.3V MCUs with 3.3V sensors.

Ok well I am getting something with the code from the first post:

$GNRMC,,V,,,,,,,,,,N,V*37
$GNGGA,,,,,,0,00,99.9,,,,,,*6F
$GNGSA,A,1,,,,,,,,,,,,,99.9,99.9,99.9,1*0A
$GNGSA,A,1,,,,,,,,,,,,,99.9,99.9,99.9,4*0F
$GPGSV,1,1,03,13,,,24,15,,,23,23,,,15,0*62
$BDGSV,1,1,00,0*74
$GNTXT,1,1,01,ANTENNA OK*2B
$GNRMC,,V,,,,,,,,,,N,V*37
$GNGGA,,,,,,0,00,99.9,,,,,,*6F
$GNGSA,A,1,,,,,,,,,,,,,99.9,99.9,99.9,1*0A
$GNGSA,A,1,,,,,,,,,,,,,99.9,99.9,99.9,4*0F
$GPGSV,1,1,03,15,,,23,17,,,24,23,,,15,0*66
$BDGSV,1,1,01,10,,,23,0*75
$GNTXT,1,1,01,ANTENNA OK*2B

But when I try and use Device Example from the tinygps++ library I just get "No GPS detected check wiring", that code is

#include <TinyGPSPlus.h>
#include <SoftwareSerial.h>
/*
   This sample sketch demonstrates the normal use of a TinyGPSPlus (TinyGPSPlus) object.
   It requires the use of SoftwareSerial, and assumes that you have a
   4800-baud serial GPS device hooked up on pins 4(rx) and 3(tx).
 */
static const int RXPin = 18, TXPin = 19;
static const uint32_t GPSBaud = 9600;

// The TinyGPSPlus object
TinyGPSPlus gps;

// The serial connection to the GPS device
SoftwareSerial ss(RXPin, TXPin);

void setup() {
	Serial.begin(115200);
	ss.begin(GPSBaud);

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

void loop() {
	// This sketch displays information every time a new sentence is correctly encoded.
	while (ss.available() > 0) {
		if (gps.encode(ss.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();
}

That looks like the sort of output you get when the GPS does not have a satellite lock. Are you testing this indoors by any chance ?

I am cause its cold and dark outside haha, but I was hoping tinygps++ would be able to read the characters and not say check wiring, cause the program freezes if the gps is not detected meaning it would need a lock before the code is run right? or am I getting confused

SoftwareSerial ss(RXPin, TXPin);

Why are you using SoftwareSerial on a Mega that has 4 hardware UARTs and making it worse by using the hardware Serial1 pins ?

You must be outside, with a clear view of the sky, to receive GPS satellite signals.

I am just used the code from the tinygps++ example, I am not great at coding arduinos haha

Use pins 18 and 19, forget SoftwareSerial and just use Serial1 to read the GPS data

Ok I retrofitted the code and I am quite proud of this,

#include <TinyGPSPlus.h>
TinyGPSPlus gps;
void setup()
{
   // Open serial communications
   Serial.begin(9600);  
   Serial1.begin(9600);

   Serial.print("Mega up");
}

void loop()
{


   while (Serial1.available()) {
     if (gps.encode(Serial1.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();
}

Hopefully this is what you meant, and I seem to be getting something out