NEO-6M GPS + ESP32: Build a Bike Trip Computer With a Speed Dial, a Route Trail and a GPX Ride Log
Share
A NEO-6M GPS module gives you more than latitude and longitude. Every second it also reports speed, altitude, satellites and UTC time. Add a colour screen and a microSD card and you have a proper bike computer.
This one shows live speed as a big dial, plus trip, top speed, altitude and satellites. It draws your route as a breadcrumb trail and logs every second of the ride to the card as a GPX file you can open on a map at home.
Soldr designed this build, the parts list, the pin plan and the code around parts that can be shipped to you in India. Soldr is Compoden's AI, AI built on a catalog, so everything below is a part you can order here. If anything is missing, incorrect, or doesn't work as expected, let us know so it can be fixed.
What you need
- ESP32-DEVKITC Development Board (Black)
- NEO-6M GPS Module with Built-in Antenna
- 2.8 Inch TFT LCD Display ILI9341 (SPI, 240x320)
- MicroSD Card Reader SPI Module
- MicroSD Card 32GB Class 10
- MB102 830-Point Breadboard with Jumper Wires
- Jumper Wire Combo (M-M, M-F, F-F)
- USB to Micro-USB Data Cable (1 m) for the ESP32
For the bike: a USB power bank and a handlebar mount or small box.
Step 1: Wire it up
GPS on a serial port, screen and SD card sharing one SPI bus, all on 3.3V logic.

| Module pin | ESP32 |
|---|---|
| GPS VCC / GND | ESP32 3V3 / GND |
| GPS TX | GPIO4 (ESP32 receives) |
| GPS RX | GPIO13 (ESP32 transmits) |
| TFT VCC / GND | 3V3 / GND |
| TFT SCK | GPIO18 |
| TFT SDI (MOSI) | GPIO23 |
| TFT SDO (MISO) | GPIO19 |
| TFT CS / DC / RESET | GPIO5 / GPIO14 / GPIO16 |
| TFT LED (backlight) | 3V3 |
| SD module VCC / GND | 3V3 / GND (see the note below) |
| SD module SCK / MOSI / MISO | GPIO18 / GPIO23 / GPIO19 (same rows as the TFT) |
| SD module CS | GPIO17 |
| Power | ESP32 micro-USB port (computer, 5V USB charger or a power bank on the bike) |
A few notes so it works the first time:
- TX goes to RX. GPS TX goes to the ESP32's listening pin (GPIO4). The sketch uses a hardware serial port at 9600 baud, the NEO-6M default. No GPS data? Swap these two wires first.
- One SPI bus, two chip selects. The screen and the card share SCK, MOSI and MISO on breadboard rails. Each has its own CS pin (5 and 17), so they take turns.
- If the card won't mount, give the module 5V. Soldr's plan feeds it from 3V3, which this module supports. It also has its own regulator and level shifter, so if a card won't mount, move VCC to the ESP32's 5V (VIN) pin. The card still runs at 3.3V; the sketch's [FIX] hint says the same. Use a FAT32 card, 32GB or smaller.
- Leave the extra TFT pins unconnected. The 2.8 inch board's touch (T_) and SD_ pins aren't used here.
Step 2: Upload the Soldr firmware
Soldr generated this sketch for the trip computer. Paste it as gps_trip_computer.ino and upload with the board set to ESP32 Dev Module. Nothing to edit. Faster than 60 km/h? Raise DIAL_MAX_KMH.
// legend: [SOLDR] build · [INIT] init · [TEST] self-test · [DATA] telemetry · [WARN]/[ERROR] fault · [FIX] likely remedy
//
// GPS bike trip computer - ESP32 + NEO-6M + ILI9341 2.8" + microSD (GPX log)
//
// LOOP STRUCTURE
// every pass : feed GPS bytes into TinyGPSPlus (never blocked)
// every 1000 ms (millis): distance / top speed / trail point / GPX trackpoint / [DATA] line
// every 200 ms (millis): redraw ONLY what changed (dial segments, text cells, map on new point)
// No delay() in loop(); no fillScreen() after setup.
//
// WIRING (3.3V logic)
// WIRING - generated from the same pin plan as the Wiring tab (follow the Wiring tab if in doubt):
// 3V3 -> NEO-6M GPS Module VCC
// GND -> NEO-6M GPS Module GND
// GPIO13 -> NEO-6M GPS Module RX (board TX → module RX)
// GPIO4 -> NEO-6M GPS Module TX (board RX ← module TX)
// 3V3 -> 2.8 inch TFT Display Module ILI934 VCC
// GND -> 2.8 inch TFT Display Module ILI934 GND
// GPIO18 -> 2.8 inch TFT Display Module ILI934 SCK
// GPIO23 -> 2.8 inch TFT Display Module ILI934 MOSI
// GPIO19 -> 2.8 inch TFT Display Module ILI934 MISO
// GPIO5 -> 2.8 inch TFT Display Module ILI934 CS - LCD chip select, active low
// 3V3 -> 2.8 inch TFT Display Module ILI934 LED / BL (backlight)
// GPIO14 -> 2.8 inch TFT Display Module ILI934 DC
// GPIO16 -> 2.8 inch TFT Display Module ILI934 RST
// 3V3 -> MicroSD Card Reader SPI Module VCC
// GND -> MicroSD Card Reader SPI Module GND
// GPIO18 -> MicroSD Card Reader SPI Module SCK
// GPIO23 -> MicroSD Card Reader SPI Module MOSI
// GPIO19 -> MicroSD Card Reader SPI Module MISO
// GPIO17 -> MicroSD Card Reader SPI Module CS
// USB port -> ESP32-DEVKITC Development Board powered from its own USB port (a cable to a computer or a 5 V USB charger)
//
// Library Manager: "Adafruit GFX Library", "Adafruit ILI9341", "TinyGPSPlus"
#include <Arduino.h>
#include <SPI.h>
#include <SD.h>
#include <Adafruit_GFX.h>
#include <Adafruit_ILI9341.h>
#include <TinyGPS++.h>
#define SOLDR_DEBUG 1
#define FW_VERSION "1.0"
// ---- pins ----
#define TFT_CS_PIN 5
#define TFT_DC_PIN 14
#define TFT_RST_PIN 16
#define SD_CS_PIN 17
#define SPI_SCK_PIN 18
#define SPI_MISO_PIN 19
#define SPI_MOSI_PIN 23
#define GPS_RX_PIN 4 // ESP32 receives here (GPS TXD)
#define GPS_TX_PIN 13 // ESP32 transmits here (GPS RXD)
#define GPS_BAUD 9600
// ---- dial / layout ----
#define DIAL_MAX_KMH 60
#define DIAL_SEGS 36
#define DIAL_CX 90
#define DIAL_CY 118
#define DIAL_R_IN 50
#define DIAL_R_OUT 70
#define COL_DIM 0x2104
#define COL_HDR ILI9341_NAVY
#define MAP_X 188
#define MAP_Y 128
#define MAP_W 131
#define MAP_H 111
#define MAX_TRAIL 300
Adafruit_ILI9341 tft(TFT_CS_PIN, TFT_DC_PIN, TFT_RST_PIN);
TinyGPSPlus gps;
HardwareSerial gpsSerial(2);
// ---- state ----
bool sdOk = false;
bool haveFix = false;
File gpxFile;
char gpxName[20] = "";
uint32_t gpxPoints = 0;
double tripMeters = 0;
float topSpeedKmh = 0;
float curSpeedKmh = 0;
bool hasLast = false;
double lastLat = 0, lastLon = 0;
float trailLat[MAX_TRAIL];
float trailLon[MAX_TRAIL];
int trailCount = 0;
float trailStepM = 8.0f; // min metres between breadcrumb points (doubles when decimated)
bool trailDirty = true;
int litSegs = 0;
int lastSpeedShown = -1;
unsigned long lastSecond = 0, lastUi = 0, bootMs = 0;
bool noGpsWarned = false;
int initOk = 0, initFail = 0;
// text cache cells
char cHdr[24] = "", cSd[28] = "", cTrip[16] = "", cTop[16] = "", cAlt[16] = "", cSats[16] = "";
// ---------- helpers ----------
static void putText(int x, int y, int w, int h, uint8_t sz, uint16_t col, uint16_t bg,
const char *txt, char *cache) {
if (strcmp(cache, txt) == 0) return;
strncpy(cache, txt, 23);
cache[23] = 0;
tft.fillRect(x, y, w, h, bg);
tft.setTextSize(sz);
tft.setTextColor(col);
tft.setCursor(x + 1, y + 1);
tft.print(txt);
}
static uint16_t segColor(int i) {
if (i < DIAL_SEGS * 6 / 10) return ILI9341_GREEN;
if (i < DIAL_SEGS * 85 / 100) return ILI9341_YELLOW;
return ILI9341_RED;
}
static void drawSeg(int i, bool on) {
const float gap = 0.6f;
float a0 = (135.0f + 270.0f * i / DIAL_SEGS + gap) * DEG_TO_RAD;
float a1 = (135.0f + 270.0f * (i + 1) / DIAL_SEGS - gap) * DEG_TO_RAD;
int xi0 = DIAL_CX + DIAL_R_IN * cosf(a0), yi0 = DIAL_CY + DIAL_R_IN * sinf(a0);
int xo0 = DIAL_CX + DIAL_R_OUT * cosf(a0), yo0 = DIAL_CY + DIAL_R_OUT * sinf(a0);
int xi1 = DIAL_CX + DIAL_R_IN * cosf(a1), yi1 = DIAL_CY + DIAL_R_IN * sinf(a1);
int xo1 = DIAL_CX + DIAL_R_OUT * cosf(a1), yo1 = DIAL_CY + DIAL_R_OUT * sinf(a1);
uint16_t c = on ? segColor(i) : COL_DIM;
tft.fillTriangle(xi0, yi0, xo0, yo0, xo1, yo1, c);
tft.fillTriangle(xi0, yi0, xo1, yo1, xi1, yi1, c);
}
static void drawStaticUi() {
tft.fillScreen(ILI9341_BLACK); // once, scene setup
tft.fillRect(0, 0, 320, 20, COL_HDR);
tft.setTextSize(2);
tft.setTextColor(ILI9341_WHITE);
tft.setCursor(4, 3);
tft.print("BIKE TRIP");
for (int i = 0; i < DIAL_SEGS; i++) drawSeg(i, false);
tft.setTextSize(1);
tft.setTextColor(ILI9341_LIGHTGREY);
tft.setCursor(DIAL_CX - 12, DIAL_CY + 24);
tft.print("km/h");
const char *labels[4] = {"TRIP km", "TOP km/h", "ALT m", "SATS"};
for (int r = 0; r < 4; r++) {
tft.setCursor(190, 24 + r * 25);
tft.print(labels[r]);
}
tft.drawFastVLine(186, 22, 218, ILI9341_DARKGREY);
tft.drawRect(MAP_X - 1, MAP_Y - 1, MAP_W + 2, MAP_H + 2, ILI9341_DARKGREY);
}
static void drawMap() {
tft.fillRect(MAP_X, MAP_Y, MAP_W, MAP_H, ILI9341_BLACK);
if (trailCount < 1) return;
float minLat = trailLat[0], maxLat = trailLat[0], minLon = trailLon[0], maxLon = trailLon[0];
for (int i = 1; i < trailCount; i++) {
if (trailLat[i] < minLat) minLat = trailLat[i];
if (trailLat[i] > maxLat) maxLat = trailLat[i];
if (trailLon[i] < minLon) minLon = trailLon[i];
if (trailLon[i] > maxLon) maxLon = trailLon[i];
}
float cosLat = cosf(((minLat + maxLat) * 0.5f) * DEG_TO_RAD);
float spanY = maxLat - minLat;
float spanX = (maxLon - minLon) * cosLat;
if (spanY < 0.0005f) spanY = 0.0005f; // ~55 m minimum zoom
if (spanX < 0.0005f) spanX = 0.0005f;
const int pad = 5;
float sc = min((MAP_W - 2 * pad) / spanX, (MAP_H - 2 * pad) / spanY);
float cLat = (minLat + maxLat) * 0.5f, cLon = (minLon + maxLon) * 0.5f;
int px = 0, py = 0;
for (int i = 0; i < trailCount; i++) {
int x = MAP_X + MAP_W / 2 + (int)((trailLon[i] - cLon) * cosLat * sc);
int y = MAP_Y + MAP_H / 2 - (int)((trailLat[i] - cLat) * sc);
if (i > 0) tft.drawLine(px, py, x, y, ILI9341_CYAN);
px = x; py = y;
}
int sx = MAP_X + MAP_W / 2 + (int)((trailLon[0] - cLon) * cosLat * sc);
int sy = MAP_Y + MAP_H / 2 - (int)((trailLat[0] - cLat) * sc);
tft.fillCircle(sx, sy, 3, ILI9341_GREEN); // start
tft.fillCircle(px, py, 3, ILI9341_RED); // current
}
static void addTrailPoint(double lat, double lon) {
if (trailCount > 0) {
double d = TinyGPSPlus::distanceBetween(lat, lon, trailLat[trailCount - 1], trailLon[trailCount - 1]);
if (d < trailStepM) return;
}
if (trailCount >= MAX_TRAIL) { // decimate: keep every other point, widen spacing
int n = 0;
for (int i = 0; i < trailCount; i += 2) { trailLat[n] = trailLat[i]; trailLon[n] = trailLon[i]; n++; }
trailCount = n;
trailStepM *= 2.0f;
}
trailLat[trailCount] = (float)lat;
trailLon[trailCount] = (float)lon;
trailCount++;
trailDirty = true;
}
// ---------- GPX ----------
static const char GPX_FOOT[] = "</trkseg></trk></gpx>\n";
static bool openGpx() {
for (int n = 1; n < 10000; n++) {
snprintf(gpxName, sizeof(gpxName), "/RIDE%04d.GPX", n); // 8.3 name
if (!SD.exists(gpxName)) break;
}
gpxFile = SD.open(gpxName, FILE_WRITE);
if (!gpxFile) return false;
gpxFile.print("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
"<gpx version=\"1.1\" creator=\"Soldr Bike Trip Computer\" "
"xmlns=\"http://www.topografix.com/GPX/1/1\">\n"
"<trk><name>Bike ride</name><trkseg>\n");
gpxFile.flush();
return true;
}
// Writes the closing tags then seeks back, so the file is always a valid GPX even if power is cut.
static void gpxCheckpoint() {
size_t pos = gpxFile.position();
gpxFile.print(GPX_FOOT);
gpxFile.flush();
gpxFile.seek(pos);
}
static void logGpxPoint() {
if (!sdOk || !gpxFile) return;
if (!gps.date.isValid() || !gps.time.isValid()) return;
char line[160];
snprintf(line, sizeof(line),
"<trkpt lat=\"%.6f\" lon=\"%.6f\"><ele>%.1f</ele><time>%04d-%02d-%02dT%02d:%02d:%02dZ</time></trkpt>\n",
gps.location.lat(), gps.location.lng(),
gps.altitude.isValid() ? gps.altitude.meters() : 0.0,
gps.date.year(), gps.date.month(), gps.date.day(),
gps.time.hour(), gps.time.minute(), gps.time.second());
gpxFile.print(line);
gpxPoints++;
if (gpxPoints % 10 == 0) gpxCheckpoint();
}
// ---------- 1 s work ----------
static void secondTick() {
haveFix = gps.location.isValid() && gps.location.age() < 2000;
if (!haveFix) {
curSpeedKmh = 0;
return;
}
double lat = gps.location.lat(), lon = gps.location.lng();
float spd = gps.speed.isValid() ? (float)gps.speed.kmph() : 0.0f;
if (spd < 1.0f) spd = 0;
curSpeedKmh = spd;
if (gps.satellites.isValid() && gps.satellites.value() >= 4 && spd > topSpeedKmh) topSpeedKmh = spd;
if (hasLast) {
double d = TinyGPSPlus::distanceBetween(lat, lon, lastLat, lastLon);
if (spd >= 2.0f && d < 100.0) tripMeters += d; // ignore standstill jitter and jumps
}
lastLat = lat; lastLon = lon; hasLast = true;
addTrailPoint(lat, lon);
logGpxPoint();
#if SOLDR_DEBUG
Serial.printf("[DATA] spd=%.1f trip=%.2fkm top=%.1f alt=%.0f sats=%u hdop=%.1f pts=%lu\n",
spd, tripMeters / 1000.0, topSpeedKmh,
gps.altitude.isValid() ? gps.altitude.meters() : 0.0,
gps.satellites.isValid() ? (unsigned)gps.satellites.value() : 0u,
gps.hdop.isValid() ? gps.hdop.hdop() : 99.9,
(unsigned long)gpxPoints);
#endif
}
// ---------- UI refresh (changed values only) ----------
static void updateUi() {
char buf[24];
// header status
snprintf(buf, sizeof(buf), "%s %s", haveFix ? "FIX" : "NO FIX", sdOk ? "REC" : "NO SD");
putText(150, 2, 170, 17, 2, haveFix ? ILI9341_GREEN : ILI9341_ORANGE, COL_HDR, buf, cHdr);
// dial segments - only the ones that changed
int target = (int)(curSpeedKmh / DIAL_MAX_KMH * DIAL_SEGS + 0.5f);
if (target > DIAL_SEGS) target = DIAL_SEGS;
if (target < 0) target = 0;
while (litSegs < target) drawSeg(litSegs++, true);
while (litSegs > target) drawSeg(--litSegs, false);
// big speed number
int spdInt = (int)(curSpeedKmh + 0.5f);
if (spdInt != lastSpeedShown) {
lastSpeedShown = spdInt;
tft.fillRect(DIAL_CX - 44, DIAL_CY - 22, 88, 42, ILI9341_BLACK);
snprintf(buf, sizeof(buf), "%d", spdInt);
tft.setTextSize(5);
tft.setTextColor(ILI9341_WHITE);
int16_t bx, by; uint16_t bw, bh;
tft.getTextBounds(buf, 0, 0, &bx, &by, &bw, &bh);
tft.setCursor(DIAL_CX - (int)bw / 2, DIAL_CY - 20);
tft.print(buf);
}
// stat rows
snprintf(buf, sizeof(buf), "%.2f", tripMeters / 1000.0);
putText(188, 33, 130, 16, 2, ILI9341_WHITE, ILI9341_BLACK, buf, cTrip);
snprintf(buf, sizeof(buf), "%.1f", topSpeedKmh);
putText(188, 58, 130, 16, 2, ILI9341_WHITE, ILI9341_BLACK, buf, cTop);
if (gps.altitude.isValid()) snprintf(buf, sizeof(buf), "%d", (int)gps.altitude.meters());
else snprintf(buf, sizeof(buf), "--");
putText(188, 83, 130, 16, 2, ILI9341_WHITE, ILI9341_BLACK, buf, cAlt);
if (gps.satellites.isValid()) snprintf(buf, sizeof(buf), "%u", (unsigned)gps.satellites.value());
else snprintf(buf, sizeof(buf), "--");
putText(188, 108, 130, 16, 2, ILI9341_WHITE, ILI9341_BLACK, buf, cSats);
// SD status line (bottom left)
if (sdOk) snprintf(buf, sizeof(buf), "%s %lu", gpxName + 1, (unsigned long)gpxPoints);
else snprintf(buf, sizeof(buf), "SD: not available");
putText(4, 214, 178, 12, 1, sdOk ? ILI9341_CYAN : ILI9341_ORANGE, ILI9341_BLACK, buf, cSd);
if (trailDirty) {
trailDirty = false;
drawMap();
}
}
// ---------- setup / loop ----------
void setup() {
Serial.begin(115200);
delay(300);
#if SOLDR_DEBUG
Serial.println();
Serial.println("[SOLDR] GPS Bike Trip Computer | board:ESP32-DEVKITC | v" FW_VERSION);
#endif
SPI.begin(SPI_SCK_PIN, SPI_MISO_PIN, SPI_MOSI_PIN);
// TFT (write-only check: begin() cannot report presence)
tft.begin();
tft.setRotation(1); // landscape 320x240
drawStaticUi();
initOk++;
#if SOLDR_DEBUG
Serial.println("[INIT] TFT ILI9341: OK");
Serial.println("[FIX] TFT ILI9341: if the screen is blank check LED->3V3, CS=5, DC=14, RST=16");
#endif
// SD + GPX file
sdOk = SD.begin(SD_CS_PIN, SPI);
if (sdOk && openGpx()) {
initOk++;
#if SOLDR_DEBUG
Serial.printf("[INIT] SD card: OK\n[TEST] SD file=%s\n", gpxName);
#endif
} else {
sdOk = false;
initFail++;
#if SOLDR_DEBUG
Serial.println("[INIT] SD card: FAIL (mount or file create failed)");
Serial.println("[FIX] SD card: use a FAT32 card, check CS=17 and 5V on the module VCC; logging is disabled");
#endif
}
// GPS
gpsSerial.begin(GPS_BAUD, SERIAL_8N1, GPS_RX_PIN, GPS_TX_PIN);
unsigned long t0 = millis();
while (millis() - t0 < 2000) {
while (gpsSerial.available()) gps.encode(gpsSerial.read());
}
uint32_t chars = gps.charsProcessed();
#if SOLDR_DEBUG
Serial.printf("[TEST] GPS: chars=%lu\n", (unsigned long)chars);
#endif
if (chars > 0) {
initOk++;
#if SOLDR_DEBUG
Serial.println("[INIT] NEO-6M GPS: OK");
#endif
} else {
initFail++;
#if SOLDR_DEBUG
Serial.println("[INIT] NEO-6M GPS: FAIL (no NMEA data)");
Serial.println("[FIX] NEO-6M GPS: GPS TXD must go to GPIO4 and RXD to GPIO13; check 3V3/GND");
#endif
}
#if SOLDR_DEBUG
Serial.printf("[READY] %d OK / %d FAIL\n", initOk, initFail);
Serial.println("[WARN] GPS: first fix outdoors with clear sky can take 1-5 minutes");
#endif
bootMs = millis();
}
void loop() {
while (gpsSerial.available()) gps.encode(gpsSerial.read());
unsigned long now = millis();
if (now - lastSecond >= 1000UL) {
lastSecond = now;
secondTick();
}
if (now - lastUi >= 200UL) {
lastUi = now;
updateUi();
}
if (!noGpsWarned && now - bootMs > 10000UL && gps.charsProcessed() < 10) {
noGpsWarned = true;
#if SOLDR_DEBUG
Serial.println("[ERROR] GPS: no data received");
Serial.println("[FIX] NEO-6M GPS: swap TXD/RXD wires, confirm 9600 baud and power");
#endif
}
}
How it works
- The loop never blocks, so no GPS sentence is dropped. Once a second, with a fresh fix, it updates the stats, adds a breadcrumb and writes one GPX trackpoint.
- Trip distance only counts above 2 km/h and ignores jumps over 100 m, so jitter at a signal adds nothing. Top speed needs 4+ satellites.
- The trail keeps 300 points, 8 m apart. When full it drops every other point and doubles the spacing, so long rides still fit. Green dot is the start, red is you.
- Each boot starts a new RIDE0001.GPX, RIDE0002.GPX and so on. Every 10 points it writes the closing tags, so the file stays valid even if you just unplug.
Step 3: Take it for a ride
- In the Arduino IDE, install the esp32 board package and pick ESP32 Dev Module. Install Adafruit GFX Library, Adafruit ILI9341 and TinyGPSPlus from Library Manager.
- Upload and open the Serial Monitor at 115200. You should see [READY] 3 OK / 0 FAIL.
- Go outside, antenna facing the sky. The header shows NO FIX until it locks (a cold start can take a few minutes), then FIX REC. Indoors it may never lock; that's normal.
- Ride a loop, then open the RIDE file from the card in Google Earth Pro or any GPX app.
If something's off
- NEO-6M GPS: FAIL: GPS TX to GPIO4, RX to GPIO13; check 3V3 and GND.
- SD card: FAIL: check CS on GPIO17, FAT32, and try 5V on the module. Without a card it still works and shows NO SD.
- White screen: check LED to 3V3 and CS 5, DC 14, RESET 16.
How Soldr designs this from the idea
Want an auto-pause when you stop, or a cadence sensor? Describe the idea at soldr.ai. Soldr designs hardware from the idea: it asks which board you want, picks parts from the Compoden catalog, assigns the pins, gives you the wiring and writes the firmware, then compiles it for your board. For this one the idea was simply a GPS trip computer for my bike that shows speed on a dial, draws the route and logs the ride as GPX.
Mount it on the handlebar in a small box with a power bank, and every ride ends with a map.