Setup Your Own GPS Tracking Server on a Raspberry Pi

Introduction: Setup Your Own GPS Tracking Server on a Raspberry Pi

About: Electronics enthusiast, vlogger on youtube.

In this project I'm gonna show you how to setup your own GPS tracking server on a Raspberry pi. It doesn’t have to be a Raspberry pi, because the software that we’re going to be using for the tracking server is available for Windows and Linux as well, so you could host this on your Windows machine or in a virtual machine on a cloud service, it's up to you, but the instructions here are for a Raspberry pi 4.

The idea started a while back, in Voltlog #272 when I got this GPS tracker disguised into a general purpose automotive relay. In theory this should come with free online tracking service on some Chinese hosted server but I wasn’t able to connect to that server and so I thought why not setup my own server and try to pair it with this tracker. This way I would have a functioning tracking server and improve the privacy aspect because it will be self hosted. and nobody else will have access to my tracking data.

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: Watch the Build Video!

The video describes the entire project step by step so I recommend watching the video first to get an overview of the project, the problems I encountered and how I solved them. Then you can come back and read the following steps for a more detailed explanation.

Step 2: Source the Required Parts

At the core of this project lies the raspberry pi, any model should work, but if you use one of the latest models you should get better performance, meaning software will run smoother and it will be faster to install. For reference I used a raspberry pi 4 and while you might already have this I will still place some links below to places where you can get a raspberry pi 4.

Also very important is the GPS tracker. I've used a model which is disguised as an automotive relay. This is a brilliant idea because if you hide this under the dashboard, nobody will suspect what the real function is. For the GPRS connection between the GPS tracker and the server you will need to provide a data enabled sim card. Pick your favorite local operator for this but keep in mind this particular GPS model only works on 2G networks.

If you live in a country where 2G networks have been decommission you will need to buy a 3G enabled GPS tracker, they are more expensive and the instructions provided here for configuring the tracker, might not be 100% compatible with a 3G enabled GPS tracker.

Step 3: Fresh Install of Raspbian

I’m going to start with a fresh install of Raspbian, I grabbed the latest release of Raspbian Buster Lite from the official website and prepared an sd card with this image using Balena etcher. This should be fairly simple to do, it’s just the usual way of setting up a raspberry pi. After Balena etcher finished the job, I went on to the boot partition on the sd card and created an empty file called ssh, with no extension. This is to enable the SSH server on the raspberry pi because it’s disabled by default. When finished insert the sd card into your raspberry pi, connect it to the network and apply power.

Step 4: Setup the Tracking Server Software: Traccar

Next step is to setup the tracking server, the name of the software is Traccar and here is their website. We’re going to be using the linux arm release, because the raspberry pi runs on an arm processor. Grab the download link, connect to the raspberry pi using your favorite method, I used SSH on the local network. Next all of the commands needed to install the server are described below:

sudo mkdir /opt/traccar && cd /opt/traccar
sudo wget https://github.com/traccar/traccar/releases/download/v4.6/traccar-linux-arm-4.6.zip sudo unzip traccar-linux-arm-4.6.zip sudo rm -f traccar-linux-arm-4.6.zip sudo ./traccar.run //run the install sudo systemctl start traccar.service

When finished open a browser on the same network and try to connect to server using the ip address and port 8082. You should be greeted with a web interface, the default username and password is admin. I advice you change this immediately. The service will automatically start on boot so it’s not required to perform any other steps at this point.

Step 5: Setup Port Forwarding

If your raspberry pi is sitting behind a router or firewall like in my case you will need to forward a port so an external device like the GPS tracker can connect to our newly created server. In the case of the relay gps tracker that I have, it’s using port 5013 but this might vary if you have a different device. This port is critical and you will need to find out which port your tracker is using to establish a connection. I’m using a tp-link router here so I’m just forwarding port 5013 to the local ip address of the raspberry pi server.

Step 6: Register GPS Tracker to Server

Next we can add our GPS tracker in the web interface of Traccar, on the left side I click add, choose a name for your device and fill in the 10 digit identifier which is this label on the side of your trackers case.The newly created device will be shown as offline until the server starts receiving data.

Step 7: Configure the GPS Tracker

The final step is to configure the GPS tracker and these particular commands apply to the tracker that I am using, you might have to use different commands for a different tracker but the idea is to reset the tracker, set your admin number, configure the apn settings for your network operator, set the external ip address we saved earlier, the port is 5013. Set the upload frequency in seconds and enable the GPRS connection. Going back to the Traccar web interface, status should switch to online and we should start seeing data about our device.

Step 8: Final Thoughts

If you are having trouble with this whole setup process, I’ll give you a few hints to check while troubleshooting. First of all this tracker only works with 2G networks, so make sure your network operator is supporting 2G. The sim card must not have a pin lock enabled because the tracker is not able to bypass that. The sim card must have data services enabled and enough credit to perform those operations on the network.

Regarding the server is very important to get the port forwarding right and use the correct external ip address otherwise your devices won’t be pointing to the correct server. It’s also very important to get the correct port for your particular tracking device. Traccar has some great info on this so make sure you check their documentation and forums.

There is a blog post on the subject if you would like to send me some feedback you can do so in the comments and you can also checkout my Youtube channel for more awesome projects: Voltlog Youtube Channel.

Be the First to Share

    Recommendations

    • Raspberry Pi Contest 2020

      Raspberry Pi Contest 2020
    • Wearables Contest

      Wearables Contest
    • Fix It Contest

      Fix It Contest

    Discussions