Datacake Overview
Datacake is a multi-purpose, low-code IoT platform that makes it quite easy to create a custom IoT application. This article will show how simple it is to forward your sensor data from a WisBlock environment sensor node to Datacake and create the visualization.
Helpful Articles Not Covered Here:
- How to setup the WisBlock Environment sensor node. You can use the WisBlock Environment Monitoring example. The same payload structure was exactly used as in that example.
- How to connect the WisBlock node to a Gateway. Checkout RAK4631 Quick Start.
- How to setup the Chirpstack server and connect the Gateway to it. You can find a guide in the Chirpstack Quick Start.
- How to setup an application in Chirpstack and add your device to the application. This is shown in Chirpstack - Connecting a device.
- How to get a Datacake account (Datacake).
- How to run a Datacake application (Datacake Docs).
Topics Covered in This Article:
- How to set up the HTTP integration in the Chirpstack Server
- How to set up a device in your Datacake application
- How to create the data parser and data fields for your sensor node in Datacake
- How to set up your dashboard to visualize the incoming sensor data
Setup the HTTP Integration in the Chirpstack Server
đź“ť NOTE: Make sure that you have already set up your Chirpstack server and created an application.
Open your Chirpstack web interface and go to your application. |
Open your application to view all the connected devices. At this point, you should write down the Device EUI of the node you want to connect to Datacake. You will need it later in Datacake.
Click the Integrations tab to see the integrations Chirpstack has already implemented.
For Datacake, we will use HTTP integration. Just click on the ADD
button.
In the window that opens, we will do three things:
- Select
JSON
as Payload marshaler. - Add the Datacake API URL
https://api.datacake.co/integrations/lorawan/chirpstack/
. The URLs for other LPWAN servers can be found on Datacake LPWAN Get Started. - Push the UPDATE INTEGRATION button.
Moving forward, Chirpstack will forward the data coming from your sensor node to Datacake.
Now, it's time to setup your visualization.
Setup a Device in Your Datacake Application
đź“ť NOTE: Make sure that you have already setup your Datacake account, created your application, and are ready to add a device. If not, go to the Datacake Documentation. They have tutorials on how to get everything up and running. |
In the Datacake application, click Devices to see the overview of your devices. Then click the Add Device button to start.
In the next screen, select LoRaWAN and New Product. RAKwireless WisBlock devices are not yet available as templates.
Add your Product Name and click the Next button.
Then, scroll down the window until you see the Network Server section. Search and select Chirpstack, and click the Next
button.
In the next step, you have to enter the DEVEUI of your node and a name. The DEVEUI must match the node that you chose earlier in the Chirpstack Application. Once you have entered the information, hit the Next button again.
Depending on your Datacake account and how many devices you have already registered, select between the different payment options. Luckily, a coupon allowed me to use Extended Free for this new device. Once done here, push the Add 1 device button.
You can now see the new device in the Devices overview screen of Datacake. It is not yet shown as connected because no valid data was received yet.
Create the Data Parser and Data Fields for Your Sensor Node in Datacake
To finish the configuration of the device, click it in the overview.
In the next window, select Configuration.
In the Configuration tab, scroll down until you see the LoRaWAN section. Verify here that the DevEUI is correct and that the Network Server is indeed Chirpstack.
Continue to scroll down until you see the Payload Decoder section. Here, you'll have to enter our custom payload decoder for the arriving data. As you can see in the image, the decoder is returning a nested JSON array where each JSON entry has two fields: field and value. field will later be needed for the visualization and value is the sensor data.
To make things easier, a payload decoder that you may copy and paste was prepared below. It will work with this example and can be easily extended to use with our other WisBlock Solutions.
Overwrite the example payload decoder with the following:
function Decoder(payload, port) {
if(payload[0] === 0x01) {
return [
{
field: "TEMPERATURE",
value: (payload[1] << 8 | payload[2]) / 100
},
{
field: "HUMIDITY",
value: (payload[3] << 8 | + payload[4]) / 100
},
{
field: "PRESSURE",
value: (payload[8] | (payload[7] << 8) | (payload[6] << 16) | (payload[5] << 24)) / 100
},
{
field: "GAS",
value: payload[12] | (payload[11] << 8) | (payload[10] << 16) | (payload[9] << 24)
},
{
field: "COUNTER",
value: payload[16] | (payload[15] << 8) | (payload[14] << 16) | (payload[13] << 24)
}
];
}
if(payload[0] === 0x02) {
return [
{
field: "TEMPERATURE",
value: (payload[1] << 8 | payload[2]) / 100
},
{
field: "HUMIDITY",
value: (payload[3] << 8 | + payload[4]) / 100
},
{
field: "COUNTER",
value: payload[8] | (payload[7] << 8) | (payload[6] << 16) | (payload[5] << 24)
}
];
}
if(payload[0] === 0x03) {
return [
{
field: "LIGHT",
value: (payload[4] | (payload[3] << 8) | (payload[2] << 16) | (payload[1] << 24)) / 100
},
{
field: "COUNTER",
value: payload[8] | (payload[7] << 8) | (payload[6] << 16) | (payload[5] << 24)
}
];
}
if(payload[0] === 0x04) {
return [
{
field: "COUNTER",
value: payload[4] | (payload[3] << 8) | (payload[2] << 16) | (payload[1] << 24)
}
];
}
}
Check if the decoder works. Scroll further down and hit the Save button to update the decoder.
Scroll all the way up and select the Debug tab. If your device is online and already sending data, you can see the results of the decoder in the Debug Log.
If that works, you'll next have to do some more entry work. Datacake uses fields to find the correct data for the visualization, but you must first define all of the fields.
Go back to the configuration tab and scroll down until you see the Fields section. Once you're there, click the Add Field button.
In the Add Field
window, select the data type, name for the field, and unit.
đź“ť NOTE: The Identifier must match the field name that is assigned in the payload decoder. So, for Temperature, the correct field name is TEMPERATURE.
|
After entering all the information, hit the Add Field button.
You have to repeat this step until you've defined all four fields that will contain the sensor data. In the end, your Fields section should look like this:
At this point, we're done with the preparations. Now, let's go and show the data with some nice charts.
Setup Your Dashboard to Visualize the Incoming Sensor Data
Return to your device overview and open the Dashboard tab. For now, it's empty. To add a new widget, click the small edit
icon on the right side.
Now, you will see an Add Widget button. Click it to start.
In the next screen, you'll see a selection of different visualization options. I chose Chart here.
The next window has four tabs. Start with the Basic tab and enter the chart title.
On the Devices tab, click Add Device.
The window will extend, and you can select the Field, which represents the data you want to visualize.
After selecting Temperature, you can choose a color for this data and change the display name (optional).
On the Axis tab, you can define the Unit
of the data and set the MIN
and MAX
values to be displayed (optional). I left it here at 0 for the min value and auto for the max value.
In the last tab, the Timeframe tab, you can set how much data should be displayed. Since we just started receiving data here, I chose This hour
. You can change this later, once more data is available.
The preview will already show some data. Click Save to go back to the dashboard edit window.
It will now show your first widget with the temperature data. You can resize it with the small arrow in the lower right corner of the widget.
After repeating these steps for other fields, Humidity, Pressure, and Air Quality, you can see the charts with the received data.
Click the yellow icon next to 'Unsaved changes' to save your work and return to the main dashboard view.
Now, you have the data from your environment sensor in a nice visualization that you can access and see from anywhere.
Bernd Giesecke Electronics Engineer, 23 years of experience in industrial and automotive HW and SW R&D. Supporting Arduino open-source community since 2014. |
Updated