The MQTT interface supports a bi-directional communication method including all features of the MQTT protocol e.g.
  • Keep alive
  • Last Will
  • Quality of service
By using the MQTT interface the device can send any data to the M2MGO, e.g. device can send the temperature value to the M2MGO.
The other way around, the M2MGO can send the command to the device, e.g. the M2MGO sends a command for triggering the GPIO to the device.



MQTT Topic

The MQTT topic format consists of

  • Blueprint Id
  • Device Id
  • Data Type

m2mgo/<Blueprint Id>/<Device Id>/[data | attributes | location]

The Blueprint Id is generated by M2MGO when you create a new device type. You will find the Blueprint Id on the Blueprints widget

The Device Id needs to e defined by you. You need to make sure that the Device Id is unique within your Blueprint

Data type describes the kind of data you want to send to M2MGO

data – any sensor data, e.g. temperature. See the data format in the next section

location – the location value. See the data format in the next section

attributes – device attributes, e.g. device color. See the data format in the next section

Example mqtt topic when sending data to M2MGO: m2mgo/123-231-4567-7654/dev_375/data

MQTT data payload format

M2MGO supports two common data payload formats Key/Value pairs and JSON format
  • Key/Value pair: The Key/Value pair has following structure
    The Key/Value pairs can be combined
    Example: temperature=25&light=450&message=any text message

  • JSON: The JSON format has following structure:

    {"message":"any text message"},

Sending Commands to the device

The user can send the commands to the device, e.g. the user sends a command for triggering a switch on the device.

The M2MGO will send the data in following MQTT topic format:
Mqtt topic: m2mgo/<Blueprint Id>>/<Device Id>/command

  • Blueprint Id – Id of your blueprint
  • Device Id – Id of a particular device
  • Command– a key for the command

This means that on your device you will need to subscribe tot he mentioned MQTT topic. The data will arrive as you define it in the blueprint. You will need to parse the data in your device application and perform the appropriate action.

Example mqtt topic: m2mgo/123-231-4567-7654/dev_375/gpio1=high