I'm trying to get coordinates from board a9g with at+location=2 Tiny library sometimes work sometimes not. The function to get coordinates as string is:
String sendData(String command, const int timeout, boolean debug)
{
String response = "";
mySerial.println(command);
long int time = millis();
while ((time + timeout) > millis())
{
while (mySerial.available()){
char c = mySerial.read();
response += c;
}
}
if (debug)
{
Serial.print(response);
}
return response;
}
to retrieve the coordinates
coordinates =sendData("AT+LOCATION=2", 1000, DEBUG);
int index = coordinates.indexOf(',');
lat = coordinates.substring(17, index);
lng = coordinates.substring(index + 1);
printing:
lat = 42.850
lng = 2.8500
but when I send to php
"AT+HTTPGET=\"http://carles.ho.submit_data01.php?data1=" + String(lat) +"&data2=" + String(lng) + "&data3=" + mac + "&data4=" + String(flag) + "\"";
it does'nt work. The documentation for at+location is this:
AT+LOCATION=1(return:,OK) xx.xxxxx, xxx.xxxxxx (fixed to 6 digits after the decimal point) OK Return latitude and longitude directly without conversion
I've tried differents options but I can't. Thanks in advance.
I would like to know what kind of response return and how to solve.
Improving accuracy in lng:
and cleaning results avoiding undesirable characters:
}