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.
This documentation is obsolete. Use latest EasyIoT Cloud MQTT API (v1).
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.
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.
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.
On module parameter configuration screen is visible parameter MQTT topic. Copy this topic if you want to control parameter value.
Parameter topics is:
/Db/[instance id]/[module id]/[parameter name]
Where:
instance id is your instance id.
Module id is module id visible in module configuration screen.
Parameter name is name of parameter.
example of parameter topics is:
/Db/345645678qwer34564567771/7/Sensor.Parameter1
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.
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 |
/Db/InstanceId | Subscribe to this topic to get instance id for username |
/Db/[instanceId]/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. |
/Db/[instance id]/[parameter id]/ModuleType | Publish to this topic to set module type. As parameter set module type name. |
/Db/[instance Id]/[module id]/[parameter name]/NewParameter | Subscribe to this topic to create new module parameter with name [parameter name] and get it's id. |
Db/[instance id]/[parameter id]/[parameter name]/Description | Publish to this topic to set parameter description. Parameter description is set as parameter. |
Db/[instance id]/[parameter id]/[parameter name]/Unit | Publish to this topic to set parameter unit. Parameter unit is set as parameter. |
Db/[instance id]/[parameter id]/[parameter name]/DBLogging | Publish to this topic to set parameter database logging. Parameter dataase logging is set as parameter. |
Comments
Here is example how to use it:
http://iot-playground.com/blog/2-uncategorised/77-esp8266-internet-controlled-switch-easyiot-cloud-mqtt-api
RSS feed for comments to this post