I have a LS20031 GPS interfacing with an Uno using SoftSerial on pins 9/10 with a baud of 19200 using TinyGPS 12 to parse the data. I have them (apparently) communicating fine since I am getting accurate position and altitude information, however TinyGPS is showing invalid values for Velocity and Course. Has anyone else run into these issues?
Here is a trimmed down sample of the source:
#include <SoftwareSerial.h>
#include <TinyGPS.h>
#define GPS_SERIAL_BAUD 19200
SoftwareSerial gpsSerial(10, 9); // RX, TX
TinyGPS gps;
float b_latitude=0;
float b_longitude=0;
unsigned long b_fix_age;
float b_course=0;
float b_velocity=0;
int b_numSats=0;
int b_gpsfix=0;
float b_altitude=0;
unsigned long int b_chars=0;
unsigned short int b_sentences=0;
unsigned short int b_failed_checksum=0;
int timer;
void gps_update() {
while (gpsSerial.available()) {
int c = gpsSerial.read();
if (gps.encode(c))
{
gps.f_get_position(&b_latitude, &b_longitude, &b_fix_age);
// statistics
gps.stats(&b_chars, &b_sentences, &b_failed_checksum);
if (b_failed_checksum >= 100)
b_failed_checksum = 0;
b_velocity = gps.f_speed_kmph();
b_course = gps.f_course();
b_numSats = gps.satellites();
b_altitude = (gps.altitude() / 100);
}
}
}
void local_data()
{
if (millis() - timer > 200)
{
timer = millis();
lcd.clear();
lcd.setCursor(0,0);
if (relAltitude == 1)
{
lcd_print_P(PSTR("AH:"));
lcd.print((b_altitude - Altitude_Home)* DIST_CONV);
}
else
{
lcd_print_P(PSTR("AT:"));
lcd.print(b_altitude * DIST_CONV );
}
//lcd.setCursor(0,1);
//lcd_print_P(PSTR("NSat:"));
//lcd.print(b_numSats);
lcd.setCursor(19,0);
if (b_fix_age == TinyGPS::GPS_INVALID_AGE || b_fix_age == 0) {
lcd_print_P(PSTR("N"));
}
else if (b_fix_age > 3000)
{
lcd_print_P(PSTR("O"));
}
else
{
lcd_print_P(PSTR("G"));
}
lcd.setCursor(0,1);
lcd_print_P(PSTR("LT:"));
lcd.print(b_latitude,3);
lcd.setCursor(10,1);
lcd_print_P(PSTR("LN:"));
lcd.print(b_longitude,3);
lcd.setCursor(0,2);
lcd_print_P(PSTR("VL:"));
lcd.print(b_velocity);
lcd.print(" KM/H");
lcd.setCursor(0,3);
lcd_print_P(PSTR("D:"));
lcd.print(gps.cardinal(b_course));
lcd_print_P(PSTR(" NS:"));
lcd.print(b_numSats);
lcd_print_P(PSTR(" CE:"));
lcd.print(b_failed_checksum);
lcd_print_P(PSTR(" S:"));
lcd.print(b_sentences);
}
}
void setup() {
gpsSerial.begin(GPS_SERIAL_BAUD);
}
void loop() {
gps_update();
local_data();
}
I apologize if anything is missing from the source above, this is grossly reduced from the whole file.
After some testing I discovered that the Velocity/Course information is only missing if the GPS is sending both RMC and GGA sentences. If it only sends RMC sentences then the velocity/course information come through just fine, but then altitude and quality data is lost.
Any ideas?