In this tutorial, we’ll connect the UP Squared Series MicroPC to the Kaa platform. This setup allows you to monitor your device’s status and execute terminal commands remotely via MQTT, without the need for a static IP.
The UP Squared Series MicroPC will act as an endpoint in the Kaa platform. We’ll use a Python-based system scanner to fetch system data and integrate it with Kaa via MQTT. This setup also allows us to execute Kaa commands and run terminal commands remotely. Note that the System Scanner requires a Linux environment to operate.
To get started with the project, follow these steps:
Ensure Python is installed on your system:
sudo apt install python3.12-venv
pip install setuptools
Install the project using the following commands:
git clone https://github.com/kaaproject/mqtt-client-python
cd mqtt-client-python
python3 -m venv env
source env/bin/activate
cd examples/linux_sys_scan/
pip install -r requirements.txt
Start the project by running:
python3 main.py
Upon your first launch, you may encounter a several errors:
The program scans your system and attempts to send the data, but it doesn’t know where to send it due to missing environment variables such as DEFAULT_KPC_HOST
, APPLICATION_VERSION
, APPLICATION_NAME
, TENANT_ID
and ENDPOINT_TOKEN
.
Here’s how to get them.
To resolve the issue, you need to create a new application and an endpoint. The application acts as a storage for your Linux servers, providing default settings for each one. Within this application, you will create an endpoint to receive and view generated data, as well as to execute commands remotely.
Open Kaa console: Navigate to the Applications tab, choose a name for your application, and create it.
Add a Device: In the Devices tab, select your application from the dropdown and click “Add device”. Choose a name for the device and create it.
Copy the Token: You will be greeted with a token.
Copy it. That is ENDPOINT_TOKEN
, 1 out of the 5 required variables.
Get Application Version: Open your newly created device and copy the appVersion.name
and appName
.
This will be APPLICATION_VERSION
and APPLICATION_NAME
, which are the 3 out of 5 variables.
Get Tenant ID: In the top right corner, click on profile icon
and copy Tenant ID
.
That’s 4 out of 5.
Get Default KPC Host: Finally, on the device page, navigate to “Data Publish”, check the MQTT option, and copy the resulting URL.
This is the DEFAULT_KPC_HOST
, the last variable.
Here’s an example of the credentials you should provide. Replace the placeholder values with your own and copy the result into your terminal:
export DEFAULT_KPC_HOST="mqtt://mqtt.cloud.kaaiot.com"
export DEFAULT_KPC_PORT="1883"
export APPLICATION_NAME="{your-application-name}"
export APPLICATION_VERSION="{your-application-version}"
export ENDPOINT_TOKEN="{your-endpoint-token}"
export TENANT_ID="{your-tenant-id}"
Now you can launch the program with python3 main.py
, and hopefully, you will start receiving data.
In your device page, navigate to the Commands section. You can execute terminal commands from Kaa and view the output in JSON format. To do this:
LINUX_COMMAND
.{"command": "ls"}
You can use the Kaa dashboard to create a custom UI to view your data and go beyond the default device page.
Open the Solutions tab.
A solution is automatically created for each application, but you can create a new one if needed.
To keep things simple, here’s a quick example. After running the python3 main.py script, a JSON template will be generated using the environment variables you provided earlier. To apply the template, follow these steps:
./dashboards/output
folder and copy the code from device_overview.json
.You should now see a dashboard similar to the one shown below:
Congratulations, you have connected and visualized data from your UP Squared Series!