How to send simple data using MQTT

Recall our structure of sending data from an asset, via the MQTT broker, to Assetwolf:

MQTT diagram 1

Publish to send data

Assuming your device is connected using MQTT, it should publish its data to:

$sensorTopic = "up/client/clientId/asset/deviceId";

The topic is structured in this way:

  • up means device to cloud
  • clientID is your client identifier)
  • deviceId the communication device identifier.

The JSON payload should look like this (but you can remove newlines and spaces):

    "timestamp": timestamp,
    "field1": "boolean",
    "field2": integer,
    "field3: float,
    "latitude": latitude,
    "longitude": longitude,
    "field4": "string",
    "field5": "state_indicator"

Notes on field types

You do not have to send all fields that are defined on the schema for this asset. It's quite normal to send partial data, or that the full set of field data is only sent occasionally.


Optional! You only need to send this if you want to be specific about the time that the current data refers to, or if you wish to send data for sensor readings taken in the past. Must be a Unix microtime (milliseconds since 1970).


Must be either "true" or "false" (with double quotes).

integer, float

You can send integer and floating-point numbers, no quotes are necessary.


Be sure to use double-quotes (not single quotes) around all alphanumeric fields. Numeric fields can have quotes but they are optional.


If the asset has a state indicator, such as a run mode, you can send a state indicator, such as "1", or "on" for example. This can be used to display an icon within the portal (on a schematic floorplan, a list of assets, or on an asset's status panel).

Checking your data is arriving

On the Dashboard on your portal, and look at your assets. If all is well, you should see some data has arrived.

Google ChromeScreenSnapz780.jpg 

Minimising the amount of data sent with short aliases

When editing the schema for the asset, you will notice a small "+" sign in the list of "Incoming data from asset". You can use this to specify an short alias.

Here for example a floating-point field is called "lightlevel", but to the Superuser is adding a short alias "L":

Google ChromeScreenSnapz2227.jpg

In the data transmission, the value of this field can now be sent with a reduced data size. Without the alias the format would be like this:

    "lightlevel": 499

With the alias defined, data can now be sent like this:

    "L": 499