0

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!

asked Jan 6, 2017 at 23:56
6
  • 6.000000 is the value of ((gps.location.lat(),6)) where 6 is the last item in the list. C/C++ is a strange language. Remove all the extra () and things will look better. Commented Jan 7, 2017 at 1:22
  • If i do BTLEserial.print (gps.location.lng(),6); i get a error: no matching function for call to 'Adafruit_BLE_UART::print(double, int)' Commented Jan 7, 2017 at 1:32
  • Add links to the libraries you are using. Commented Jan 7, 2017 at 1:42
  • myLat = (gps.location.lat(), 6); gives the value 6.0000 as explained above. It is not a list with the two values or a double with 6 digits. Commented Jan 7, 2017 at 1:45
  • For gps i use TinyGPS++, this: arduiniana.org/libraries/tinygpsplus and for my BLE i use this where you can see sample code also: learn.adafruit.com/… Commented Jan 7, 2017 at 1:45

1 Answer 1

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!

answered Jan 7, 2017 at 2:04
7
  • Hey! Thanks for this answer. Will try it in an hour Commented 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. Commented Jan 7, 2017 at 14:33
  • I do not use println btw, instead print Commented 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 :) Commented 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! Commented Jan 7, 2017 at 14:43

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.