Simulate IoT real time messages with Mapify Data Feed Simulator

Introduction to the Mapify Data Feed Simulator tool


TL; DR;


In this post we’ll show yo how you can use Mapify Data Feed Simulator to simulate real time MQTT messages being sent by a fictional vehicle to a Mapify Data Feed. You can use this tool to quickly and easily test your Mapify Workflows and IoT real time processes without requiring you to set up physical devices. And all of that without having to write a single line of code!



It is not the purpose of this article to explain or deep dive into Data Feeds, Workflows or other Mapify features, so we will assume you have read some of the previous articles which focus on those topics.


Requirements

  • Mapify account (you can request a trial account here)

  • Mapify API Key (to be used by the simulator to connect to your account)




Make sure the API Key selected for this example has both read and write permissions for the “Data Feeds” claim.



If you want to dive right in the deep end without following this tutorial, feel free to request a Mapify trial here, or click here to schedule a talk with us, and start creating your location intelligence solutions today!



One of the most well known uses for a real time sensor feed is to track moving vehicles, and to create rules for monitoring those vehicles, such as defining geo-fences and alerts.


In this article we will simulate a moving vehicle’s Data Feed and show you how you can quickly and easily setup and configure your own tracking solution without writing a single line of code.


The first thing is to specify the JSON schema of the incoming messages originating from our fictional vehicles. For this example we will consider the messages’ JSON schema as shown below:


{
  "type": "object",
  "properties": {
    "id": {
      "type": "string"
    },
    "gear": {
      "type": "string"
    },
    "temperature": {
      "type": "number"
    },
    "doorOpen": {
      "type": "boolean"
    },
    "location": {
      "type": "object",
      "properties": {
        "type": {
          "type": "MultiPoint"
        },
        "coordinates": {
          "type": "array"
        }
      }
    }
  }
}

Each message will have a string id attribute to identify the vehicle license plate from which the message originates, a string gear attribute for the currently engaged gear, a numeric temperature attribute which contains an engine temperature value, a doorOpen boolean attribute to determine if the vehicle’s cargo door is open, and an object attribute for the location information of the vehicle.


For the sake of this article, let’s imagine that we want to simulate a vehicle with license plate “ABC123”. We will simulate changes in the vehicle’s engine temperature, current gear, if its cargo door is open, and display the vehicle latest position in real time on a map.


That’s all we need to start using our Mapify Simulator!


Create a Dataset


First of all, we will create Dataset named My Vehicles Fleet to hold the latest vehicle positions data. This will also allow us to make real time updates to its data through a Workflow, and render it using a Mapify Realtime Layer. Add the following attributes to the Dataset:


​Attribute

Type

Nullable

Default Value

Unique

geom

Point

id

Text

X

gear

Text

X

temperature

Numeric

X

dooropen

Boolean

X



Create a Realtime Layer


In order to be able to later render the vehicles, you need to create a Mapify Realtime Layer based on the My Vehicles Fleet Dataset. The screenshot below shows the creation screen for the My Vehicles Fleet Layer:



Create a Data Feed


Next, let’s create a Push (MQTT) Data Feed named vehicle-trackers to handle the incoming messages that the simulator will generate.

This will be the JSON schema of the messages “sent” by the fictional vehicles as previously defined:


{
  "type": "object",
  "properties": {
    "id": {
      "type": "string"
    },
    "gear": {
      "type": "string"
    },
    "temperature": {
      "type": "number"
    },
    "doorOpen": {
      "type": "boolean"
    },
    "location": {
      "type": "object",
      "properties": {
        "type": {
          "type": "MultiPoint"
        },
        "coordinates": {
          "type": "array"
        }
      }
    }
  }
}

Copy the JSON schema above and paste it in the Data Feed schema input box.


After saving the new Data Feed, you will be ready to create a simple Workflow which you will later use to confirm that the messages are arriving and being processed by Mapify.


Create a Workflow


Create a new Workflow named vehicle-tracking, and add a new Source node. In the Source node, select the previously created vehicle-trackers Data Feed as its source.



Below the Source node, add a Dataset sink node to persist the latest data from the received message to the My Vehicles Fleet Dataset, and configure it as illustrated in the screenshot below.



Now, below the Dataset sink node, add a Email sink node which cause an email to be sent when a new message arrives.


Specify the email subject as


Vehicle ${id} message received!

Add your email to the “To:” input box, and for the email Body, type something such as:


Vehicle ID: ${id}
Gear: ${gear}
Temperature: ${temperature}
Is Door Open: ${dooropen}

After adding the nodes above, your workflow should look something like the screenshot below:



Simulate those messages!


You are now ready to simulate the vehicle tracking messages, so open up Mapify Simulator on your browser, by navigating to https://simulator.mapify.ai.


Paste your Mapify API Key in the API Key input box, and the click the Data Feed list to select the previously created vehicle-trackers Data Feed. The Data Feed schema will be automatically detected and a template for the generated messages will be displayed below in the Template tab:


Mapify Simulator is able to generate values for the message attributes, but we need to provide some additional information for the generated values to conform to what one of our fictional vehicle trackers would send.


Let’s start with the id attribute, which is