GPS - Distance between two points

Before I go and code this directly, I was digging around in the AssetTracker library, looking to see if this has been done already. I didn’t see it in there. Are they’re any other GPS based library that may have that already coded?

Thank you.

@n8xja, are you looking for “as the crow flies” distance (point to point) or via a routing algorithm (like Google Maps)?

For point-to-point, here is an arduino example:


Peekay - great question - “as the crow flys” - Going to use the distance to help determine when the electron is moving, above a threshold, to increase logging frequency.

@n8xja, so like geo-fencing basically. That formula should work. However, it took all of 30 seconds to google “distance between two gps coordinates arduino”! :wink:

I appreciate anyone who responds to a question but the question wasn’t “how do you code” (I actually know how to do that already) - the question was - is it already coded in a library.

ANDDDDDDDDD you are implying that there’s some relationship between arduino and electron - Good to know - I will be include that in the searches to avoid gratuitous snark.

@n8xja, I only snark with smart people so no offense intended, just having fun :wink:

And yes, a LOT of arduino code can be ported to Particle and that is my typical go-to term to include in my searches. You would be amazed how much is available!

TinyGPS++ library does feature a TinyGPSPlus::distanceBetween() function

And a sample use can be found here

1 Like