I have a u-blox gps module and I use TinyGPS (http://arduiniana.org/libraries/tinygpsplus/) to get out the lat + lng.
If i write...
Serial.println(gps.location.lat(), 6);
...out in the log I get the correct latvalue. Right now I however work with a BLE (https://www.adafruit.com/product/1697) and when I try to print it like this:
BTLEserial.print (gps.location.lat()`, 6);
I get a error: no matching function for call to 'Adafruit_BLE_UART::print(double, int)'
If I do this instead, the code runs...
BTLEserial.print ((gps.location.lat(),6));
But I do not get the correct lat, instead I get this value 6.00000000
I have tried to store the lat like this:
double myLat;
myLat = (gps.location.lat(), 6);
BTLEserial.print (myLat);
But with that myLat also has a value of 6.00000000
which is not correct.
I tried this as well:
char sValueOne[16], sValueTwo[16];
char sBuffer[33];
strcpy(sBuffer,dtostrf(((gps.location.lat(),6)), 15, 8, sValueOne));
strcat(sBuffer,",");
strcat(sBuffer,dtostrf(((gps.location.lng(),6)), 15, 8, sValueTwo));
BTLEserial.write((uint8_t *)sBuffer, strlen(sBuffer));
But with that I still get 6.00000000
. I am starting to run out of ideas now to make this work. I have tried to send it both directly and store it but nothing works successfully.
So how can I adjust the code to be able to print (or store) gps lat, lng value (TinyGPS++) with Bluetooth BLE nRF8001?
Appreciate every help and tips!
1 Answer 1
The Arduino Stream/Print classes may sometime need some extra attention.
BTLEserial.println(gps.location.lat()`, 6);
The member function is available in the class Print but gets "hidden". You can help the compiler to find it with a prefix:
BTLEserial.Print::println(gps.location.lat()`, 6);
Cheers!
-
Hey! Thanks for this answer. Will try it in an hourMartman– Martman01/07/2017 10:35:59Commented Jan 7, 2017 at 10:35
-
Hi! I get the correct value. However, it seems like it sends one number at a time. So when I recieve this on the app the value gets chopped up. So for example if the latitude is: 32.123456, it comes like this to the app:
3
, new row,2
, new row etc.Martman– Martman01/07/2017 14:33:01Commented Jan 7, 2017 at 14:33 -
I do not use
println
btw, insteadprint
Martman– Martman01/07/2017 14:40:20Commented Jan 7, 2017 at 14:40 -
That is a new question! Acknowledge the answer and ask a new one. I can help you with that :)Mikael Patel– Mikael Patel01/07/2017 14:42:30Commented Jan 7, 2017 at 14:42
-
Ok Mikael! I will create a new thread regarding that issue. Thanks a lot for your example above to get the first part of the problem fixed. Will accept your answer and of course also upvote it!Martman– Martman01/07/2017 14:43:32Commented Jan 7, 2017 at 14:43
BTLEserial.print (gps.location.lng(),6);
i get a error:no matching function for call to 'Adafruit_BLE_UART::print(double, int)'