Forum >GPS/GSM MODULE V3.0 - CONVERT GPS LOCATION DEG/MIN TO DEG
GPS/GSM MODULE V3.0 - CONVERT GPS LOCATION DEG/MIN TO DEG

Hello,
I have a problem with GPS location not accurate after I do the conversion of the location data.
I get the location with location data from the module like before use the conversion function:
latitude - 0303.883740
longgitude - 10130.365394
that data show the raw data of GPS location that is in decimal DEG/MIN.
I use this code to get the result on the top :
the problem is, I want to convert in decimal DEG and send the location data to my mobile phone.
and I use this code for conversion the location from DEG/MIN to DEG in my library "gps_gsm_sim908Serial0.h" :
but I get the result something like this :
latitude : 3.066666
longitude: 101.483329
that is not accurate about 5km from the exact location.
supposedly, the result must be like :
latitude : 3.064729
longitude : 101.50609
please help me to correct the conversion function of int8_t convert2Degrees to make the result be more accurate.
I have a problem with GPS location not accurate after I do the conversion of the location data.
I get the location with location data from the module like before use the conversion function:
latitude - 0303.883740
longgitude - 10130.365394
that data show the raw data of GPS location that is in decimal DEG/MIN.
I use this code to get the result on the top :
Code: Select all
#include "gps_gsm_sim908Serial0.h"
void setup () {
gps_init (); //init GPS pin
Serial.begin (9600); //serial0 connect computer
start_gsm();
}
void loop () {
start_gps();
int stat = gps_get_gga (); // read data from GPS, return 0 is ok
//convert latitude and longgitude from DEG/MIN to DEG
convert2Degrees(gps_gga_lat_s ());
convert2Degrees(gps_gga_long_s ());
if (stat == 0 || stat == 1) {
if (gps_gga_is_fix ()) { //true if fix
gsm_set_numble ("0123456789"); // change it to your receiver phone number
gsm_send_message ("Latitude in Deg :");
gsm_send_message (gps_gga_lat_s ());
gsm_send_message ("Longgitude in Deg :");
gsm_send_message (gps_gga_long_s ());
gsm_send_message ("#You can view your location on map at http://www.geoplaner.com/");
gsm_end_send ();
while (1);
}
}
}
the problem is, I want to convert in decimal DEG and send the location data to my mobile phone.
and I use this code for conversion the location from DEG/MIN to DEG in my library "gps_gsm_sim908Serial0.h" :
Code: Select all
int8_t convert2Degrees(char* input){
float deg;
float minutes;
boolean neg = false;
//auxiliar variable
char aux[10];
if (input[0] == '-')
{
neg = true;
strcpy(aux, strtok(input+1, "."));
}
else
{
strcpy(aux, strtok(input, "."));
}
// convert string to integer and add it to final float variable
deg = atof(aux);
strcpy(aux, strtok(NULL, '\0'));
minutes=atof(aux);
minutes/=1000000;
if (deg < 100)
{
minutes += deg;
deg = 0;
}
else
{
minutes += int(deg) % 100;
deg = int(deg) / 100;
}
// add minutes to degrees
deg=deg+minutes/60;
if (neg == true)
{
deg*=-1.0;
}
neg = false;
if( deg < 0 ){
neg = true;
deg*=-1;
}
float numeroFloat=deg;
int parteEntera[10];
int cifra;
long numero=(long)numeroFloat;
int size=0;
while(1){
size=size+1;
cifra=numero%10;
numero=numero/10;
parteEntera[size-1]=cifra;
if (numero==0){
break;
}
}
int indice=0;
if( neg ){
indice++;
input[0]='-';
}
for (int i=size-1; i >= 0; i--)
{
input[indice]=parteEntera[i]+'0';
indice++;
}
input[indice]='.';
indice++;
numeroFloat=(numeroFloat-(int)numeroFloat);
for (int i=1; i<=6 ; i++)
{
numeroFloat=numeroFloat*10;
cifra= (long)numeroFloat;
numeroFloat=numeroFloat-cifra;
input[indice]=char(cifra)+48;
indice++;
}
input[indice]='\0';
}
but I get the result something like this :
latitude : 3.066666
longitude: 101.483329
that is not accurate about 5km from the exact location.
supposedly, the result must be like :
latitude : 3.064729
longitude : 101.50609
please help me to correct the conversion function of int8_t convert2Degrees to make the result be more accurate.
2015-11-23 23:50:08 Hello again,
But I think the library to transfor the raw location info to decimal location is correct, because this was verified once by another guy, the method and the guy's post could be found from TELL051 wiki > FAQ > Q2:
https://www.dfrobot.com/wiki/index.php/G ... KU:TEL0051)#FAQ
I also tested it, it's not very accurate, the error is about 300-400 meters, in China, with Baidu Mao API, but that guy use Google map to get a very accurate location.
Leff
But I think the library to transfor the raw location info to decimal location is correct, because this was verified once by another guy, the method and the guy's post could be found from TELL051 wiki > FAQ > Q2:
https://www.dfrobot.com/wiki/index.php/G ... KU:TEL0051)#FAQ
I also tested it, it's not very accurate, the error is about 300-400 meters, in China, with Baidu Mao API, but that guy use Google map to get a very accurate location.
