How to create a GPS tracker with a Raspberry Pi, USB GSM Modem, and AWS

Introduction

Recently I’ve been worried about recent car thefts and thought I’d create something to give me some security over the matter. This is why I decided to create a GPS tracker. It’s not the first time I’ve installed a Raspberry Pi in my car, I created a dashcam that used the Raspberry Pi V2 camera and the inbuilt WiFi to act as an AdHoc AP. This allowed me to see what’s happening in front of the car when I wasn’t there and also transfer files as soon as I arrived back at home to my local home server as a USB WiFi dongle was also attached that connected to my home WiFi.

The Accessories

For this project I used;

  • USB mobile GSM dongle (I used a Huawei E303).
  • USB GPS Dongle (U-Blox 7).
  • Raspberry Pi 2 (I had this spare laying around + good processing power).

How it works

The raspberry pi has Debian Jessie installed that is currently the latest OS you can run from the Raspberry Pi website. I chose to have the desktop already installed as it comes in useful when I want to remotely control the pi via VNC. More on this later.

WVDial – Connecting to the GSM network

Setting up the USB GSM Modem was a bit of a pain. I used a piece of software called wvdial that you can install via apt-get. The configuration for this, since I used giffgaff is;

The config file is located at /etc/wvdial.conf

There’s no private parts retracted from this as it is all generic since the SIM card is what is registered with the network.

Once this was setup you can simply run sudo wvdial and it should dial in and connect fine. You’ll notice if you also run ifconfig -a it created a ppp0 interface that is used to access the internet.

Now, for me when testing, I also had my Ethernet cable connected so in order to test I had to change the default route. To do this, just run;

Now, if you ping google.co.uk or any other site, you should see some times that are quite high due to latency when on the mobile network.

Once I know this was working, I created a little script that launches on startup;

This could be written better, but I’m no bash expert, but it works.

This script checks to see if the interface ppp0 is available, if not, then it continues with the loop and attempts to start wvdial again. Once wvdial is running an an interface is created, it then starts the tracker application that is written in node.

GPS Dongle

Setting GPS up on the raspberry pi is a relatively simple task once I knew what I was doing. Simply plug in the USB dongle and identify which port it is using. I found that mine was on /dev/ttyACM0. I found this out because if I ran sudo cat /dev/ttyAMC0 I could see a lot of raw GPS data.

Once this port was identified, then I proceeded onto installing some utilities by doing sudo apt install gpsd gpsd-clients.

Once this has finished installing, proceed to run the following commands, assuming the port you identified was /dev/ttyAMC0 like mine was.

If you have a GPS lock, you will see all the fields populated in that window. You can close it by doing CTRL+C.

The tracker + AWS

At some point I will upload this to github. For now, I’ll explain what I did.

The tracking application is built in NodeJS and uses a node module I come across called node-gpsd. This handles the parsing of the raw GPS data that you saw earlier and returns a constant stream of GPS data in the form of a JSON object. I then setup the necessary IAM roles and policies in AWS so that only the Lambda has permission to read/write to the DynamoDB table and Cloudwatch for logging. I also setup an AWS gateway and added a POST method that is passed to the Lambda that just handles putting the data into dynamo, nothing else.

Here is how it looks in AWS Gateway:

And here’s what the DynamoDB table looks like (with the coordinates retracted):

NOTE: I should note that the tracking application determines whether to send the location by checking to see if the vehicle has moved by matching the previous sent coordinates to the current coordinates. This saves bandwidth and write units on DynamoDB.

Repositories

You can clone the repositories for both projects from Github.

Summary

I will improve this article soon and provide images for you to see what I have done visually and provide the source code for my Lambda and tracking application.

I have tested this system and it works very well, the location is highly accurate!

Please feel free to leave a comment on any questions you may have and i’ll try my best to help you.

How to run Boinc & BoincTUI on the Raspberry Pi

Before we start, I would like to take this time to explain what BOINC actually is.

What is BOINC?

BOINC is an open-source piece of software that allows users to volunteer their computers idle time to carry out scientific research. This in turn is called Grid-Computing. In other words, you can register to become part of a project which uses your computers’ idle time to search for new cures for diseases or help gain a better understanding of our galaxy. There are plenty of research projects available which you can find here.

Installing BOINC on the Raspberry Pi

In order to install BOINC on the Raspberry Pi, you will need to make sure that you have enough space on the SDCard. Other than that, you can go ahead and install it by typing in…

This will install BOINC and the GUI if you want to Remote Desktop (presuming its headless) into the Pi and check up on your projects instead of using the text interface.

Installing BOINCTUI on the Raspberry Pi

This was a little frustrating at first, however I managed to get help on the Raspberry Pi forums from a user named ghans.

Start off by navigating to the home directory by typing in cd ~/. Then type in the following to download the source code into the folder “boinctui” – presuming you have subversion installed. If not, then type in

Download source code –

After the source code has downloaded, cd into the directory by typing in “cd boinctui” – without the quotes.

Then follow, in order, the commands listed;

The compiling took me about 20 minutes give or take with my Pi over-clocked @ 1GHz.

NOTE: If you get any errors about missing libraries when running ./configure, you may need to run the following commands;

Once it’s finished, type in boinctui to load the Text-Based Interface and ta-da!. You can now manage your boinc-client with ease.