Industrielle Fertigung
Industrielles Internet der Dinge | Industrielle Materialien | Gerätewartung und Reparatur | Industrielle Programmierung |
home  MfgRobots >> Industrielle Fertigung >  >> Manufacturing Technology >> Herstellungsprozess

Track ME: Arduino Mega 2560 Auto-Tracker mit GPS & GPRS

Komponenten & Zubehör

Arduino Mega 2560 1
NEO-6M GPS-Modul 1
Seeedstudio GPRS Shield V2.0 (SIM900) 1
Adafruit SD-Karten-Shield 1
9 V Blockbatterie (oder LiPo mit Step-Up) 1
Gehäuse (Kunststoffbox) 1
Steckbrücken 1 Set

Projektbeschreibung

Ein Prototyp für einen Fahrzeug-/Personen-Tracker. Der Arduino Mega liest kontinuierlich GPS-Koordinaten (NEO-6M) und loggt sie auf SD-Karte. Bei Anruf auf die SIM-Karte im GPRS-Shield sendet das System eine SMS mit aktuellem Standort (Google-Maps-Link) oder – bei fehlendem GPS-Fix – der letzten bekannten Position.

Funktionsablauf

  1. Start: GPRS, GPS, SD-Karte initialisieren.
  2. GPS sucht Satelliten (>3 für gültigen Fix).
  3. Eingehender Anruf → Anruf abweisen → SMS senden:
    • Gültiger Fix: „Hugo location is now: Lat: xx, Lon: yy. https://maps.google.com/maps?q=xx,yy“
    • Kein Fix: „Last known position: Lat: xx, Lon: yy. …“
  4. Daten (Datum, Uhrzeit, Koordinaten, SMS-Status) auf SD-Karte loggen.

Verkabelung (Arduino Mega Pinout beachten!)

SD-Karten-Shield (SPI)

UNO SPI → Mega SPI: MOSI 11→51, MISO 12→50, SCK 13→52, SS 10→53. CS-Pin = 53.

GPRS Shield (SoftwareSerial)

Jumper J7 auf SoftwareSerial. Shield Pins 7 (TX) & 8 (RX) → Mega Serial1: TX1 (Pin 18), RX1 (Pin 19).

GPS-Modul (Hardware Serial2)

GPS TX → Mega Pin 16 (RX2), GPS RX → Mega Pin 17 (TX2). Stromversorgung vom SD-Shield (5 V/GND).

Stromversorgung

9 V Batterie an Vin oder DC-Buchse.

Software & Bibliotheken

Quellcode (Hauptschleife)

#include <SIM900.h> #include <SoftwareSerial.h> #include <sms.h> #include <call.h>
#include <TinyGPS++.h> #include <SPI.h> #include <SD.h>

const int chipSelect = 53;
CallGSM call; SMSGSM sms;
TinyGPSPlus gps;
char number[20]; byte stat; int error;
double Lat, Long; int day, month, year, hour, minute, second, num_sat;
bool one_point_true = false;
const char* googlePrefix = "https://maps.google.com/maps?q=";

void setup() {
  Serial.begin(9600);
  // GPRS
  if (gsm.begin(9600)) Serial.println(F("GSM READY")); else Serial.println(F("IDLE"));
  // GPS
  Serial2.begin(9600);
  // SD
  pinMode(53, OUTPUT);
  if (!SD.begin(chipSelect)) { Serial.println(F("SD fail")); while(1); }
  Serial.println(F("SD OK"));
}

void loop() {
  Get_GPS();
  Check_call();
}

void Get_GPS() {
  while (Serial2.available()) gps.encode(Serial2.read());
  num_sat = gps.satellites.value();
  if (gps.location.isValid()) {
    Lat = gps.location.lat(); Long = gps.location.lng();
    if (Lat != 0 && Long != 0) one_point_true = true;
  }
  if (gps.date.isValid()) { day = gps.date.day(); month = gps.date.month(); year = gps.date.year(); }
  if (gps.time.isValid()) { hour = gps.time.hour(); minute = gps.time.minute(); second = gps.time.second(); }
  smartDelay(500);
}

static void smartDelay(unsigned long ms) {
  unsigned long start = millis();
  do { while (Serial2.available()) gps.encode(Serial2.read()); } while (millis() - start < ms);
}

void Check_call() {
  stat = call.CallStatusWithAuth(number, 0, 0);
  if (stat == CALL_INCOM_VOICE_AUTH) {
    delay(100); call.HangUp(); Send_SMS();
  }
}

void Send_SMS() {
  char Date[13]; sprintf(Date, "%02d/%02d/%04d ", day, month, year);
  char Time[10]; sprintf(Time, "%02d:%02d:%02d ", hour, minute, second);
  char lat_s[12], lon_s[12];
  dtostrf(Lat, 5, 6, lat_s); dtostrf(Long, 5, 6, lon_s);

  if (num_sat >= 3 && one_point_true) {
    char sms[160]; sprintf(sms, "Hugo location is now: Lat: %s, Log: %s. %s%s,+%s", lat_s, lon_s, googlePrefix, lat_s, lon_s);
    error = sms.SendSMS(number, sms);
  } else if (one_point_true) {
    char sms[150]; sprintf(sms, "Last known position: Lat: %s, Log: %s. %s%s,+%s", lat_s, lon_s, googlePrefix, lat_s, lon_s);
    error = sms.SendSMS(number, sms);
  }
  // Log auf SD
  File f = SD.open("datalog.txt", FILE_WRITE);
  if (f) { f.print(Date); f.print(Time); f.print(number); f.print(" "); f.print(lat_s); f.print(","); f.print(lon_s); f.print(" "); f.println(error); f.close(); }
}

Bekannte Limitationen & Ausblick

Schaltpläne

Zwei Übersichtsbilder: Gesamtverkabelung und Detail GPRS/GPS/Shield-Anschlüsse.

Herstellungsprozess

  1. Intelligenten Roboter mit Bridge Shield bauen – Raspberry Pi & Arduino Integration
  2. Web-gesteuertes DMX-Lichtsystem – Arduino Master Controller
  3. Bluetooth-gesteuerter Arduino-Spybot bauen – Überwachungsroboter mit IP-Kamera
  4. UnifiedWater v1 – Komplettes Arduino Wasserqualitäts-Sensorkit
  5. HSV-Uhr: Lebendige, anpassbare Zeitanzeige für Arduino-Enthusiasten
  6. Fortgeschrittener Schneeräumer-Roboter für effizientes Winter-Räumen
  7. Portables Abstimmungssystem mit GSM-Anbindung (Mobile Vote Box)
  8. DIY Whac-A-Mole Arcade-Spiel (Tasten-Edition) – Arduino Mega Projekt
  9. Modern Jukebox: Raspberry Pi & Arduino LED-Musikplayer im Retro-Look
  10. DIY Arduino Smartwatch: Eigene Apple-Watch-Alternative bauen