How To Visualize Sensor Data on Datacake Using Chirpstack

KHM-051-00.jpg

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:

Topics Covered in This Article:

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.

KHM-051-01.png

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.

KHM-051-02.png

Click the Integrations tab to see the integrations Chirpstack has already implemented.

KHM-051-03.png

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.

KHM-051-04.png

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.

KHM-051-05.png

In the next screen, select LoRaWAN and New Product. RAKwireless WisBlock devices are not yet available as templates.

KHM-051-06.png

Add your Product Name and click the Next button.

KHM-051-07.png

Then, scroll down the window until you see the Network Server section. Search and select Chirpstack, and click the Next button.

KHM-051-08.png

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.

KHM-051-09.png

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.

KHM-051-010.png

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.

KHM-051-011.png

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.

KHM-051-012.png

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.

KHM-051-013.png

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.

KHM-051-014.png

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)
            }
        ];
    }
}

KHM-051-015.png

Check if the decoder works. Scroll further down and hit the Save button to update the decoder.

KHM-051-016.png

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.

KHM-051-017.png

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.

KHM-051-018.png

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.

KHM-051-019.png

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:

KHM-051-020.png

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.

KHM-051-021.png

Now, you will see an Add Widget button. Click it to start.

KHM-051-022.png

In the next screen, you'll see a selection of different visualization options. I chose Chart here.

KHM-051-023.png

The next window has four tabs. Start with the Basic tab and enter the chart title.

KHM-051-024.png

On the Devices tab, click Add Device.

KHM-051-025.png

The window will extend, and you can select the Field, which represents the data you want to visualize.

KHM-051-026.png

After selecting Temperature, you can choose a color for this data and change the display name (optional).

KHM-051-027.png

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.

KHM-051-028.png

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.

KHM-051-029.png

The preview will already show some data. Click Save to go back to the dashboard edit window.

KHM-051-030.png

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.

KHM-051-031.png

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.

KHM-051-032.png

Now, you have the data from your environment sensor in a nice visualization that you can access and see from anywhere.

bernd-giesecke.png

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