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


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 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.


You can clone the repositories for both projects from Github.


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 setup an Access Point via hostapd – Including using the TL-WN725N


I recently had to setup an Access Point using my TL-WN725N which allowed me to share my internet to multiple devices whilst my in-built WiFi on my laptop was connected to a WiFi Access Point with an internet connection. This was because only one device could be connected using the access code which I paid quite a lot of money for and thus I couldn’t connect my phone, or other devices.

In this tutorial, I will guide you through step by step on how to install the required software, and use a very helpful piece of software that does all the hard work for you.

Install the required software

Download and Install create_ap

create_ap is an excellent piece of software that manages hostapd and all the networking for you. It is run via command line and is very easy to use. You can read the README for it here on Its github page.

In order to install this, we are going to create a directory called “src” in the home directory. This is where we will download the code to and run the install command from.

NOTE: The install command places the file in /usr/bin or /usr/local/bin so it can be used from the command line without specifying its directory.

Start an AP

In order to start an Access Point (AP) we need to know what the device is called.

Run the following command;

We should see something like this;

NOTE: I removed my MAC Address and replaced it with numbers for privacy 🙂

I know wlan1 is going to be my Access Point adapter since I ran ifconfig before and after I plugged it in. All you need to know now is the other name of the device you want to share internet from.

To start an AP with wlan1 as the AP, and let’s say, wlan0 as the source adapter which is currently connected to a WiFi network with internet access, then run;

This should start up correctly and you should be able to find and connect to the WiFi AP. When you connect, you should be able to use the internet. You can find more examples by reading the README on the github page.

Using the TL-WN725N as an AP

If you followed everything above and it fails to start an AP, this is probably because you need to download a special version of hostapd for Ralink support. This is what I had to do in order to use the TL-WN725N USB adapter which uses the ralink drivers.

Before we start, let’s remove hostapd since we’re going to compile and install our own version;

Now we download hostapd to our src directory and extract it;

And finally, compile and install;

The last step will move the compiled hostapd binary to /usr/local/bin, add a startup script and create a configuration file in /etc/hostapd/hostapd.conf.

Now it is a good idea to reboot your device and then try and use the command above with the “–driver rtl871xdrv” paramter to start an AP. Hopefully it works!

An example would be;

How to install FFMPEG, Libx264, LibRTMP, LibAACPlus, LibVPX on the Raspberry Pi (Debian “Wheezy” ARMHF)

In the past I’ve had to been required to install FFMPEG for applications such as Serviio or a website like Clipbucket. It can be quite stressful since you could get dependency issues if you tried reading any other tutorials online, since the worst nightmare is if something breaks when you have compiled software using wrong dependencies. But this tutorial should ensure that it’ll work first time.

 UPDATE (12/10/2016): I’ve since updated this tutorial to add two new codecs for FFMPEG. I’ve also changed the FFMPEG repository to the official one rather than VideoLan. I’ve tested this complete tutorial for my Raspberry Pi 3 and it works fine.

Removing any existing dependencies

It’s vital to uninstall everything we’re going to be compiling/installing just in case there have been custom compilations of software that might be corrupted or broken. I’ve had a few errors in the past which resulted in “Illegal Instruction” when executing “ffmpeg” in the terminal.

Just copy and paste this into your terminal and hit enter. Type y and hit enter when necessary.

Downloading the Dependencies

Copy and Paste the commands below. When it asks, type and press Enter. This will download and install everything we need for later on.

Downloading & Compiling FFMPEG AND It’s Modules

Before we get started, we will be working inside a folder within the home directory. It is important not to remove this file in-case you want to uninstall anything later. Type the commands below in order and follow through.

Downloading & Compiling LibaacPlus

Again, type the below commands in order, and then move onto the next step.

Downloading & Compiling Libx264

 Downloading & Compiling LibVPX

NOTE: if you see the command output for “./configure” incorrectly identify the Pi as ArmV7 instead of ArmV6, try running the configure command again with the following parameter;

Downloading & Compiling LibRTMP

Now, before we move on, it’s important to run the command

This will update the system and make it aware of the new packages which have been installed.

Downloading & Compiling Libfaac

When you’re in the nana editor, you will need to go to line 126. Once you’re at that line, make the below code the same as in the file…

Once you’re finished, press CTRL + O to save, and then hit enter, then press CTRL + X to close the editor.

Then carry on…

It’s important to do a reboot just to make sure everything is being recognised and found.

Downloading & Compiling LibFDK-aac

Downloading & Compiling FFMPEG (Latest Version)

NOTE: This took my Raspberry Pi (Model B) around ~2 hours when overclocked to “Turbo” – 1GHz.

Finishing up

Now that FFMPEG has been compiled and installed successfully, we will need to reboot to make sure that everything is working. Type in;

When the Pi boots up, type in “ffmpeg” and you should see an output similar to that of what I get below;

And that’s it! You have now successfully installed FFMPEG on your Raspberry Pi! 🙂


The Raspberry Pi is a small credit-card sized computer. It’s very low powered and can be powered by a mini-usb cable and USB plug, such as a modern day phone charger. The Raspberry Pi (Model B) has a stock 700Mhz Armv6 processor and 512MB of RAM. The processor can be overclocked in the configuration to a maximum of 1Ghz (WARNING – Overclocking the Pi may void your warranty and break it).

When software utilises FFMPEG, you will see that it may bring the processor usage to 100% on the pi. This will cause the SoC to heat up rapidly unless you have a heatsink or some other form of cooling. At 100% CPU utilisation, the temperature without a heatsink can reach up to 80 Degrees Celsius!

Feel free to comment below and ask any questions!

It’s been a while

It’s been a while since I last wrote a blog post. I thought I’ll just give you all a quick update as to what is going on right now.

In September I started college studying Electrical/Electronic Engineering at Level 3. It’s been over a month since then and I’m really enjoying it. Never the less, I still continue on with my projects at home. A few days after enrolment day, I mounted a 100W solar panel on my roof. This connects to a solar charge controller which controls the voltage/current going to the battery. Right now I only have one single leisure battery and require more for my project to be completed. My aim is to completely run this room from solar. I only ever use the light, computer, and my home server which is planned to stay on 24/7. In total the wattage adds up too… 600W(pc) + 250W(home server) + 25W(light) = 875W. Currently, the system powers the room light and my phone charger.

Right now I’m seeking a job in order to complete this project.

This Single Molecule Drives Cancer Cells to Suicide

biologyA team of researchers has identified a single molecule, called TIC10, that kick-starts the body’s tumor-destroying systems—causing a chain reaction that can kill cancer dead.”. “In a series of experiments in mice the researchers, from Pennsylvania State University, found that TIC10 activities the gene for a protein called TRAIL—that’s short for tumour-necrosis-factor-related apoptosis-inducing ligand—which causes cancerous cells to commit suicide.”

Read the full article here.

US Military installing Laser turrets on combat airplanes

laser_turret_wire2.jpg7fc930b2-07db-467d-bf77-6dcfa968ad88LargeWell, could this be the future? I’ve researched laser beam weapons before being used on military aircraft carriers as a means of taking down drones or UAV’s or missiles… But to think that this might actually be the start of the energy weapons phase; leaving behind bullets as “old fashioned” and using directed energy beam weapons as a more powerful and efficient weapon against threats.

Read more here.

View the Earth in HD

download“Canadian company plans to one-up Google Earth by streaming video footage straight from the International Space Station to the web with a top time delay of just a few hours.”

Sorry, there was a mistake here. They will be streaming sometime in summer. Keep checking here for any latest news until then!

“Urthecastis due to begin beaming the view from the ISS by autumn 2013 — the equipment will be finished by the summer, then shipped to Russia and sent to the space station via two Soyuz rockets. Once there, the Russian space agency will install it beneath the ISS and downlink the data to Earth where it will be published.”

Check their website here.