Go Down

### Topic: GPS Accuracy (Read 1 time)previous topic - next topic

#### salwaniza95

##### Apr 28, 2017, 10:02 am
does anyone here knows how to improve the gps accuracy? right now im using arduino and sim808 and implementation source code from https://www.dfrobot.com/…/SIM8…/GPRS/GSM_Shield_SKU:_TEL0097. everything works fine except the gps accuracy. i need few more decimal places so that i can get full gps accuracy because right now it gives me several kilometer inaccurate.
i want to parse the number up to 6 decimal digit. it is possible?
part of the source code:
// Parse a (potentially negative) number with up to 2 decimal digits -xxxx.yy
int32_t DFRobot_SIM808::parseDecimal(const char *term)
{
bool negative = *term == '-';
if (negative) ++term;
int32_t ret = 100 * (int32_t)atol(term);
while (isdigit(*term)) ++term;
if (*term == '.' && isdigit(term[1]))
{
ret += 10 * (term[1] - '0');
if (isdigit(term[2]))
ret += term[2] - '0';
}
return negative ? -ret : ret;
}
does anyone here would like to help? im really appreciate it.

#### johnwasser

#1
##### Apr 28, 2017, 02:07 pm
Are you using float/double values for Latitude and Longitude?  On an Arduino, the float/double types can only express between 6 and 7 significant digits.  If you need more significant digits you will need to work in integers (probably long integers).
Send Bitcoin tips to: 1G2qoGwMRXx8az71DVP1E81jShxtbSh5Hp
See who has no social life: https://forum.arduino.cc/index.php?action=stats

#### -dev

#2
##### Apr 28, 2017, 02:16 pmLast Edit: Apr 28, 2017, 02:17 pm by -dev
There's no way to fix that code, because it is returning the integer XXXXYY instead of XXXX.YY.  The caller of this routine expects the scaled-by-100 integer.  If you try to add extra digits, you have to change the scaling factor to 10000... and then you have to change all the code that calls parseDecimal.

It would probably be easier to switch to a better library.  There are several SIM808 libraries that you could combine that a GPS library.  My NeoGPS is smaller, faster and more accurate than all other libraries.  It provides 10 significant digits (7 decimals).  Other libraries only provide ~7 digits (4 or 5 decimals).

Here's an untested sketch that uses AT commands to control the SIM808.  It also uses NeoGPS to parse the GPS stream when the SIM808 is emitting the GPS NMEA sentences.
Really, I used to be /dev.

Go Up