I’m connecting a GPS (MTK3339) to the second serial port. For the most part it works, but I’ve noticed I had a high error rate on GPS updates. I’ve ditched all libraries and reduced everything to a simple read loop (see on the bottom). It seems that there are number of characters getting missed or injected. For eg:
00K$GPGGA,211115.084,,,,,0,00,,,M,,M,,*73
$GPRMC,211118.0,08$,,N$GPGGA,211119.084,,,,,0,00,,,M,,M,,*7F
$GPGSV,1,1,02,07,,,160
2,.,GTN*$GPGGA,211210.083,,,,,0,00,,,M,,M,,*72
The first line shouldn’t start with 00
, and the second is missing a newline (and a checksum on the first GPS sentence), while the 3rd and 4th have an extra newline. I’m connecting rx, tx, and gnd. I’ve tried reading the MTK3339’s serial with other devices (my computer, raspberry pi, different arduinos) and none of them seem to exhibit this issue.
Does anyone have any pointers where to look or what could be going wrong?
Thanks,
Mayo
void setup() {
Serial.begin(9600);
Serial.println("GPS test");
Serial2.begin(9600);
delay(10);
}
void loop() {
if (Serial2.available()) {
char c = Serial2.read();
Serial.write(c);
}
}