IoTAdvancedPRJ-106

Wearable Pet Tracker Using ESP32

A collar tracker that shows your pet’s location and whether it is resting, walking or running.

Built and tested by Drisya K S · Industrial Robotics Institute

Circuit diagram of the Wearable Pet Tracker using ESP32
Circuit diagram · ESP32
LevelAdvanced
Build time3–4 hours
BoardESP32
Parts5 components

What is the Wearable Pet Tracker?

A small IoT tracker for a pet’s collar. A Neo-6M GPS module finds where the pet is, and an MPU6050 accelerometer measures how much it is moving. The ESP32 sends the latitude, longitude and activity (Resting, Walking or Running) to the Blynk app every second.

How it works

  1. The GPS module provides the pet’s latitude and longitude.
  2. The MPU6050 measures movement on three axes.
  3. The total movement is classed as Resting, Walking or Running.
  4. The ESP32 sends location to Blynk V1/V2 and activity to V3.
  5. You see the pet’s location and activity live on your phone.

Parts list

ComponentQty
ESP32 Dev Board1
GPS Module (Neo-6M)1
Accelerometer (MPU6050)1
Rechargeable Li-ion Battery1
Jumper Wires / BreadboardAs needed

Software

  • Arduino IDE
  • Blynk IoT app
  • TinyGPSPlus library
  • MPU6050 library

Wiring and connections

FromConnect to
GPS VCC3.3V
GPS GNDGND
GPS TXGPIO 16 (RX)
GPS RXGPIO 17 (TX)
MPU6050 VCC3.3V
MPU6050 GNDGND
MPU6050 SDAGPIO 21
MPU6050 SCLGPIO 22
Li-ion batteryESP32 power input

How to build the Wearable Pet Tracker

  1. Connect the GPS TX to GPIO 16 and RX to GPIO 17.
  2. Connect the MPU6050 to GPIO 21 (SDA) and 22 (SCL).
  3. In Blynk, create datastreams V1 and V2 (double) and V3 (string), and add a map or labels.
  4. Install the TinyGPSPlus and MPU6050 libraries.
  5. Add your Blynk details and Wi-Fi to the code and upload it.
  6. Fit everything in a small case on the collar; take it outside for a GPS fix.

Wearable Pet Tracker code

Complete, tested Arduino C++ code for this project. Copy it into Arduino IDE and upload it to the ESP32.

#define BLYNK_TEMPLATE_ID "YourTemplateID"
#define BLYNK_TEMPLATE_NAME "Pet Tracker"
#define BLYNK_AUTH_TOKEN "YourAuthToken"

#include <Wire.h>
#include <WiFi.h>
#include <MPU6050.h>
#include <TinyGPS++.h>
#include <HardwareSerial.h>
#include <BlynkSimpleEsp32.h>

TinyGPSPlus gps;
HardwareSerial gpsSerial(1);   // RX = 16, TX = 17
MPU6050 mpu;

char ssid[] = "YourWiFiName";
char pass[] = "YourWiFiPassword";

void setup() {
  Serial.begin(115200);
  Wire.begin();
  mpu.initialize();
  gpsSerial.begin(9600, SERIAL_8N1, 16, 17);
  Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
}

void loop() {
  // Read GPS
  while (gpsSerial.available() > 0) gps.encode(gpsSerial.read());
  Blynk.virtualWrite(V1, gps.location.lat());
  Blynk.virtualWrite(V2, gps.location.lng());

  // Read accelerometer
  int16_t ax, ay, az;
  mpu.getAcceleration(&ax, &ay, &az);
  long movement = abs(ax) + abs(ay) + abs(az);

  String activity;
  if (movement < 10000)      activity = "Resting";
  else if (movement < 30000) activity = "Walking";
  else                       activity = "Running";

  Blynk.virtualWrite(V3, activity);

  Blynk.run();
  delay(1000);
}

Real-world uses

  • Pet safety and lost-pet finding
  • Livestock tracking
  • Pet fitness monitoring
  • Learning GPS + IoT

Frequently asked questions

What is a Wearable Pet Tracker?

A small IoT tracker for a pet’s collar. A Neo-6M GPS module finds where the pet is, and an MPU6050 accelerometer measures how much it is moving.

What components are needed for the Wearable Pet Tracker?

You need: ESP32 Dev Board (1), GPS Module (Neo-6M) (1), Accelerometer (MPU6050) (1), Rechargeable Li-ion Battery (1), Jumper Wires / Breadboard. Software: Arduino IDE, Blynk IoT app, TinyGPSPlus library, MPU6050 library.

Is the Wearable Pet Tracker project good for beginners?

It is rated advanced and takes about 3–4 hours to build, using the ESP32. The guide on this page explains every connection and step.

Where can I get the code for the Wearable Pet Tracker?

The complete, tested Arduino C++ code is free on this page. Copy it into Arduino IDE and upload it to the board.

Can I buy a kit for the Wearable Pet Tracker?

Yes. IRI sells a kit with the parts for this project (PRJ-106). Message IRI on WhatsApp at +91 86060 82634 for the kit price and delivery details.

Industrial Robotics Institute
Logo