Here is an example of how you can calculate the distance between two GPS points in kilometers and display it on an HTML page: In your ESP8266 server code, you will need to receive the GPS points from the HTML page and calculate the distance using the Haversine formula. Here is an example of how to do this using the math.h library: #include double calculateDistance(double lat1, double lon1, double lat2, double lon2) { double R = 6371; // Earth's radius in kilometers double dLat = (lat2 - lat1) * M_PI / 180; double dLon = (lon2 - lon1) * M_PI / 180; lat1 = lat1 * M_PI / 180; lat2 = lat2 * M_PI / 180; double a = sin(dLat / 2) * sin(dLat / 2) + sin(dLon / 2) * sin(dLon / 2) * cos(lat1) * cos(lat2); double c = 2 * atan2(sqrt(a), sqrt(1 - a)); return R * c; } In your HTML page, you will need to use JavaScript to send the GPS points to the ESP8266 server, and display the calculated distance. Here is an example of how to do this using jQuery and AJAX:
This example creates a form with four input fields for the GPS points, a submit button, and a div element to display the calculated distance. When the button is clicked, the form sends a POST request to the server with the GPS points, the server will then calculate the distance using the function provided and return the distance to the client side, and the JavaScript updates the div element with the distance. Please note that this is just an example and you may need to adapt it to your specific use case. Also note that the Haversine formula is only accurate for short distances, for longer distances it's recommended to use a more advanced algorithm like Vincenty's.