# GPS not working

**URL:** <https://forum.arduino.cc/t/gps-not-working/1158571>\
**Category:** Networking, Protocols, and Devices\
**Created:** [August 15, 2023, 8:42pm UTC](https://forum.arduino.cc/t/gps-not-working/1158571 "2023-08-15T20:42:07Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![gerald1234](https://avatars.discourse-cdn.com/v4/letter/g/96bed5/32.png) [@gerald1234](https://forum.arduino.cc/u/gerald1234)\
**Post date:** [August 15, 2023, 8:42pm UTC](https://forum.arduino.cc/t/gps-not-working/1158571/1 "2023-08-15T20:42:07Z")

</div>

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:

```arduino
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)

---

<div class="post-metadata">

**Author:** ![UKHeliBob](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/ukhelibob/32/215663_2.png) [@UKHeliBob](https://forum.arduino.cc/u/UKHeliBob)\
**Post date:** [August 15, 2023, 8:46pm UTC](https://forum.arduino.cc/t/gps-not-working/1158571/3 "2023-08-15T20:46:06Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![gerald1234](https://avatars.discourse-cdn.com/v4/letter/g/96bed5/32.png) [@gerald1234](https://forum.arduino.cc/u/gerald1234)\
**Post date:** [August 15, 2023, 8:46pm UTC](https://forum.arduino.cc/t/gps-not-working/1158571/4 "2023-08-15T20:46:59Z")

</div>

The top one, deleted other one

---

<div class="post-metadata">

**Author:** ![UKHeliBob](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/ukhelibob/32/215663_2.png) [@UKHeliBob](https://forum.arduino.cc/u/UKHeliBob)\
**Post date:** [August 15, 2023, 8:47pm UTC](https://forum.arduino.cc/t/gps-not-working/1158571/5 "2023-08-15T20:47:39Z")

</div>

Code please

---

<div class="post-metadata">

**Author:** ![gerald1234](https://avatars.discourse-cdn.com/v4/letter/g/96bed5/32.png) [@gerald1234](https://forum.arduino.cc/u/gerald1234)\
**Post date:** [August 15, 2023, 8:48pm UTC](https://forum.arduino.cc/t/gps-not-working/1158571/6 "2023-08-15T20:48:23Z")

</div>

Its in the first post

---

<div class="post-metadata">

**Author:** ![anon94801460](https://avatars.discourse-cdn.com/v4/letter/a/278dde/32.png) [@anon94801460](https://forum.arduino.cc/u/anon94801460)\
**Post date:** [August 15, 2023, 8:50pm UTC](https://forum.arduino.cc/t/gps-not-working/1158571/7 "2023-08-15T20:50:55Z")

</div>

See

> **[My GPS does not work](https://stuartsprojects.github.io/2018/10/01/My-GPS-does-not-work.html)**
>
> On public forums, such as Arduino, I see a great many posts along the lines of ‘My GPS does not work’. Most often constructors connect a GPS to an Arduino on their bench indoors, load up a complete application and find it does not work in that there...

---

<div class="post-metadata">

**Author:** ![UKHeliBob](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/ukhelibob/32/215663_2.png) [@UKHeliBob](https://forum.arduino.cc/u/UKHeliBob)\
**Post date:** [August 15, 2023, 8:53pm UTC](https://forum.arduino.cc/t/gps-not-working/1158571/8 "2023-08-15T20:53:20Z")

</div>

> [@gerald1234](#):
>
> Its in the first post

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

---

<div class="post-metadata">

**Author:** ![gerald1234](https://avatars.discourse-cdn.com/v4/letter/g/96bed5/32.png) [@gerald1234](https://forum.arduino.cc/u/gerald1234)\
**Post date:** [August 15, 2023, 8:56pm UTC](https://forum.arduino.cc/t/gps-not-working/1158571/9 "2023-08-15T20:56:52Z")

</div>

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)

---

<div class="post-metadata">

**Author:** ![UKHeliBob](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/ukhelibob/32/215663_2.png) [@UKHeliBob](https://forum.arduino.cc/u/UKHeliBob)\
**Post date:** [August 15, 2023, 8:58pm UTC](https://forum.arduino.cc/t/gps-not-working/1158571/10 "2023-08-15T20:58:00Z")

</div>

> [@gerald1234](#):
>
> TX -\> Pin 18  
> RX -\> Pin 19 (I have tried swapping these)

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 ?

---

<div class="post-metadata">

**Author:** ![gerald1234](https://avatars.discourse-cdn.com/v4/letter/g/96bed5/32.png) [@gerald1234](https://forum.arduino.cc/u/gerald1234)\
**Post date:** [August 15, 2023, 8:59pm UTC](https://forum.arduino.cc/t/gps-not-working/1158571/11 "2023-08-15T20:59:14Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![TomGeorge](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/tomgeorge/32/215261_2.png) [@TomGeorge](https://forum.arduino.cc/u/TomGeorge)\
**Post date:** [August 15, 2023, 9:00pm UTC](https://forum.arduino.cc/t/gps-not-working/1158571/12 "2023-08-15T21:00:36Z")

</div>

Hi, @gerald1234  
Welcome to the forum.

> [@gerald1234](#):
>
> Will test other way around now

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

Tom... 😀 👍 ☕ 🇦🇺

---

<div class="post-metadata">

**Author:** ![anon94801460](https://avatars.discourse-cdn.com/v4/letter/a/278dde/32.png) [@anon94801460](https://forum.arduino.cc/u/anon94801460)\
**Post date:** [August 15, 2023, 9:06pm UTC](https://forum.arduino.cc/t/gps-not-working/1158571/13 "2023-08-15T21:06:45Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![gerald1234](https://avatars.discourse-cdn.com/v4/letter/g/96bed5/32.png) [@gerald1234](https://forum.arduino.cc/u/gerald1234)\
**Post date:** [August 15, 2023, 9:07pm UTC](https://forum.arduino.cc/t/gps-not-working/1158571/14 "2023-08-15T21:07:04Z")

</div>

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

```arduino
$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

```arduino
#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();
}

```

---

<div class="post-metadata">

**Author:** ![UKHeliBob](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/ukhelibob/32/215663_2.png) [@UKHeliBob](https://forum.arduino.cc/u/UKHeliBob)\
**Post date:** [August 15, 2023, 9:08pm UTC](https://forum.arduino.cc/t/gps-not-working/1158571/15 "2023-08-15T21:08:32Z")

</div>

> [@gerald1234](#):
>
> I am getting something with the code from the first post:

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 ?

---

<div class="post-metadata">

**Author:** ![gerald1234](https://avatars.discourse-cdn.com/v4/letter/g/96bed5/32.png) [@gerald1234](https://forum.arduino.cc/u/gerald1234)\
**Post date:** [August 15, 2023, 9:10pm UTC](https://forum.arduino.cc/t/gps-not-working/1158571/16 "2023-08-15T21:10:01Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![UKHeliBob](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/ukhelibob/32/215663_2.png) [@UKHeliBob](https://forum.arduino.cc/u/UKHeliBob)\
**Post date:** [August 15, 2023, 9:10pm UTC](https://forum.arduino.cc/t/gps-not-working/1158571/17 "2023-08-15T21:10:32Z")

</div>

```arduino
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 ?

---

<div class="post-metadata">

**Author:** ![anon94801460](https://avatars.discourse-cdn.com/v4/letter/a/278dde/32.png) [@anon94801460](https://forum.arduino.cc/u/anon94801460)\
**Post date:** [August 15, 2023, 9:10pm UTC](https://forum.arduino.cc/t/gps-not-working/1158571/18 "2023-08-15T21:10:59Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![gerald1234](https://avatars.discourse-cdn.com/v4/letter/g/96bed5/32.png) [@gerald1234](https://forum.arduino.cc/u/gerald1234)\
**Post date:** [August 15, 2023, 9:11pm UTC](https://forum.arduino.cc/t/gps-not-working/1158571/19 "2023-08-15T21:11:05Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![UKHeliBob](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/ukhelibob/32/215663_2.png) [@UKHeliBob](https://forum.arduino.cc/u/UKHeliBob)\
**Post date:** [August 15, 2023, 9:12pm UTC](https://forum.arduino.cc/t/gps-not-working/1158571/20 "2023-08-15T21:12:08Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![gerald1234](https://avatars.discourse-cdn.com/v4/letter/g/96bed5/32.png) [@gerald1234](https://forum.arduino.cc/u/gerald1234)\
**Post date:** [August 15, 2023, 9:13pm UTC](https://forum.arduino.cc/t/gps-not-working/1158571/21 "2023-08-15T21:13:31Z")

</div>

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

```arduino
#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

[Next page](https://forum.arduino.cc/t/gps-not-working/1158571.md?page=2)
