1. Home
  2. LegacyConnector
  3. LoraWan
  4. Device

Device

If you didin’t add the LoaraWan devices on Lumit.io LoraWan Server, click here.

Step1. Create Lora Server node

1Add new Lora-serve endpoint
2Set node Name

Step 2. Now we need to create LoraWan Device parser for the sensors you add before on Lumitio LoraWan Server

Add into your workspace the function node and write the parser (Example code for Ursalink EM300 sensor).

data = JSON.parse(msg.payload);
if (data.devaddr == "0007848E")
{
    bytes = Buffer.from(data.data,'hex');
    // Decode an uplink message from a buffer 03 67 DE 00 04 68 59
    // (array) of bytes to an object of fields.
    var aux;
    var temp;
    var hum;
    var dataOk=0;
    var channel = bytes[0]
    var bat=data.battery
    bat = bat.toFixed(0)
    if (bytes[0] == 0x03 && bytes[1] == 0x67)
    {
        aux = (bytes[3]<<8 |bytes[2])*0.1
        temp=aux.toFixed(1);//temperature,units:℃    
        dataOk=1;
    }else{
        dataOk=0;
    }
    if (bytes[4] == 0x04 && bytes[5] == 0x68)
    {
        aux = bytes[6]*0.5
        hum=(aux).toFixed(1);//Humidity,units:%
        dataOk=1;
    }else
    {
        dataOk=0
    }
    
    if (dataOk)
    {
        var msg0={
            "variable":"bat.rawValue",
            "value":bat
        }
        var msg1={
            "variable":"temp.rawValue",
            "value":temp
        }
        var msg2={
            "variable":"hum.rawValue",
            "value":hum
        }
        return [msg0,msg1,msg2];   
    }
}

Tip: The objects msg0, msg1 and msg2 got the correct format to be compatible with the Virtual Interface. Also change the Outputs to 3 because we are returning 3 objects.

Step 3. Add Virtual interface to integrate data from your LoraWan device parser

The name for each variable must be the same as the parser function, previous build.

Step 4. After finish adding the variables you need to connect the parser and the Virtual Interface

You can connect multiple node outputs into single node input.

Step 5. Deploy Flow to apply changes

Tip: To facilitate the debug you can add debug nodes to check the data sent between nodes.

Step 6. Now that you created your node go to Cloud Connector and start sending data to the cloud

Was this article helpful to you? Yes No

How can we help?