GPS with DiStance

This Arduino sketch reads GPS data from a NEO-6M GPS module and displays the latitude, longitude, and distance from a predefined home location (in this case, London) on a 16x4 I2C LCD screen. 

In the first picture, the setup showcases the back end of the Arduino GPS Distance unit with an Arduino Nano and a GPS module mounted on it. This configuration shows a compact and portable solution for tracking geographical data. The Arduino Nano serves as the brains of the operation, interfacing with both the GPS module and the 16x4 LCD display via I2C communication. The GPS module communicates with the Arduino Nano through serial communication, providing real-time latitude and longitude data. 

The second picture captures the user with the setup, demonstrating the functionality of the system in action. With the GPS module properly configured and connected to the Arduino Nano, it successfully acquires longitude and latitude coordinates. The Arduino Nano then utilizes these coordinates, along with predefined home base coordinates (set to London's latitude and longitude which you change for your home location), to calculate the distance from the home base. This distance calculation is achieved through mathematical algorithms implemented in the Arduino code,  leveraging the TinyGPS++ library to parse GPS data and perform distance calculations accurately. 

Finally, the third picture illustrates the integration of the GPS tracking system into the console of a vehicle. This deployment suggests the practical application of the setup for navigation or location-based services while on the move. The Arduino Nano, along with the GPS module and LCD display, seamlessly fits into the vehicle's console, providing real-time geographic information to the user. The code running on the Arduino continuously reads GPS data, updates the LCD display with latitude, longitude, and distance from home, and ensures that the system functions reliably, even in a dynamic environment like a moving vehicle. Overall, this project showcases the versatility of Arduino-based GPS tracking systems and their potential applications in various scenarios, from outdoor adventures to vehicle navigation. 

Arduino code below with detailed comments explaining each part to someone who's new to programming 

/*  Author: Douglas Fessler  Date: 2024-03-26  

#include <Wire.h>

#include <LiquidCrystal_I2C.h>

#include <TinyGPS++.h>

#include <SoftwareSerial.h>

const int RX_PIN = 6, TX_PIN = 5;

const uint32_t GPS_BAUD = 9600; //Default baud of NEO-6M is 9600

TinyGPSPlus gps; // The TinyGPS++ object

SoftwareSerial gpsSerial(RX_PIN, TX_PIN); // The serial interface to the GPS device


const double LONDON_LAT = 51.508131;

const double LONDON_LON = 0.128002;

LiquidCrystal_I2C lcd(0x27, 16, 4); // Address 0x27, 16 column and 4 rows

unsigned long previousMillis = 0;

const long lcdInterval = 1000; // LCD update interval (milliseconds)

void setup() {





  lcd.setCursor(0, 0);

  lcd.print("Arduino - GPS");

  lcd.setCursor(0, 1);



void loop() {

  unsigned long currentMillis = millis();

  if (currentMillis - previousMillis >= lcdInterval) {

    previousMillis = currentMillis;

    updateLCD(); // Update LCD display


  readGPS(); // Read GPS data


void updateLCD() {



  lcd.print("  Adventure VAN GPS");

  lcd.setCursor(0, 1);

  lcd.print("Lat: ");

  lcd.print(, 4); // Display latitude with 6 decimal places

  lcd.setCursor(0, 2);

  lcd.print("Lon: ");

  lcd.print(gps.location.lng(), 4); // Display longitude with 6 decimal places

  lcd.setCursor(0, 3);

  lcd.print("From Home: ");

  lcd.print(TinyGPSPlus::distanceBetween(, gps.location.lng(), LONDON_LAT, LONDON_LON) / 1000);

  lcd.print(" km");


void readGPS() {

  while (gpsSerial.available() > 0) {

    if (gps.encode( {

      if (gps.location.isValid()) {

        Serial.print("- latitude: ");


        Serial.print("- longitude: ");


        Serial.print("- distance to Home: ");

        Serial.println(TinyGPSPlus::distanceBetween(, gps.location.lng(), LONDON_LAT, LONDON_LON) / 1000);

      } else {

        Serial.println("- location: INVALID");





  if (millis() > 5000 && gps.charsProcessed() < 10)

    Serial.println("No GPS data received: check wiring");


Now, let's go through each part:


If you've enjoyed exploring my Arduino projects and want to see more amazing creations, your support can make a big difference! By contributing, you're helping me continue to innovate and bring even more exciting projects to life. Together, we can explore the endless possibilities of DIY electronics! Don't forget to like, subscribe, and follow for updates on the latest developments. Thank you for being a part of this journey! 

Click here to make a difference with your donation today!