Hi
I bought a PMB-688 GPS receiver and an Arduino Uno. I need to get gps location coordinates to serial monitor. I connected yellow gps cable to digital pin 6, red cable to 5v, black to ground.
I used tinyGPS and SoftwareSerial library. Following is the code I used:
#include <SoftwareSerial.h>
#include "TinyGPS.h" // Special version for 1.0
TinyGPS gps;
SoftwareSerial nss(6, 255); // Yellow wire to pin 6
void setup() {
Serial.begin(9600);
nss.begin(4800);
Serial.println("Reading GPS");
}
void loop() {
bool newdata = false;
unsigned long start = millis();
while (millis() - start < 5000) { // Update every 5 seconds
if (feedgps())
newdata = true;
}
if (newdata) {
gpsdump(gps);
}
}
// Get and process GPS data
void gpsdump(TinyGPS &gps) {
float flat, flon;
unsigned long age;
gps.f_get_position(&flat, &flon, &age);
Serial.print(flat, 6); Serial.print(", ");
Serial.println(flon, 6);
}
// Feed data as it becomes available
bool feedgps() {
while (nss.available()) {
if (gps.encode(nss.read()))
return true;
}
return false;
}
When powered on, on serial monitor I saw correct latitute and longitude coordinates, but when I move the gps module, coordinates stay the same. Coordinates will be correctly updated only by power off and subsequently power on Arduino.
Does anybody knows why this could happens? Suggestions are appreciated!
Indeed, I checked the raw strings received without using tinyGPS library, and it turned out that GPRMC messages frequently overlaps with GPGGA messages, such as:
$GPRMC,143044.000$GPGGA,143045.000,4152.9430,N,01119.2805,E,2,10,0.8,50.0,M,46.8,M,1.8,0000*45
Thanks for your help!