Skip to main content
emobility.academy
Maker buildsModerateLow risk 1 weekendFor makers, students

Build a GPS Ride Tracker with an ESP32

Build a self-powered GPS ride tracker with an ESP32 that logs position, speed and time to a microSD card. You map your rides afterwards and calculate distance and average speed, without connecting anything to the vehicle.

Go to the steps
Build a GPS Ride Tracker with an ESP32: Microcontroller board, LCD and laptop on a DIYguru lab desk
Representative photo from DIYguru's EV lab.

Why this happens

A GPS module outputs standard NMEA sentences containing position, speed and time once or more per second. An ESP32 can parse them and save them to a card, giving you a tracker you own and control. Building it teaches serial communication, parsing and file logging, and the data helps you study your routes and riding.

What you need

Tools

  • Soldering iron and solder
  • Laptop with the Arduino IDE
  • Digital multimeter

Materials

  • ESP32 development board
  • GPS module with antenna
  • MicroSD card module and card
  • Power bank or a battery holder with a protected cell and a proper charging module
  • Weatherproof project box
  • Velcro straps or cable ties

Before you start

  • Never handle or check the tracker while riding; set it up before you move.
  • Do not power the tracker from the vehicle's battery or tap into its wiring.
  • Make sure the mount cannot come loose into the wheel, chain or brake.
  • Location logs are personal data; keep them private and do not track other people without their consent.

Step by step

  1. 1

    Connect the GPS module

    Wire the GPS module's TX to an ESP32 receive pin on a spare hardware serial port, and its RX to a transmit pin if you want to configure it. Power it from 3.3 V or 5 V as its datasheet states and connect grounds. Most modules default to 9600 baud. Place the antenna with a clear view of the sky.

  2. 2

    Read the raw sentences

    Upload a sketch that copies everything from the GPS serial port to the USB serial monitor. Take the board outside or near a window. At first the sentences have empty fields; after a few minutes the module gets a fix and fills in latitude, longitude, time and speed. A first fix after a long power-off takes longer than later starts.

  3. 3

    Parse with a library

    Install a maintained GPS parsing library. In the sketch, feed it every character from the GPS port and, when it reports a valid new location, read latitude, longitude, speed, altitude, satellites and time. Print them to check. Only log readings when the fix is valid, so bad data does not appear in your files.

  4. 4

    Log to the microSD card

    Wire the microSD module to the ESP32's SPI pins. At start-up, create a new CSV file named with the date or a counter. Once a second, append a line with time, latitude, longitude, speed in km/h, altitude and satellite count. Flush after each write. Blink an LED on each saved line so you can see it is logging.

    Tip: Start a new file for each power-on so a corrupted file never loses more than one ride.

  5. 5

    Power it independently

    Power the tracker from a small power bank, or from a holder with a protected cell and a proper single-cell charging module. Do not connect it to the vehicle's battery or wiring. Measure how long it runs on a full power bank on the bench, so you know it will last your longest ride.

  6. 6

    Box and mount it

    Fit everything in a weatherproof box with the GPS antenna on top, facing the sky. Secure it under a seat or on a rack with straps where it cannot fall into the wheel or block lights or controls. Seal cable entries. Switch it on before you set off and leave it alone while riding.

  7. 7

    Map and analyse rides

    Copy the CSV to a computer. Most mapping software can import a CSV with latitude and longitude columns, or convert it to a GPX track. Use a spreadsheet to calculate distance, moving time and average speed. Compare rides on the same route with different conditions. Delete old files you do not need, because they show where you live and travel.

How to tell it worked

The tracker logs a valid position every second for a whole ride, the track appears correctly on a map, and the distance matches your vehicle's trip meter closely.

Stop and call a technician if

  • The power bank or cell gets hot, swells or is damaged; stop using it and dispose of it properly.
  • Fitting the tracker would need drilling or modifying parts of the vehicle under warranty.

Questions

Why does it take so long to get a fix?

A module that has been off for a long time must download satellite data before its first fix. A clear sky view and leaving it powered for a few minutes help.

Can I see the location live on my phone?

The ESP32 has Bluetooth and Wi-Fi, so you can add that later. Start with card logging, which is simpler and works without a signal.

Related EV hacks

All 100 EV hacks