A self-hosted GPS pet tracking solution — part 1
As a pet owner, keeping track of your furry friend can provide invaluable peace of mind. Whether you’re dealing with an adventurous pup or simply want to ensure your pet’s safety during walks, a GPS tracker can be a game-changer. In this two-part series, I’ll share my journey of building a self-hosted GPS pet tracking solution that’s reliable, customizable, and free from ongoing subscription costs.
Why Track Your Pet?
Dogs are curious by nature. Even a slight distraction can lead to them wandering off. Having a GPS tracker allows you to locate them more quickly. This not only ensures their safety but also offers peace of mind.
Defining the Requirements
To build a robust GPS tracking system, I had a few must-haves for both the tracker device and the server:
For the tracker device:
- Small and lightweight: Comfortable for the dog to wear.
- Good battery life: To minimize frequent recharging, and to ensure it does not run out of battery when the dog needs to be found
- Cellular connectivity: To work virtually anywhere
- Data efficiency: Keeps operational costs low.
- Waterproof (IP68): Durable in all weather conditions.
- Easy to charge: Convenient for regular use.
- Attachment-friendly: Easily secures to a collar or harness.
For the tracking server:
- Cross-platform support: Accessible on both desktop and mobile.
- Geofence capabilities: For setting virtual boundaries.
- Home Assistant integration: To fit into my existing smart home ecosystem.
- Comprehensive mapping: Includes both street map and satellite imagery.
- Cost-effective: Free of charge and preferably open-source.
The Solution
After researching numerous options, I settled on the following:
- Server: Traccar — an open-source GPS tracking system with robust features and a user-friendly interface.
- Device: Mictrack MT710 — a compact, waterproof GPS tracker meeting all the criteria I outlined. It's $75 for the tracker and the silicon case, shipped directly from the OEM.
I’m thrilled with how this setup turned out:
Here’s how you can set up Traccar for your own self-hosted GPS tracking solution.
Setting Up Traccar
For this project, I decided to host Traccar on a public cloud server. This ensures that the tracking system remains accessible even during home network or power outages. Alternatively, there is a hosted offering for ~$10/month, and it's a good way to support the open-source project.
I decided to deploy it in a docker container, but bare-metal installation is also supported.
To deploy Traccar, you'll need:
- a read-only mount for the config
- a writable mount for logs
- open ports for the tracker to connect to and for the web UI
- a database (MariaDB in my case)
- optional, but recommended: a reverse proxy (Caddy in my case) to put in front of the UI for security and convenient SSL termination with Let's Encrypt
My docker compose looks like this:
With the following env file so that I don't store my secrets in the compose yaml.
And this is my Traccar config.xml, pointing to my MariaDB and with a few other options configure. The only thing required to start is the database. You'll need to ensure the database exists, and Traccar will create the tables for you and populate them.
Integration with Home Assistant
Integrating Traccar with Home Assistant is very easy. Simply add a new integration and point it to the UI port (in my case, 8082)
Coming Up Next
With Traccar up and running, the next step is to configure the Mictrack MT710 device and link it to the server. In Part 2, I’ll guide you through setting up the tracker.