So, I'm trying to build a GPS speedcoach for my crew team and I'm hitting a wall. I can't find a formula to easily calculate the distance in meters between two set GPS points with an accuracy of under ~20 meters. Would any of you guys happen to have a piece of code to help me out? I'm measuring distances from 250-10,000 meters with a usual operating distance of the classic 2k. I'm also using an Adafruit M0 Adalogger and matching GPS featherwing, if that matters.

The TinyGPSplus library includes the calculation of the distance and direction between two sets of GPS co-ordinates.

Over short distances its typically within a couple of metres, although the bearing calculation is not so good.

The major limitation on accuracy is in any case the GPS itself, the location may be +-5M at best, but can easily be far worse than that.

To calculate distances between two closely spaced latitude/longitude points, the equirectangular approximation is excellent.

One limitation is that the standard Arduino does not support double precision float calculations, and a single precision floating point variable (6-7 decimal digits) cannot accurately represent a lat/lon value (8 decimal digits required for +/- 1 meter accuracy).