Tekko BDSimSimulatorProjects

GPS জিওফেন্স এলার্ম (পোষা প্রাণী বা সাইকেলের জন্য)GPS Geofence Alarm with Arduino (Pet Collar / Bike Tracker)

প্রথম GPS fix হয়ে যায় অদৃশ্য বেড়ার কেন্দ্র। সেই কেন্দ্র থেকে ০.০৫ ডিগ্রির (প্রায় ৫ কিমি) বেশি দূরে গেলে buzzer বাজে আর লাল LED জ্বলে, ভেতরে ফিরলে থামে। GPS-এর Latitude slider টেনে বেড়ার বাইরে হাঁটিয়ে পরীক্ষা করো।

The first GPS fix becomes the centre of an invisible fence. Any fix farther than 0.05 degrees (about 5 km) sounds the buzzer and lights the red LED until the tracker comes back inside the line. Walk the Latitude slider on the GPS to test it.

▶ ফ্রি চালিয়ে দেখো / Run it free Parts অর্ডার করো (WhatsApp)

সার্কিট ডায়াগ্রাম · Circuit diagram

GPS Geofence Alarm with Arduino (Pet Collar / Bike Tracker) circuit diagram — Arduino Uno, GPS module (NEO-6M), Resistor 220Ω, LED (green), LED (red), Buzzer, Jumper wires

যা যা লাগবে · Parts you need

তার লাগানো · Wiring

GPS module (NEO-6M) VCC→Arduino Uno 5V
GPS module (NEO-6M) GND→Arduino Uno GND
GPS module (NEO-6M) TX→Arduino Uno D4
GPS module (NEO-6M) RX→Arduino Uno D3
Arduino Uno D5→Resistor a
Resistor b→LED A
LED K→Arduino Uno GND.3
Arduino Uno D6→Resistor a
Resistor b→LED A
LED K→Arduino Uno GND.3
Arduino Uno D8→Buzzer +
Buzzer -→Arduino Uno GND.3

Code (Arduino C++)

#include <SoftwareSerial.h>
#include <TinyGPS++.h>
// Geofence: whatever the tracker rides on — a pet collar, a bicycle — may not
// leave a small area around home. The first valid fix becomes the centre; any
// fix farther away than 0.05 degrees (roughly 5 km) sounds the alarm until the
// tracker comes back inside. Move the Latitude slider on the GPS to walk it out
// of the fence.
SoftwareSerial gpsSerial(4, 3);   // NEO-6M TX -> D4
TinyGPSPlus gps;
const int buzzer = 8, safeLed = 5, alarmLed = 6;
bool hasHome = false;
float homeLat = 0, homeLng = 0;

void setup() {
  pinMode(buzzer, OUTPUT); pinMode(safeLed, OUTPUT); pinMode(alarmLed, OUTPUT);
  Serial.begin(9600);
  gpsSerial.begin(9600);
  Serial.println("Waiting for the first fix (that becomes home)...");
}

void loop() {
  while (gpsSerial.available()) gps.encode(gpsSerial.read());
  if (!gps.location.isValid()) return;
  if (!hasHome) {
    homeLat = gps.location.lat();
    homeLng = gps.location.lng();
    hasHome = true;
    Serial.print("Home set: "); Serial.print(homeLat, 4); Serial.print(","); Serial.println(homeLng, 4);
    return;
  }
  float dLat = gps.location.lat() - homeLat, dLng = gps.location.lng() - homeLng;
  bool outside = fabs(dLat) > 0.05 || fabs(dLng) > 0.05;
  digitalWrite(safeLed, outside ? LOW : HIGH);
  digitalWrite(alarmLed, outside ? HIGH : LOW);
  digitalWrite(buzzer, outside ? HIGH : LOW);
  Serial.println(outside ? "OUT OF FENCE!" : "SAFE");
  delay(400);
}

আরো project · More projects