In this tutorial we will explain EasyIoT Cloud MQTT API. EasyIoT Cloud MQTT works as MQTT broker and it is connected to EasyIoT Cloud database.

MQTT is a machine-to-machine (M2M)/"Internet of Things" connectivity protocol.  It is designed for connections with remote locations where a "small code footprint" is required or the network bandwidth is limited. EasyIoT Clud implements MQTT broker connected to EasyIoT realtime database. This mean that MQTT data can be easily displayed on EasyIoT Cloud WEB interface or native mobile application. MQTT EasyIoT Cloud implementation uses some special topics to control database settings and this is specific to EasyIoT Cloud implementation.

Important difference between classic MQTT broker is that EasyIoT Cloud broker does not publish messages originated in MQTT clients. It only publish messages from  sources other than MQTT client like WEB interface, native mobile application or automation module. Also EasyIoT Cloud MQTT broker uses some special topics to configure EasyIoT Cloud.

MQTT address

EasyIoT Cloud MQTT broker address is cloud.iot-playground.com and port is 1883.

Authentication

MQTT uses authentication. To login to EasyIoT Cloud MQTT broker use the same username and password as to connect to EasyIoT Cloud.

MQTT Publish/Subscribe topics

In EasyIoT Cloud all data are stored as module parameters. This parameters are easily visualized or controlled in EasyIoT Cloud WEB interface or native mobile application. Module parameter is visible in EasyIoT Cloud under Configure->Modules and click to one of modules in list on right side.

module configuration

On module configuration screen we see Module Id. This ID is included in MQTT parameter topic. To see parameter click to one of parameters on the list.

module parameter

On module parameter configuration screen is visible parameter MQTT topic. Copy this topic if you want to control parameter value.

MQTT topic

 

Parameter topics is:

/[module id]/[parameter name]

Where:

Module id is module id visible in module configuration screen.

Parameter name is name of parameter.

example of parameter topics is:

/7/Sensor.Parameter1

 

Sometimes we want to connect to MQTT device with different topic. In this case enable "Is custom MQTT topic" and enter custom topic in "Custom MQTT topic" filed.

Custom MQTT topic 

Topic visible on parameter configuration is topic to which we subscribe if we want to receive changes of parameter value or publish if we want to change value of parameter.

All clients with incorrect topics will be disconnected automatically.

 

EasyIoT Cloud MQTT special topics

EasyIoT Cloud uses some special MQTT topics to control EasyIoT Cloud database. This topics are used to add new module or parameter to database and to set properties of module or parameter.

Topic Description
/NewModule Subscribe to this topic to add new module to EasyIoT cloud database and get it's ID. instance id is instance id for your username.
/[module id]/ModuleType Publish to this topic to set module type. As parameter set module type name.
/[module id]/[parameter name]/NewParameter Subscribe to this topic to create new module parameter with name [parameter name] and get it's id.
/[module id]/[parameter name]/Description Publish to this topic to set parameter description. Parameter description is set as parameter.
/[module id]/[parameter name]/Unit Publish to this topic to set parameter unit. Parameter unit is set as parameter.
/[module id]/[parameter name]/DbAvgInterval Publish to this topic to set parameter database averaging interval. Parameter database averaging interval is set as parameter.
/[module id]/[parameter name]/UINotifications Publish to this topic to set parameter UI notifications. Parameter UI notifications is set as parameter.
/[module id]/[parameter name]/DBLogging Publish to this topic to set parameter database logging. Parameter database logging is set as parameter.
/[module id]/[parameter name]/ChartSteps Publish to this topic to set parameter chart steps. Parameter database chart steps is set as parameter.
/[module id]/[parameter name]/IsCommand Publish to this topic to set parameter is command. Parameter is command is set as parameter.

 

See more tutorials at http://iot-playground.com/build


Comments   

#5 Tsaukpaetra 2021-07-26 09:30
It would be nice if we could set the module name also. Maybe a publish to /[moduleId]/Name ?
#4 profile 2018-11-01 18:17
Need cheap hosting? Try webhosting1st, just $10 for an year.

+1 #3 Aleksandar Aleksandrov 2016-11-24 12:47
Quoting Super User:
Quoting Aleksandar Aleksandrov:
Is there a command to change parameter value ?
/[module id]/[parameter name]/Value
is not working. Plase help


Just publish value to :
/[module id]/[parameter name]


Thank you! This is working very well
valueStr = String("Value");
topic = "/"+String(storage.moduleId)+ "/Settings.Icon1";
result = myMqtt.publish(topic, valueStr);
+1 #2 Super User 2016-11-24 11:51
Quoting Aleksandar Aleksandrov:
Is there a command to change parameter value ?
/[module id]/[parameter name]/Value
is not working. Plase help


Just publish value to :
/[module id]/[parameter name]
+1 #1 Aleksandar Aleksandrov 2016-11-24 00:33
Is there a command to change parameter value ?
/[module id]/[parameter name]/Value
is not working. Plase help

You have no rights to post comments

Forum latest

  • No posts to display.