Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

EasyIot Cloud MQTT API v.1

DZone's Guide to

EasyIot Cloud MQTT API v.1

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.

· IoT Zone
Free Resource

MQTT is a machine-to-machine (M2M)/"Internet of Things" connectivity protocol.  It is designed for connections to remote locations where a "small code footprint" is required or the network bandwidth is limited. EasyIoT Cloud implements MQTT broker connected to EasyIoT real-time 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.

An important difference between classic MQTT broker is that EasyIoT Cloud broker does not publish messages originated in MQTT clients. It only publishes 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 log in 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. These 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 the modules in the list on the right side.

module configuration

On module configuration screen we see Module Id. This ID is included in MQTT parameter topic. To see a 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: /[module id]/[parameter name]
  • Where: Module id is module id visible in module configuration screen.
  • Parameter name: The name of the parameter.
  • An example of parameter topics: /7/Sensor.Parameter1

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

Custom MQTT topic 

Topics visible on parameter configuration are topics to which we subscribe if we want to receive changes of parameter value or publish if we want to change the value of the 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. These topics are used to add new module or parameter to the 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

Related Refcard:

Topics:
mqtt ,configuration ,module ,cloud ,application ,native

Published at DZone with permission of Igor Jarc, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}