How to send a single value 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/fieldname";

The topic is structured in this way:

  • up means device-to-cloud
  • clientID is your client identifier (replace with your client ID)
  • deviceId the communication device identifier (replace with your device's unique ID)
  • fieldname is the code name of the field in the asset's schema (replace with your field name).

The payload should be just the value of the field at that time e.g.:

2.2

or

true

Note that there is no way to specify a timestamp using this method; the server will use the time at which the data is received.