Tuesday, 10 September 2013

NMEA with Android : speed inaccurate sometimes

NMEA with Android : speed inaccurate sometimes

I have an Android app, where in I use NMEA as speed source, I use data
from GPVTG and GPRMC
FROM DOCUMENTATION OF NMEA
eg3. $GPVTG,t,T,,,s.ss,N,s.ss,K*hh
1 = Track made good
2 = Fixed text 'T' indicates that track made good is relative to true
north
3 = not used
4 = not used
5 = Speed over ground in knots
6 = Fixed text 'N' indicates that speed over ground in in knots
7 = Speed over ground in kilometers/hour
8 = Fixed text 'K' indicates that speed over ground is in kilometers/hour
9 = Checksum
AND
eg4. $GPRMC,hhmmss.ss,A,llll.ll,a,yyyyy.yy,a,x.x,x.x,ddmmyy,x.x,a*hh
1 = UTC of position fix
2 = Data status (V=navigation receiver warning)
3 = Latitude of fix
4 = N or S
5 = Longitude of fix
6 = E or W
7 = Speed over ground in knots
8 = Track made good in degrees True
9 = UT date
10 = Magnetic variation degrees (Easterly var. subtracts from true course)
11 = E or W
12 = Checksum
Here is my code
for NMEA result
if (nmea != null && nmea.contains("RMC")) {
result = null;
result = nmea.split(",");
if (gpsdata != null && result != null && result.length > 7) {
gpsdata.setVtgdataCollected(true);
gpsdata.setHeading(result[8]);
gpsdata.setSpeed(result[7]);
} else {
return null;
}
}
// eg1. $GPVTG,360.0,T,348.7,M,000.0,N,000.0,K*43
if (nmea != null && nmea.contains("VTG")) {
result = null;
result = nmea.split(",");
if (gpsdata != null && result != null && result.length > 7) {
gpsdata.setVtgdataCollected(true);
gpsdata.setHeading(result[1]);
gpsdata.setSpeed(result[5]);
} else {
return null;
}
}
Most of time I get accurate results, but sometimes I get incorrect speed
as I was travelling at 70 Kmph but I was shown at speed of 117 Kmph. Is it
because of Garbage from GPS
If yes, How can I make sure that I always show correct speed to user
Thanks in advance!!!

No comments:

Post a Comment