How to integrate the XDK device from Legic via MQTT on akenza
In this tutorial you will learn how to connect the XDK device via MQTT on akenza
Last updated
In this tutorial you will learn how to connect the XDK device via MQTT on akenza
Last updated
Applications:
Smart Building
Predictive maintenance & monitoring of machinery
The Legic XDK Secure Sensor Evaluation Kit is the “The Swiss army knife of IoT solutions”. It is a universal programmable sensor device & prototyping platform for any IoT use case.
Product features:
Accelerometer
Gyroscope
Magnetic field strength
Brightness
Temperature
Pressure
Humidity
Acoustic noise
Enables rapid prototyping and fast transition from prototype to mass production. The device consists of eight MEMS sensors, Bluetooth, Wi-Fi. The Software includes XDK Workbench, extensive libraries & modular source code
You can find more information about the XDK here.
To create a Data Flow, go to Data Flow and select Create Data Flow.
Select Connect a device over MQTT. You do not need to choose a device type. By default, the payload will be passed through without processing. This gives the sender the option to structure the payload freely. As an output connector, you can choose one or multiple output Connectors. For this example the default setting, akenza DB is sufficient. Therefore you will have access to historical data.
Save your Data Flow and proceed with the Asset creation in Assets.
To create a new MQTT device, select Create Device in the menu of the Asset Inventory. Add a device name. The other fields are optional. Select your created MQTT – Data Flow. Once the device is saved, proceed with the configuration of your XDK device.
Please install the XDK-Workbench. Download here.
This will be used to code and configure the XDK device. Once the installation is executed, open the XDK-Workbench and select Use Eclipse Mita in the welcome screen.
For this application, there are no coding skills required.
The following code can be copy-pasted with minor changes for the WiFi credentials and the MQTT connection string.
To find the MQTT credentials needed, head over to the Asset inventory and select the device that you want to use. Under the tab API-Configuration, you can find the credentials. Edit the lines accordingly:
Note that the clientId should be unique for each broker. Picking the username in this tutorial is fine, but for production we recommend using the Device ID.
Note for the MQTT URL: In order for the XDK-Workbench to accept the URL, it has to start with mqtt://...
Please change the URL provided by Akenza from tcp://...
to mqtt://...
Also, edit this section with your WiFi-Credentials:
After adding all the needed credentials, you can now save the project. Then right-click on the Project you are working on in Project Explorer and clean it. After the Device console throws out the message Build Finished, right-click on the project again and build it again. This might take a moment.
After the device console shows that the build is finished, you can now flash your device. For that, please connect your XDK device to your PC and turn the XDK on while pressing button 1 (the button with one dot). By turning the device on this way, you activate the bootloader mode. After that, press Flash in the Device manager as shown below.
After the device is flashed, the data will be streamed to akenza.
The incoming data can be viewed on the Device Detail Page in both the Message Logs and Data Overview Tabs:
Congratulations, you have successfully integrated the XDK device from Legic on akenza.
Optionally: Check out the Rule engine in order to apply a business logic to your IoT- infrastructure.