The goal of the project was to build an easy to install out-of-the-box asset tracking solution. In order to make that work, we had to source reliable hardware, program the SIM cards, set up a gateway for the GPS tracking devices, and build out the Losant workflows and dashboards.
For this project, we decided to go with the Queclink GL505 GPS Trackers with Hologram SIM cards. These devices can be programmed by sending an SMS message with comma-delimited information to configure the device.
First, we’ll set up the gateway to collect and parse data from the GL505s. You can grab the following source code from GitHub and deploy it to a public accessible server. The code listens to data coming from the GL505 on port 8000. It parses the data, then sends it to Losant.
GitHub: https://github.com/Losant/losant-poc-asset-tracker-blog
Then, we’ll provision the SIM cards in Hologram. They provide easy step-by-step instructions to do this.
When you are done provisioning the SIM cards, insert them into the GL505 devices and follow these steps in the Hologram Dashboard to send the following commands to your device:
Device Command 1 (Configures device to send data to your servers): AT+GTQSS=gl500,hologram,,,2,,0,[YOUR SERVER IP],8000,[YOUR SERVER IP],8000,,0,0,,,FFFF$
Device Command 2 (Sets up hourly reports and then sleeps device while not moving): AT+GTNMD=gl500,8,2,4,15,240,,,,FFFF$
This tells it how often to report, what IP to report to, and what port to send the data.
For more details about how to program the GL505, read the manual.
Now, we’ll need to create an application, and set up the devices in Losant. We are setting up 3 types of devices: “Gateway” (This receives data for all GL505 devices) , “GL505” (This stores data that comes from the gateway), and “Asset” (This contains some properties directly set from the GL505, and additional calculated properties from a workflow).
You can import the device recipes from your "/device-recipes" folder from source code to your project. After you import the recipes, create these devices from your recipes:
Create your Access Keys, and update the config.js file in your gateway code with your access key and GL505 Gateway device id. Re-deploy your gateway code to your server.
Now, we'll add the following application globals:
Now, we’ll setup the workflows. You'll have to create the following workflows, and import the files from your "/workflows" directory in your source code to Losant:
After you import your workflows, At this point, you should have a working application. I’ll cover the details of each workflow below:
If you open up your GL505 Report workflow, you can view the activity by viewing the debug panel.
Notice that it receives the data from the GL505 device. Next, it checks to see if the device movement status has changed and if the device is outside of the geofence. Then it updates the state of the asset with those properties.
If you open up the Geofence Alert workflow, you’ll notice that it is triggered by the asset state being reported. It checks to see if the device is outside of the geofence, then it triggers the Email Alert and SMS Alert workflows.
The Movement Alert workflow is also triggered by the asset state being reported, so it is running simultaneously as the Geofence Alert workflow. Similar to the Geofence Alert workflow, it checks to see if the device is moving or not, and triggers the SMS Alert and Email Alert workflows if necessary.
Next steps:
Now that your devices are reporting data, you can create your dashboard from the data from your devices. Here at Losant, we are interested to see what problems you are trying to solve. If you have any questions or feedback, please leave a comment or contact us.