Hi Arduino community!
I have been trying to get my Neo-6M GPS to work with my Arduino Uno for a week now. I have read just about every thread related to the Neo-6M GPS on the entire internet and I found my solution by mere accident! I am wondering if one of the genius' here can help me understand why my change to my code made it work...?
My setup is very simple. I have one of these:
And it's connected to my Arduino Uno through the following connections:
Vcc from Ublox --> 5V Pin on Uno
Rx from Ublox --> Pin 3 on Uno
Tx from Ublox --> Pin 4 on Uno
Ground from Ublox --> Ground on Uno.
And this is my very simple code...
#include <TinyGPS++.h>
#include <SoftwareSerial.h>
static const int RXPin = 4, TXPin = 3;
static const uint32_t GPSBaud = 9600;
// The TinyGPS++ object
TinyGPSPlus gps;
// The serial connection to the GPS device
SoftwareSerial ss(RXPin, TXPin);
void setup(){
Serial.begin(9600);
ss.begin(GPSBaud);
}
void loop(){
Serial.println(gps.satellites.value());
while (ss.available() > 0){
gps.encode(ss.read());
if (gps.location.isUpdated()){
Serial.print("Latitude= ");
Serial.print(gps.location.lat(), 6);
Serial.print(" Longitude= ");
Serial.println(gps.location.lng(), 6);
}
}
delay(2000)
}
I tried all week with many different ideas to get it working: I tried playing around with the GPSBaud value from 9600 to 115200 and that didn't do anything. I stood outside in my garden looking like an idiot trying to get better "signal" for my GPS and that didn't do anything too.
But in the end, it was the "delay(2000)" bit. I removed that from the code and it worked instantly. Can someone please tell me why this made it work? Did I need to store the gps.location.lng and lat to a variable and print that instead of printing direct from the output of the gps.location function?
Best wishes,
Lewis Norris