Skip to main content

Building a Real-Time GPS Dashboard with ESP8266, NEO-6M, and FastAPI

From Space Signals to Real-Time Display

Published 4 min readMarkdown
Building a Real-Time GPS Dashboard with ESP8266, NEO-6M, and FastAPI

I’ve always been fascinated by how easily we can share our live location — whether it’s tracking a delivery, following a friend’s ride, or even our own movement on a map. That curiosity led me to explore the NEO-6M GPS module, a small yet powerful device capable of fetching precise geographic coordinates directly from satellites.

In this project, I built a real-time GPS tracking system that sends live coordinates from an ESP8266 to a FastAPI backend, which then displays them on an interactive web dashboard using Leaflet.js.

Before jumping into the build, let’s first understand the NEO-6M GPS module and how it works.


1. What is the NEO-6M GPS Module?

The NEO-6M is a GPS receiver developed by u-blox that communicates with satellites orbiting Earth to determine its exact position. It can provide real-time data such as:

  • Latitude & Longitude

  • Altitude

  • Speed

  • Time

Fun Fact: The NEO-6M works only outdoors, as it requires a clear view of the sky to connect with GPS satellites. It won’t function properly indoors due to signal blockage.

NEO-6M GPS Module


2. How GPS Works (Simplified Theory)

The Global Positioning System (GPS) uses signals from a network of at least 24 satellites orbiting Earth. Each satellite broadcasts its position and time.

When a GPS module receives signals from four or more satellites, it calculates its position using trilateration, determining your location based on distances from multiple satellites.


3. What Kind of Data Does NEO-6M Provide?

The module outputs data in NMEA sentences (like $GPGGA, $GPRMC), which contain:

  • Latitude & Longitude

  • UTC Time

  • Fix quality (signal validity)

  • Number of satellites connected

  • Altitude

Example NMEA sentence:

$GPGGA,130113.00,37XX.XXXX,N,07XXX.XXXX,E,1,04,3.97,404.9,M,45.7,M,,*79

Note on Accuracy:
Under open-sky conditions, the NEO-6M typically provides position accuracy within 2.5 to 5 meters. However, accuracy can decrease in areas with obstructions like tall buildings, dense trees, or poor satellite visibility.


4. Components & Tools Used

Component / ToolPurpose
ESP8266 (NodeMCU)Reads GPS data and sends it to FastAPI
NEO-6M GPS ModuleProvides latitude, longitude, and time
TinyGPS++Parses GPS data from the module
SoftwareSerialHandles serial communication with GPS
ESP8266WiFiConnects ESP8266 to WiFi
ArduinoJsonFormats GPS data as JSON
FastAPIReceives GPS data and serves it via API
Leaflet.js + HTML/JSDisplays live location on a web map

5. Connecting NEO-6M to ESP8266

GPS Module PinESP8266 PinPurpose
VCC3.3VPower supply
GNDGNDGround
TXD7 (RX)GPS data output to ESP8266
RXD6 (TX)ESP8266 data output to GPS

6. Reading GPS Data on ESP8266

#include <TinyGPS++.h>
#include <SoftwareSerial.h>

TinyGPSPlus gps;
SoftwareSerial gpsSerial(D7, D6); // RX, TX

void setup() {
  Serial.begin(115200);
  gpsSerial.begin(9600);
}

void loop() {
  while (gpsSerial.available() > 0) {
    gps.encode(gpsSerial.read());
    if (gps.location.isUpdated()) {
      float latitude = gps.location.lat();
      float longitude = gps.location.lng();
      Serial.print("Lat: "); Serial.print(latitude, 6);
      Serial.print(" Lon: "); Serial.println(longitude, 6);
    }
  }
}

This prints real-time GPS coordinates to the serial monitor.


7. Sending GPS Data to FastAPI

After reading GPS coordinates, the next step is sending them to the backend:

  • Use HTTP POST requests from ESP8266 to FastAPI.

  • Format the data as JSON using ArduinoJson.

StaticJsonDocument<200> jsonDoc;
jsonDoc["latitude"] = latitude;
jsonDoc["longitude"] = longitude;
String postData;
serializeJson(jsonDoc, postData);
client.println(postData);

FastAPI receives the data and makes it available to the frontend dashboard.


8. Setting Up ESP8266 and FastAPI Communication

  • Ensure ESP8266 and your PC/server are connected to the same WiFi network.

  • Find your PC’s IPv4 address and update the server URL in the ESP8266 code.

  • Upload the code to the ESP8266 using Arduino IDE.

For the complete setup and code, refer to the GitHub Repository.


9. Viewing Live Location

  • Open index.html in your browser (or host it via FastAPI).

  • You’ll see a live map with GPS coordinates updating in real-time.


10. Project Flowchart

The flow of data in this project:


11. Access the Code and Learn More!

I hope this project helps you understand the fascinating world of GPS tracking. Feel free to explore and build upon this foundation.

  • Get the full code here: GitHub Repository

  • Connect with me: Portfolio | GitHub

  • Working Video: Demo

No comments yet. Be the first to comment.