I have a GY-GPS6MV2 connected to a nano. (Also tried UNO same result). RX on GPS goes to TX of Nano PIN 3 and TX on GPS to PIN 4 on Nano.
When I run the code below all I get is a set of numbers. They do not appear to be hex numbers.
367180827767444486444444444444444444447842535113103671808684714444444444444444447842514813103671807171654444444444444844484844
The code I am using is
#include <SoftwareSerial.h>
String data = "";
// Define the Arduino pins for software serial communication
const int RXPin = 4;
const int TXPin = 3;
// Set the default baud rate for the NEO-6M GPS module
const int GPSBaud = 9600;
// Create a software serial object for GPS communication
SoftwareSerial gpsSerial(RXPin, TXPin);
void setup() {
// Start the hardware serial port for communication with the computer
Serial.begin(9600);
// Start the software serial port for GPS communication
gpsSerial.begin(GPSBaud);
}
void loop() {
data = "";
// Check if there is data available from the GPS module
while (gpsSerial.available()>0) {
// Read the incoming data and send it to the computer
data += gpsSerial.read();
}
// Read the incoming data and send it to the computer
Serial.println(data);
delay(30000);
}
I tried 2 different GPS modules and the result is the same. Seems that the GPS sends me data via the Arduino but not the correct data. I read about cold starts so I left the module running more than 30 hours but the result is the same. I know it may not see satellite and was expecting to see some NMEA from it even if gibberish NMEA.
What have I missed in making this work please?
,
ASCII values
3671808277674444...
is the ASCII code for"$GPRMC,,...
, so you are receiving data correctly but doing the wrong data cancatenation. When programming in C/C++, always need to aware what kind of data type you are dealing with.gpsSerial.read()
return an int, so you need to cast it to achar
before you can concatenate with a String withdata += (char) gpsSerial.read();
.