How We Built the PoC Asset Tracker

Bao Nguyen
Bao Nguyen | 4 minute read

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.

Asset Tracker Kit

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:

  1. Click on your Hologram device
    Hologram Devices
  2. Scroll down and click on the “via SMS” tab
    SMS Message
  3. Send the following commands (Wait about a minute between sending commands):
    SMS Messages

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:

  1. GL505 Gateway (from the GL505 Gateway recipe)
  2. GL505 #1 (from the GL505 recipe)
    1. Update the IMEI tag with the IMEI number on your GL505
  3. Asset #1 (from the Asset recipe)
    1. Update the IMEI tag with the IMEI number on your GL505

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:

      • SMS (String): Phone number used to receive alerts.
      • EMAIL (String): Email used to receive alerts.
      • GEOFENCE_CENTER (String): This is the latitude and longitude coordinates to use as the center point for your geofence-based alerts.
      • GEOFENCE_LIMIT_MILES (Number): Set the radius distance in miles for your geofence alerts. Ex: If this field is set to 20, you will be notified when your assets are 20+ miles away from your GEOFENCE_CENTER coordinates.

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:

  1. Gatway Report
    1. Import "gateway-report-develop.flow" and deploy workflow.
  2. GL505 Report
    1. Import "gl505-report-develop.flow" and deploy workflow.
  3. Email Alerts
    1. Import "email-alerts-develop.flow"and deploy workflow.
  4. SMS Alerts
    1. Import "sms-alerts-develop.flow" and deploy workflow.
  5. Geofence Alert
    1. Import "geofence-alert-develop.flow"
    2. Click on the Email Alert node, and set the following properties:
      geo-fence-email-alert.png
      1. Workflow: Email Alerts
      2. Virtual Button: Virtual Button
    3. Click on the SMS Alert node, and set the following properties:
      geo-fence-sms-alert.png
      1. Workflow: SMS Alerts
      2. Virtual Button: Virtual Button
  6. Movement Alert
    1. Import "movement-alert-develop.flow"
    2. Click on the Email Alert node, and set the following properties:
      movement-email-alert.png
      1. Workflow: Email Alerts
      2. Virtual Button: Virtual Button
    3. Click on the SMS Alert node, and set the following properties:
      movement-sms-alert.png
      1. Workflow: SMS Alerts
      2. Virtual Button: Virtual Button

After you import your workflows, At this point, you should have a working application. I’ll cover the details of each workflow below:

  1. Gateway Report - This is the workflow that receives data from the Gateway. It parses the data coming and updates the state of each GL505 device in Losant.
  2. GL505 Report - This is the main workflow that is triggered from state data from the GL505 and takes action on that data to set the properties on the asset device. It has these main objectives:
    1. It detects if the asset is outside of the geofence
    2. Sets the properties of the asset device
  3. Geofence Alert - This will notify you by email or SMS if your asset is outside of your geofence.
  4. Movement Alert - This will notify you by email or SMS if any movement is detected on your device.
  5. Email Alerts - This workflow sends you email alerts. If this workflow is disabled, you will no longer receive alerts by email.
  6. SMS Alerts - This workflow sends you SMS alerts. If this workflow is disabled, you will no longer receive SMS alerts.

If you open up your GL505 Report workflow, you can view the activity by viewing the debug panel.

debug.png

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.

gl505-report-workflow.png

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. 

geofence-alert-workflow.png

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.

movement-alert-workflow.png

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.

dashboard.png