Software apps and online services
Hand tools and fabrication machines
I'll probably be completing this project and moving it to my own blog shortly, with real-time tracking. It's possible - yet not guaranteed - that I'll make the kit available as a service, so you just have to install it and pay a - minimal - subscription to enjoy all the benefits. Would cost you probably something around USD5 a month (including the particle subscription), and you'd have the ability to interrupt or reactivate the subscription anytime (by month periods, still), so that you don't spend money on it if you don't use it.
If you're new to the maker world, and not really familiar with the various providers involved in this (Particle, Amazon AWS, Google APIs) then this could be a difficult project for you. I'd suggest you first get acquainted with Particle and their various platforms and tools, so that you get a better understanding of how firmware is written and updated, what an IDE is and how to use it; then you should get an idea of what Amazon AWS is, in particular what AWS Lambda, DynamoDB and API Gateway do, and how AWS IAM deals with security; as a final step, you should learn how to work with Google Developer console and create API credentials.
It could be quite easy to follow a step-by-step screenshot tutorial, but then I would need many hours to write it, and I don't really have so much time on my hands at this point, so the explanations may be a bit scarce at first, and I'll complete the best I can later on, based on comments and feedback.
For all those reasons, I'll upgrade the difficulty level of this project to Advanced for now, and will move it back to Intermediate when more detailed steps are added in.See Updates at the bottom...
I'm adding a section with updates, so just scroll down if you already know the story...What This Is
I wanted to track my motorbike if stolen and/or when riding around. I had just received that Kickstarter 3G Asset Tracker kit from Particle that I had initially planned to use to track my car's position and speed while my stepson was driving it, but hey my bike was more important that spying on my stepson's habits, so I decided to use it to locate the bike and possibly more.
First step was to code some firmware for the tracker, using both acceleration data from the embedded accelerometer and GPS location from the tracker. I also wanted to save the amount data used: Particle's cloud plan allows you 1MB per month for $2.99 and any additional 1MB costs you $0.99 more, so the less the better; so I had to play with several parameters: how often to send data over the 3G connection, how much data, and finally which data. I came to something quite efficient, saving measurements in memory between each publish event, and publishing sparsely, but with a pretty good result: a 15s position precision.
When the first step was done, and everything was sent to Particle's cloud, I started working on the data storage part, using AWS (Amazon Web Services) for that purpose, called by Particle's webhooks:
- AWS API Gateway receives the call from Particle with the data in the payload
- AWS Lambda extracts, cleans and processes the data
- AWS DynamoDB stores the data
Last step was to display the data on a nice Google map, using some Google APIs. I'm still working on making that display more dynamic, but refreshing the map already shows the position in real time.
Next step will be to add some nice features to the projects, like:
- switching off the engine remotely (too bad, Mr. Thief...)
- switching the horn and/or lights on and off
- showing colour changing lights based on your speed and/or acceleration
- anything else that looks and sounds nerdy enough...
- add a phone app to do these easily
Below is an example of a few recent trips (currently set to show last 12 hours, but that can be configured in the page). Some imprecision may occur occasionally with GPS positioning, but it's minor errors mostly since trivial errors are automatically discarded (on a recent day display was showing a sudden minute' trip to China, due to a dropped sign in the GPS information...)
Click here for my bike's latest trips (last 24 hours)How Hard to Build / How Much Time
Building the hardware is pretty straight-forward: you just have to buy the 3G Asset Tracker kit from Particle, for the region where you will be using it: America/Australia or Europe/Asia/Africa (details of countries on Particle's site). Then you plug the Electron (Particle's micro controller board) on the 3G Tracker Shield, then you plug the LIPO battery, the 3G antenna and an external GPS antenna (bought separately, I recommend using one, because GPS tracking won't work well without it, trust me, I tried...).
- Time: 5 minutes
- Difficulty: none (the hardest part being plugging the antennas on the micro uFS connectors)
2. Hardware II (optional)
I added two push buttons on my enclosure because I needed to be able to reset, test or set up the box specifically, without having to open it every single time to press the two tiny buttons on the Electron board.
In fact the added buttons are quite cool, because they allow me to:
- reset the box - you never know, things sometimes go wrong... ever used Windows?
- put the box in USB firmware update, so that I don't use my 3G bandwidth to update the firmware
- force a GPS publish manually
- put the tracker in privacy mode
I know I mentioned 2 buttons, but you can also combine them and press them for more or less time ;-) Since I mounted the buttons on the outside of the enclosure, I needed to drill through the box (you'll need a drill) and solder some cables to connect them to the main board (you'll need a soldering iron). I made the system so that an unexpected pressure on the buttons doesn't do anything (e.g. the reset button needs to be pressed at least 3 secs to actually reset the box), everything else requires using box buttons together or in a sequence.
@TODO: describe how/where to connect the switches
- Time: 30 minutes to 1 hour
- Difficulty: easy if you can use an soldering iron and a drill
3. Particle Registration
You'll have to register the Electron with Particle's cloud. Process is relatively easy and well documented. It is relatively straight-forward and you do it online, using the 3G connection, so no worries connecting the Electron to your local wireless network or anything, you just need a browser with a connection to the internet and your kit plugged to any powered USB connector.
I won't reproduce all the details of the process here, you will get them along with your Electron kit. If you want to learn about that part before you get your electron, visit the Particle Getting Started page for the Electron.
- Time: 5 min
- Difficulty: None
4. Software install on your PC/Mac
To update the firmware on your electron you may need to install one or more tools, depending on how you want to compile and upload the firmware.
Simple way: you install nothing, and you use Particle Build online - you'll use the latest version of libraries with no effort but will waste some of your data (30KB more or less) each time you update the firmware.
Intermediate way: you install Particle Dev tool, you fork the libraries onto your computer, you compile and upload using the firmware in the cloud, still using your data - not so much benefit at this point...
Hard way - yet more efficient: you install Particle Dev then the Particle Command Line Utility (CLI), you fork ("git clone") the libraries onto your computer, and you use the CLI to compile and flash your electron via USB (no data used)
In no case it is necessary to be a software developer to succeed in those steps, but the harder it gets, the easier it will be if you have those skills and understand what you're doing.
Based on the path you choose, follow the installation procedure informed by Particle. We'll discuss how to fork the libraries in the next step.
- Time: 10 minutes
- Difficulty: None
5. Firmware compile and upload (see code in corresponding section)
So, in this part we'll compile the firmware and upload it to your electron, either via USB or OTA (Over The Air) depending on the tools you decided to use. But first you need to get the main code and the necessary libraries into the IDE (Integrated Development Environment, that is Particle Build or Particle Dev).
a) Download GPSTracker.ino and open it into Particle Dev/Build
b) Download my slightly modified version of AssetTracker.cpp and AssetTracker.h (gets Lat and Lon in degrees, separately)
c) Compile and flash as follows:
c.1) Simple: paste everything online into Particle Build, select your electron, click compile, click flash, pray...
c.2) Intermediate: create a new project folder in Particle Dev, copy the 3 files into it, select your electron, compile, flash, pray... pretty much the same to be honest, but I personally don't like online IDEs so much so this suits me better :)
c.3) (somehow) Hard(er): do the same as c.2, so that you can see the files - if you're curious - and have them in the same folder - required, but then open a Terminal window, change directory to that folder (cd), and run
particle compile electron
if you called - like me - your electron "electron" (how original!). If everything went fine, then plug your electron via USB, switch to programming mode (press mode for 3 sec until the light goes to a blinking blue) and run
particle serial flash $(ls -lrt electron_firmware_*.bin|tail -1)
on mac or linux; on windows, you may want to find the latest firmware .bin file generated (using
) and run
particle serial flash
(hey, wait, is particle CLI even running on windows...?)
d) If and when everything goes fine, you should see your electron reset, then go through its connection cycle and end breathing cyan, then you should see events coming into your particle dashboard (alternately you can use
particle subscribe mine
to see them); finally if all this doesn't make any sense to you, just don't worry and go to next step (and possibly pray everything works...)
- Time: 5-10 minutes depending on your abilities and level of confusion.
- Difficulty: Easy
6. AWS services set up
- Time: 30 minutes to 1 hour (depending on your experience with AWS)
- Difficulty: Medium
7. Google API setup
- Time: 5 minutes if you have a google account
- Difficulty: Easy
8. Web page configuration
- Time: 1 minute if you can use a text editor
- Difficulty: Easy
9. Web page publishing on your provider
This steps is variable and depends on your web services provider, if you have any. It can require you to use FTP, SCP, SSH or other apps and also to set up your web server. If this sounds like nerd stuff to you then you should probably skip that part or have someone explain to you because it's definitely out of the scope of this project. Note that this cannot be trivially achieved on a Wordpress blog (although it can be done on a self-hosted one, with some knowledge)
- Time: 10 minutes to hours depending on your provider and your skills.
- Difficulty: from easy to complex.How Much Will it Cost Me?
Costs can be decomposed as follows:
- $130 for the 3G asset tracker kit (little less for a 2G asset tracker kit, not tested)
- some $20 to $30 to get a USB connector on your motorbike (no cost on a car) - see your usual bike dealer, I recommend an Optimate 100 which will prevent draining your battery in case things go wrong...
- $13 for the GPS antenna at Adafruit
Then you also get recurring costs:
- $3 monthly subscription to Particle Cloud (unless you pass the 1MB limit, then you'll pay $1 more per additional 1MB)
- around $1 monthly for the Amazon Web Services
- Still have to add a few parts in there, just haven't had so many comments showing any interest in it, so maybe I'll do that when some people really want to set the tracker up for themselves...
- Also, I improved the map page, with better random colors and a snap button to snap the GPS positions to roads... Still gives a few weird paths sometimes, but other than that it works pretty well. I switched my own map to 48hours, since I don't necessarily ride everyday, so feel free to check it here.
- I'm thinking of leaving all specific API keys and URLs in specific external files, so that I can publish all the code on github. Again, let's see if there's any interest first, not sure everyone here even knows what github is :)
- And here are 2 new recent map snapshots (regular and snapped):