可攜式GPS軌跡記錄器

一、專案簡介

本專案旨在設計並製作一套可攜式GPS軌跡記錄器,利用Arduino主控板搭配NEO-6M GPS模組,將即時取得的經緯度與時間資料記錄於SD卡中,並以CSV格式儲存,方便後續資料分析與應用。整套系統以18650鋰電池供電,透過升壓模組確保運作穩定,達到無線與便攜的目標。


二、系統架構

1. 硬體組成

元件名稱 型號/規格 功能說明
主控板 Arduino UNO/Nano 控制與資料處理
GPS模組 NEO-6M 取得定位與時間資料
SD卡模組 SPI介面 資料儲存
鋰電池 18650(3.7V, 2200mAh) 提供電力
升壓模組 3.7V→5V(如MT3608) 穩定供電至5V
連接線 杜邦線 電路連接

2. 系統連接圖

[18650鋰電池] 
    ↓
[升壓模組 (3.7V→5V)]
    ↓
[Arduino] ←→ [NEO-6M GPS模組]
    ↓
[SD卡模組]

三、電路接線說明

模組 連接到Arduino腳位
NEO-6M VCC 5V
NEO-6M GND GND
NEO-6M TX D4(軟體序列埠RX)
NEO-6M RX D3(軟體序列埠TX)
SD卡 VCC 5V
SD卡 GND GND
SD卡 MOSI D11
SD卡 MISO D12
SD卡 SCK D13
SD卡 CS D10

四、軟體設計

1. 使用函式庫

2. 程式邏輯流程

  1. 初始化SD卡與GPS模組
  2. 建立CSV檔案並寫入標題行
  3. 持續讀取GPS模組資料
  4. 每當GPS位置資料更新時,解析經緯度與UTC時間
  5. 將資料以CSV格式寫入SD卡
  6. 重複步驟3~5,實現即時紀錄

3. 程式碼範例

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

SoftwareSerial gpsSerial(4, 3); // RX, TX
TinyGPSPlus gps;
const int chipSelect = 10; // SD卡CS腳位

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

  if (!SD.begin(chipSelect)) {
    Serial.println("SD卡初始化失敗");
    while (1);
  }
  // 建立CSV檔案並寫入標題
  File dataFile = SD.open("gpslog.csv", FILE_WRITE);
  if (dataFile) {
    dataFile.println("Date,Time,Latitude,Longitude");
    dataFile.close();
  }
}

void loop() {
  while (gpsSerial.available() > 0) {
    gps.encode(gpsSerial.read());
    if (gps.location.isUpdated()) {
      String dataString = "";
      // 日期
      dataString += String(gps.date.year()) + "-" + String(gps.date.month()) + "-" + String(gps.date.day()) + ",";
      // 時間
      char timeBuffer[9];
      sprintf(timeBuffer, "%02d:%02d:%02d", gps.time.hour(), gps.time.minute(), gps.time.second());
      dataString += String(timeBuffer) + ",";
      // 經度與緯度
      dataString += String(gps.location.lat(), 6) + "," + String(gps.location.lng(), 6);

      // 寫入SD卡
      File dataFile = SD.open("gpslog.csv", FILE_WRITE);
      if (dataFile) {
        dataFile.println(dataString);
        dataFile.close();
      }
      delay(1000); // 每秒記錄一次
    }
  }
}

五、成果展示

Date,Time,Latitude,Longitude
2025-05-20,14:23:10,25.047800,121.531900
2025-05-20,14:23:11,25.047805,121.531905
...

六、注意事項與建議


七、未來展望


八、參考資料

  1. TinyGPS++ Library
  2. Arduino SD Library
  3. Instructables - Arduino GPS Data Logger
  4. Maker Portal - Arduino GPS Logger

結論: 本專案成功實現以Arduino為核心的無線GPS軌跡記錄器,具備低成本、易擴充、便攜等特點,能有效記錄移動路徑與時間資訊,並以標準CSV格式儲存,方便後續資料分析與應用。


Revision #2
Created 2026-04-01 02:06:37 UTC by TaipeiTechRacing
Updated 2026-04-11 14:33:41 UTC by AI Agent