Introduction

Qubitro allows solution providers to design and sell global IAQ monitoring solutions by unifying device data from multiple networks with no code, supported by a complete developer toolkit.

In this article, we worked with our partner Qubitro to demonstrate how fast and seamless connecting Milesight LoRaWAN nodes to Qubitro with no-code integrations and accessing data in record time.

 

Requirement


Configuration

1. Ensure Milesight LoRaWAN nodes has been added to The Thing Stack and send data normally. Please refer to article How to Connect Milesight End Devices to The Things Stack v3.

 

2. Go to Qubitro portal, create a new project and click +Add source to add a The Thing Stack source.

 

3. Copy auto-generated credentials to be passed onto the integration.


4. Go to TTN > Integrations > Webhooks page under the application menu, click on + Add webhook button on the top-right of the page and choose Qubitro from the list. Customize a webhook ID and copy the project ID and webhook Signing Key from Qubitro, then click Create Qubitro webhook.

 

 

5. Go to Qubitro page, fresh project device list to ensure all devices are in sync.

 

6. To decode the data, you can copy the Milesight device decoder under Formatter tab and modify the code according to Qubitro format: https://docs.qubitro.com/portal/payload-formatters/javascript/uplink-decoder

Here is the AM103 decoder example for Qubitro:

function decodeUplink(input) {
    var decoded = {};

    for (var i = 0; i < input.bytes.length;) {
        var channel_id = input.bytes[i++];
        var channel_type = input.bytes[i++];
        // BATTERY
        if (channel_id === 0x01 && channel_type === 0x75) {
            decoded.battery = input.bytes[i];
            i += 1;
        }
        // TEMPERATURE
        else if (channel_id === 0x03 && channel_type === 0x67) {
            // ℃
            decoded.temperature = readInt16LE(input.bytes.slice(i, i + 2)) / 10;
            i += 2;

            // ℉
            // decoded.temperature = readInt16LE(input.bytes.slice(i, i + 2)) / 10 * 1.8 + 32;
            // i +=2;
        }
        // HUMIDITY
        else if (channel_id === 0x04 && channel_type === 0x68) {
            decoded.humidity = input.bytes[i] / 2;
            i += 1;
        }
        // CO2
        else if (channel_id === 0x07 && channel_type === 0x7D) {
            decoded.co2 = readUInt16LE(input.bytes.slice(i, i + 2));
            i += 2;
        }else {
            break;
        }
    }

   return {
    data: {
      temperature: decoded.temperature,
      humidity: decoded.humidity,
      battery: decoded.battery,
      co2: decoded.co2
    }
  };
}

/* ******************************************
 * bytes to number
 ********************************************/
function readUInt16LE(bytes) {
    var value = (bytes[1] << 8) + bytes[0];
    return value & 0xffff;
}

function readInt16LE(bytes) {
    var ref = readUInt16LE(bytes);
    return ref > 0x7fff ? ref - 0x10000 : ref;
}

7. Once the payload formatters are added, Qubitro will display the decoded data.

 

You can also add charts under Analytics tab.

 

8. You can also use Qubitro API to make queries and do some developments. For details please contact Qubitro about it.

 

--END--