Kaa is an IoT platform that provides device management, data collection, data processing and analytics, alerts, data visualization, configuration management, command execution, over-the-air updates and more. Kaa provides comprehensive multi-tenancy with full isolation of each tenant’s data, users, permissions, dashboards, solutions, etc. It is modular by design and built upon cloud-native microservices that you can easily swap, customize, or integrate with third-party solutions. Also, Kaa features a modern-looking, intuitive, and fully customizable web dashboard.
This tutorial shows how to integrate The Things Stack with the Kaa platform for observing your device’s telemetry on the Kaa UI.
Prerequisites
Setup The Things Stack
Go to the MQTT integration section on the left hand menu in The Things Stack and generate an API key to access The Things Stack application from Kaa.
Set the rights for the API key by selecting Grant all current and future rights. The Kaa platform requires this level of access in order to be able to query The Things Stack for application parameters and information on registered devices in that application.
After that, go to the Payload formatters section on the left hand menu in The Things Stack, select Uplink and choose the Custom Javascript formatter. Leave the formatter code as it is suggested by default:
function decodeUplink(input) {
return {
data: {
bytes: input.bytes
},
warnings: [],
errors: []
};
}
Setup Kaa
Create Application
First, you need to create an application in the Kaa Cloud, that will correspond to the application inside The Things Stack.
To do so, navigate to the Device management → Applications and add a new application by clicking the Add application button.
Next, create at least one version of that application by clicking the plus button.
Create Application Integration
Next, you can create the integration between Kaa and The Things Stack applications.
Navigate to the Device management → Integrations and click the Add integration button. Fill in the following fields:
- TTN username - The Things Stack MQTT username
- TTN API key - the API key that you created in steps above
- Identity Server Host - The Things Stack Identity Server host address (see the Server Addresses section for more info)
- MQTT Server Host - The Things Stack MQTT public address
Create Device Integration
Now, you need to create device integration, i.e. mappings between The Things Stack devices and Kaa endpoints.
Go to the created application integration and create a device integration by choosing the application version and The Things Stack device that you want to integrate. You can see the device integration in the Devices list after its creation.
By navigating to Device management → Devices, you will find the Kaa endpoint that was automatically created during the device integration creation. All incoming data from The Things Stack device will be ingested under that endpoint.
Visualize Device Data
Next, you can visualize data coming from The Things Stack on Kaa UI.
Edit the application configuration for the Endpoint Time Series service (EPTS). EPTS is a Kaa platform component responsible for transforming raw data samples into well-structured time series. It also stores the time series data and provides access to API for other services, including the Web Dashboard.
Go to the Device management → Applications, expand the application used for integration, click on EPTS and enable auto-extraction.
With this function enabled, Kaa will automatically create a time series for each numeric field that it encounters at the root of data samples submitted by your endpoints. You will then be able to view these time series in the Kaa UI, with no extra configuration required.
Now navigate to the device details page of the endpoint created in previous steps. To do that, go to the Devices page in the Device management section and click on the corresponding row. The data coming from The Things Stack device will be displayed on the Device telemetry widget.
Let’s assume that The Things Stack device is sending temperature measurements in the next format:
{"temp":20}
Convert this payload to a byte array in HEX (7B 22 74 65 6D 70 22 3A 32 30 7D
), go to the End devices → your device’s Overview page → Messaging in The Things Stack Console and paste the byte array into the Payload field.
As a result, you should be able to see the data on Kaa UI.
Congratulations, you have successfully integrated The Things Stack with Kaa and visualized your data on the Kaa UI!
Next Steps
Explore more Kaa features by completing the Getting Started tutorials cycle with short tutorials on the main Kaa features.