I've built several trackers using Particle's Electron Asset Tracker kit in the past and wanted to document how easy it could be to create your own tracker using MySignal.io's MQTT library and start tracking assets in a matter of minutes.
First step is to create an account or sign in over at MySignal.io and create a new device.
Once the device is created, it will be assigned a Device Token which will be needed a little later.
Over at Particle's IDE, click on the Libraries icon and search for SignalMQTT. Once you select the SignalMQTT library (at the time of this writing, the library is version 1.0.7), you will find an example app called AssetTrackerExample.ino. Select that file and click the Use this Example button. This will create a new app for you.
The only thing you need to change in this file to make it work, is the TOKEN at line #7. You need to paste the device token you received earlier from MySignal.io in between the quotation marks.
By default the code is setup to publish your coordinates every 10 seconds, which is probably not ideal long term. To change this, you can modify the value of delayMillis to whatever you like.
The final step is to include Particle's Asset Tracker library. Click on the Libraries icon once again, and search for AssetTracker (or it should be on first page of the libraries list). Select the library, click the Include in Project button.
You'll be asked to which app you want to add it to. Select the AssetTrackerExample app (or whatever you may have renamed it to) and click the confirm button.
By default, the Particle IDE will automatically add the #include statement for the asset tracker library at the very top of the code but the AssetTrackerExample.ino already has it included. It shouldn't cause any problems, however one of the two lines can be removed.
Save the code, click the verify button to make sure there are no errors and then flash your device with the new code.
NOTE: Make sure your Electron firmware version is 0.6.1 or above. It is not guaranteed to work for anything lower than that version.
Once your asset tracker has a cellular connection and GPS fix, it'll submit the coordinates over to MySignal.io and you should see your asset on the map in real-time.
Comments