Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

6 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🐾 Smart Pet Tracker System Using IoT

A real-time IoT-based pet tracking system built with the GeoLinker GL868_ESP32 board. It uses GPS, GSM, geofencing, an E-paper display, and cloud connectivity to monitor your pet's location and send instant alerts when they leave a safe zone.

Disclaimer: No animals were harmed during the development and testing of this project.


πŸ“– Table of Contents


Overview

"Where did my pet go?" β€” If you have a pet, you've probably asked this question at least once. This project provides a practical solution by building a smart pet tracking collar that:

  • πŸ“ Tracks your pet's real-time GPS location
  • 🚧 Monitors multiple geofence zones (Home, Garden, Park, Restricted Area)
  • πŸ“± Sends SMS alerts & voice calls when boundaries are crossed
  • πŸ“Ί Displays pet status on an E-paper screen (retains info even without power)
  • ☁️ Uploads location data to CircuitDigest Cloud for live map tracking

Note: This is a proof-of-concept project intended for learning and experimentation. It should not be considered a replacement for commercially certified pet tracking products.


How It Works

The system operates in three continuous stages:

1. System Initialization & Location Tracking

  • On power-up, the GeoLinker board initializes GPS, GSM/GPRS, E-paper display, and cloud services.
  • Previously saved geofence states are restored from flash memory to avoid false alerts after restart.
  • The GPS module continuously acquires latitude, longitude, speed, and other location data.
  • Current coordinates are compared against all predefined geofence zones using the Haversine formula.

2. Alert Generation & Safety Features

  • Zone Entry/Exit: An SMS alert is sent with location, speed, battery %, and a Google Maps link.
  • Restricted Zone: In addition to SMS, a voice call is placed to the caretaker for critical alerts.
  • GPS Loss: If GPS signal is unavailable for multiple consecutive attempts, a GPS-loss alert is sent.
  • On-Demand Location: The caretaker can send a LOCATION SMS command to receive the pet's latest coordinates.
  • E-paper Display:
    • Normal: Shows pet name and healthy status.
    • Lost/Restricted Zone: Shows "My Pet is Lost" with the caretaker's phone number.
    • Retains content even when battery is fully drained.

3. Cloud Monitoring & Continuous Operation

  • Periodically uploads GPS location, battery %, and signal strength to the CircuitDigest Cloud.
  • Live map tracking via the cloud dashboard.
  • Continuously checks for GPS updates, geofence events, incoming SMS commands, and display status.
  • E-paper display refreshes only on status change to conserve power and extend display life.

Components Required

S.No Components Purpose Alternatives
1 GeoLinker GL868_ESP32 Board GeoLinker GL868_ESP32 is a production-ready, open-source development board that combines an ESP32-S3 and SIM868 GSM modem, used for tracking purposes. β€”
2 IoT / Normal Nano SIM Card Airtel M2M IoT SIM recommended (3 months free data with board purchase). Any 2G-compatible SIM works. Regular 2G SIM
3 3.7V Li-Ion Battery Used for powering the board. LiPo pouch battery
4 USB-C Cable Programming, testing & charging. β€”
5 E-Paper Display For displaying different messages and retaining content even when power is out. β€”

Circuit Diagram

The GeoLinker board integrates the ESP32 microcontroller, GPS, GSM, and GPRS modules on a single board, eliminating the need for multiple separate modules. Only the E-paper display needs to be externally connected via SPI.

A 3.7V lithium-ion battery connects directly to the GeoLinker board for portable operation.

Circuit Diagram


Hardware Assembly

The E-paper display and battery are connected to the GeoLinker board and arranged inside the 3D-printed enclosure. The compact layout allows all components to fit comfortably within the collar enclosure.

Hardware Connection


3D Enclosure Design

The enclosure was designed in Autodesk Fusion 360 and consists of two parts:

Part Description
Base Houses the GeoLinker board, 3.7V battery, and internal wiring.
Lid Features a precisely sized cutout for the E-paper display, ensuring the screen remains visible while protecting the electronics.

Key Features:

  • Collar slots on both sides for mounting onto a standard pet collar
  • Lightweight and durable 3D-printed construction
  • Easy assembly with secure component placement

πŸ“ 3D design files are available in the /3D-Design folder of this repository. You can modify them in Fusion 360 or use them as-is for printing.

Enclosure Design


Software Setup

Prerequisites

  • Arduino IDE (v2.x recommended)
  • GeoLinker board support package installed
  • Required libraries (see code dependencies)

Configuration

Update the following constants in the main code file before uploading:

#define DEVICE_ID      "your_device_id"
#define API_KEY        "your_api_key"
#define ALERT_NUMBER   "+91XXXXXXXXXX"   // Caretaker's phone number
#define PET_NAME       "YourPetName"

Upload Steps

  1. Connect the GeoLinker board via USB-C.
  2. Select the correct board and port in Arduino IDE.
  3. Update the configuration constants above.
  4. Configure your geofence zones (latitude, longitude, radius).
  5. Upload the code to the board.

Code Explanation

Initialization

void setup() {
    Serial.begin(115200);
    loadZoneStates();              // Restore saved geofence states from flash
    GeoLinker.begin(DEVICE_ID, API_KEY);
    GeoLinker.gpsOn();
    epdInit();                     // Initialize E-paper display
}

GPS Acquisition & Geofence Checking

bool hasLoc = getValidLocation(&gps);

if (hasLoc) {
    checkGeofences(&gps, hasLoc);
}

// Distance calculation using Haversine formula
double dist = haversineDistance(
    gps->latitude, gps->longitude,
    zones[i].latitude, zones[i].longitude
);

Alert Generation

static void sendGeofenceAlert(const char *zoneName, bool entered,
                              bool restricted, GPSData *gps, bool hasLoc) {
    char msg[256];
    buildAlertMessage(msg, sizeof(msg), entered ? "ENTERED" : "LEFT",
                      zoneName, gps, hasLoc);
    sendReliableSMS(ALERT_NUMBER, msg);

    // Schedule voice call for restricted zones
    if (restricted && !callInProgress && !pendingCall) {
        pendingCall = true;
        pendingCallTimer = millis();
    }
}

E-paper Display Update

static void epdUpdateIfNeeded() {
    if (petIsLost == displayShowsLost) return;  // No change needed

    if (petIsLost)
        epdShowLost();      // Shows "My Pet is Lost" + phone number
    else
        epdShowHealthy();   // Shows pet name + healthy status

    displayShowsLost = petIsLost;
}

Main Loop

void loop() {
    GeoLinker.update();
    checkIncomingSMS();                      // Handle "LOCATION" SMS commands

    bool hasLoc = getValidLocation(&gps);
    checkGeofences(&gps, hasLoc);

    // Cloud data upload at regular intervals
    if (!pendingCall && !callInProgress &&
        millis() - lastCloudPush >= CLOUD_SEND_INTERVAL * 1000UL) {
        lastCloudPush = millis();
        cloudPush(&gps, hasLoc);
    }
}

Spoof/Test Mode

A spoof code is also available in this repository, allowing you to test the entire system (geofence alerts, SMS, calls, cloud upload) without physically moving β€” useful for development and debugging.


Output & Demonstration

Live Map Tracking

The cloud dashboard provides a live map showing the pet's real-time location and geofence zone status.

Live Map

E-paper Display States

Condition Display
Normal (inside safe zone) Pet name + owner contact details
Restricted zone / Lost ⚠️ "My Pet is Lost" + caretaker's phone number

Toby with Collar

SMS & Call Alerts

  • SMS Alert: Sent when the pet exits a safe zone β€” includes event details, location, and Google Maps link.
  • Voice Call: Automatically placed when the pet enters a restricted area β€” ensures critical alerts are not missed.

SMS and Call Alerts


Applications

Application Description
πŸ• Prevention of Pet Theft Pet theft is an increasing problem in many regions. By providing real-time location information and instant alerts when unusual movement is detected, the Smart Pet Safety System serves as an additional layer of protection against theft.
πŸ‘Ά Child and Elderly Safety Monitoring The device can be used to track children, elderly individuals, or people requiring special care. Caregivers receive instant alerts if the wearer moves beyond predefined safe zones, improving safety and response times.
πŸš— Vehicle and Fleet Management The solution can be integrated into vehicles for route monitoring, theft prevention, and fleet management. Real-time GPS tracking helps optimize operations and improve vehicle security.
πŸ„ Livestock and Animal Monitoring Farmers and animal caretakers can use the system to track livestock, working animals, or pets across large areas, ensuring they remain within designated boundaries.
πŸ“¦ Parcel Tracking and Delivery Management The same geofencing and GPS tracking technology can be used for parcel tracking and last-mile delivery management. A GPS-enabled tracking device attached to a valuable package can continuously report its location while monitoring predefined geofenced areas such as warehouses, distribution centers, or delivery zones.

Troubleshooting

Problems Cause Solutions
GSM module fails to connect to the network SIM card is not inserted correctly, network coverage is weak, or SIM services are inactive. Check SIM card placement, verify network availability, and ensure the SIM card has an active plan with sufficient balance.
Voice call alerts are not working Network issues, insufficient SIM balance, or incorrect call configuration. Confirm GSM connectivity, ensure calling services are enabled, and verify emergency contact settings.
E-paper display remains blank Display initialization failure, loose wiring, or power supply issues. Verify all SPI connections, check display power requirements, and ensure the display initialization code executes correctly.
Battery drains faster than expected Continuous GPS tracking, frequent GSM communication, or lack of power-saving features. Increase update intervals, optimize code efficiency, and enable low-power modes when possible.
System freezes during operation Memory overflow, software bugs, or communication conflicts between modules. Debug the code, monitor memory usage, and test each module independently to identify the issue.
Whitelisted number not receiving alerts The phone number is not added correctly, stored in an incorrect format, or the whitelist configuration has not been updated in the system. Verify that the number is entered correctly with the appropriate country code, check the whitelist settings in the firmware, and restart the device after updating the configuration.

FAQ

1. Can multiple safe zones be configured?

Yes. The system can be programmed to monitor multiple geofenced areas depending on the application requirements.

2. What are the possible future improvements?

Future enhancements may include mobile app integration, cloud connectivity, AI-based analytics, health monitoring sensors, longer battery life, and real-time dashboard visualization.

3. What happens when the device moves outside the safe zone?

The system detects the boundary violation and automatically sends an alert message and location details to the registered contact number.

4. Why is an e-paper display used instead of a regular display?

E-paper displays consume very little power and remain visible even in bright sunlight, making them ideal for portable and battery-powered applications.

5. What is geofencing?

Geofencing is a virtual boundary created around a specific location. When the tracked object enters or exits this area, the system automatically generates alerts and notifications.

6. How are alerts sent to users?

Alerts are sent through a GSM module using SMS messages and voice calls, ensuring notifications can be received even without internet access.


Future Improvements

  • πŸ“± Mobile app integration for easier configuration and monitoring
  • πŸ€– AI-based analytics for behavior pattern detection
  • πŸ’“ Health monitoring sensors (body temperature, heart rate)
  • πŸ”‹ Extended battery life with low-power GNSS modules
  • πŸ“‘ Wi-Fi / Bluetooth for indoor tracking
  • πŸƒ IMU sensor for activity and collar-removal detection
  • πŸ“Š Real-time dashboard visualization

Related Projects


⭐ If you found this project helpful, please give it a star!

About

The project is related to the pet tracking in the real-time

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages