TinyGPS++ distanceBetween() calculates wrong distance


Can someone confirm that TinyGPSPlus::distanceBetween() calculates the distance wrong?
To be sure that I’m not using it wrong I also checked the library’s example.
Distance to London shows me 7712km but it must be around 500km. Using an ordinary arduino with the Github library works as expected (520km). I tried with photon and electron…
Could there be a problem with the math functions? the code of the distanceBetween() looks correct to me…



You should modify the library example to print out the values of gps.location.lat() and gps.location.lng() (in the distanceBetween function) to see if those values are correct for your location. That should tell you whether the problem is with the math, or with the values that you’re feeding in to the math.

I did that already. Everything is correct and as i said, even the example sketches don’t work. What I don’t understand is that the same sketch works with arduino but not with the particle cloud.
Now I’ve written my own function to calculate the distance between but anyway would i be happy to know where the problem is…

There is a big that I fixed.

You can include the files manually from GitHub in your application to make sure you are using the latest version.

1 Like

Jep… I was close. Thank you!