Sending Telemetry to Ubidots
Introduction
This example project is a setup that showcases how to connect a CDP application with the Ubidots IoT platform at https://ubidots.com/ using MQTT. It includes the UbidotsEdge block for data transmission, the CDP Logger for data logging, and a FallbackBroker for local MQTT communication in case of Ubidots API Key issues.
Note: The Ubidots cloud part needs no configuration for accepting the data. Nodes will be auto-created with the EdgeName and variables sent by the UbidotsEdge.
Note: For ease of example testing the MQTT link is not secured, but the required alternate broker address and the needed certificates are available from Ubidots and MQTTClient supports a secure setup.
Components
The project comprises the following key components
UbidotsEdge Block
Manages communication with the Ubidots cloud. It automatically sends logged data to the Ubidots platform using MQTT.
CDPLogger and Sine Blocks
Logs data from the application. In this example, it logs values from 'SineA' and 'SineB' sources. The logger has been set to log a new value every 10 seconds. Setting a Delta value on LoggedValues is also advised to reduce unwanted changes.
Testing only FallbackBroker Block
A local MQTT broker that serves as a stand-in for testing the edge behaviour without the Ubidots cloud. It is used when the Ubidots API Key is not set or is invalid. Note that in a real use case, this block should be removed.
In the fallback mode, MQTTExplorer can be used to monitor the fallback broker at 127.0.0.1:1883 to see what data would be uploaded to the cloud and the rate of the requests.
Configuration of UbidotsEdge
For testing the whole example it is best to create a trial account at Ubidots https://ubidots.com/ and set the APIKey in the UbidotsEdge block. When testing with multiple edge devices make sure the EdgeName is also changed to be unique.
Configuration Entry | Description |
---|---|
EdgeName | Represents the unique identifier of the edge node. |
RootTopic | The MQTT topic root under which data will be published (preconfigured). |
APIKey | The Ubidots API Key is needed for authenticating with the Ubidots platform. Register for trial at https://ubidots.com/ to get the API Key. |
The APIKey is available under API Credentials in your profile.
Note: The Ubidots cloud is intended for slow telemetry data (up to 4 requests/second) and the UbidotsEdge down-samples all data from CDP Logger to 1 Hz. It is recommended to configure the logged values with Delta
option to reduce unneeded data changes further for such telemetry data.
Operation Flow
- The CDP Logger logs data from specified sources at a defined frequency.
- UbidotsEdge reads the logged data and prepares it for transmission.
- If the Ubidots API Key is valid, data is sent to the Ubidots cloud.
- In case of an invalid or unset API Key, UbidotsEdge switches to the FallbackBroker for local MQTT communication.
Use Case and Benefits
This example project is ideal for IoT applications requiring reliable data transmission to cloud platforms. The integration of UbidotsEdge with CDPLogger simplifies the process of setting up data logging and cloud communication.
Get started with CDP Studio today
Let us help you take your great ideas and turn them into the products your customer will love.