Description

Milesight LoRaWAN gateway supports Node Red feature, which can help user to simulate and set up related solutions easily. Besides, Milesight developed some own component which can be used directly.

This article describes how to use decoder on Node Red of Milesight gateway.


Requirement

Milesight gateway: UG56, UG65, UG67

LoRaWAN sensor: take Milesight AM107 as an example


Content

Decode the data of Milesight LoRaWAN sensor

Decode the data of third-party LoRaWAN sensor


Configuration


Decode the data of Milesight LoRaWAN sensor

1. Connect Milesight nodes to Milesight LoRaWAN gateway, please refer to this article:

How to Connect LoRaWAN Nodes to Milesight Gateway.


2. Go to App -> Node-RED to enable the Node-RED feature, after enabled, click Launch to go to the Node-RED web GUI and to log in with the same username and password as gateway.


3. Create topology like the picture below:


LoRa Input: Receive the LoRa data, please ensure the network server mode is enabled before using this node.

Device Filter: Filter out the data of one or more specific LoRaWAN® nodes

Decoder: Decode the Milesight LoRaWAN® end nodes data.

debug: Displays selected message properties in the debug sidebar tab and optionally the runtime log. By default it displays msg.payload.

4. Device Filter configuration, filter out the data via Device EUI

5. Decoder configuration, in this example, select AM100 Series.

6. Debug configuration, just keep it by default.

7. Click Deploy to save the configuration, go to debug page, you can check the decoded data.

Decode the data of third-party LoRaWAN sensor

1. If the sensor is not offered by Milesight, you need to use the component of function instead of Decoder, and then add decoder of your sensor in function.

Create topology like the picture below:


2. Function configuration

Milesight provides SensorDecoders developed via Java Script on GitHub, you need to ask the third-party LoRaWAN sensor manufacturer for sensor decoders.

take AM107 as an example:

Copy AM100_TTN.js decoder to function

 

If decoder is developed via Java Script, the function header follows this format.

function Decoder(bytes, port) {

}

Besides, add the following lines of code outside the function


var buffer = Buffer.from(msg.payload, 'base64');
var aa = Decoder(buffer);
msg.payload =aa;
msg.buffer =buffer;
return msg;



 

3. Then you can check the decoded data in debug page.


                                                                             ----END- --