Raspberry Pi GPS tracker – Getting it Together

Having secured a Pi Zero from the cover of a the magazine MagPi I thought I would start out simple by trying one of the projects shown there. The one that caught my eye and required no soldering was to build a GPS tracker.

Getting hold of a cheap USB unit was pretty easy but make sure it is Linux compatible. I bought this one from eBay.

The first thing I did when I got the unit was to try it out on the Pi and while it was working I could see that it had got a satellite fix the record containing the actual location wasn’t populated and showed as invalid.

Satellite fixes in Ublox U-center software

Satellite fixes in Ublox U-center software

Assuming that it was a an issue with the unit I downloaded ublox software on a Windows machine and tried from there. Again the same thing. So I contacted the company that sold me the unit and they came back with this very full explanation.

Invalid records in Ublox U-center software

Invalid records in Ublox U-center software

The first time these devices are powered up in a new location, they firstly locate as many satellite signals as possible, then download the almanac data (future predicted satellite positions), whilst trying to calculate the current position.

If the signals aren’t strong enough, the satellites can be seen and identified by number, however the position cannot be calculated and the almanac data cannot be downloaded.

When I test all of these modules, I do so outside with a laptop, a clear view of the sky, and a hot mug of coffee (as each module can take 5-15mins the first time depending on satellite positions).

The device will likely output the current satellite time with a signal which is much weaker than the signal level required to get a location fix.

Whilst the device may give a satellite lock indoors after the initial location fix, you are unlikely to get a first location fix at all indoors, believe me I’ve tried this without much success on cold days to avoid going outside, ultimately they need a clear view of the sky to work.

So I put the kettle on and set off outside with the GPS unit once again connected to the Pi. Almost immediately it got a fix and the green light started to blink. Success!

The next step was putting it all together with some code to record the GPS records as I moved around. For this I used the recommended Python script, GPS Experimentation, which was easy to setup and configure. Unfortunately I don’t speak Python so one of my first tasks will be to see if I can re-write it in PHP.

And so I set off out with my Heath Robinson GPS tracker. As you can see from the images below the combined battery, wires and Pi resembles a cinematic bomb so I spent quite a bit of time searching for the perfect container in which to house it. In the end Poundland came up trumps with a box of screen wipes and it was cheap too (a pound, obviously).

The first surprise was that the battery,  a freebie 2000mAh usb power bank, lasted a full 10 hours just driving the Pi and GPS unit. That was seriously impressive. The second was just how accurate the tracker was when out in the open. As you can see when I plotted the data in GPSPrune.

A meander around Reading Town

A meander around Reading Town

However, there were times when things were not all that they seemed. The image below shows the hour I spent sat in a coffee shop working and highlights the small variations on GPS location that are returned. I think one improvement I will make to the code is to stop tracking when the speed is zero, or very close to it.

An hour sat in the same place

An hour sat in the same place

And at one point the tracker lost the plot completely and decided that I was in France which led to this anomaly!

A day trip to France

A day trip to France

 

On the whole this was an easy and fun project to put together and all relatively cheap. The next step is to convert the code to PHP and start to make some improvements. Check back next week for an update.

8 comments on “Raspberry Pi GPS tracker – Getting it Together

  1. A great write up. I snagged a pi zero and have been looking for a simple solution to track my motorcycle in case of theft. Were you able to convert it to PHP?

Leave a Reply

Your email address will not be published. Required fields are marked *