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.


Milesight gateway: UG56, UG65, UG67

Any LoRaWAN sensor


Before using the decode feature on Node-RED, ensure the Milesight LoRaWAN nodes has been added to Milesight LoRaWAN gateway, please refer to this article: How to Connect LoRaWAN Nodes to Milesight Gateway.

Method 1: Decode via Payload Codec page

1. Add payload decoder on Payload Codec page referring to article How to Use Payload Codec on Milesight Gateway. Ensure the sensor data can be decoded on Packet page.

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 a Node-RED flow like the picture below:

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

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

debug: Displays selected message properties in the debug sidebar tab and optionally the runtime log. You can add it to either LoRa Input node or Device Filter node.

4. Select any of the debug node to change output as complete msg object, click Done to save the settings.

5. Click Deploy to save the flow. Then go to debug page, you can check the decoded data inside the object part.

Method 2: Decode via function node

1. Create a Node-RED flow like the picture below:

2. Function configuration

For Milesight sensors and controllers, please find SensorDecoders developed via Java Script on GitHub (select TTN type decoder); for third-party LoRaWAN sensors, please contact 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 at the end of the function

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


Click Deploy to save the configuration, then you can check the decoded data in debug page.

3. If you need to add specific attribute variables in decoded data, like RSSI, SNR, etc. Please add below statements before “return decoded” sentence:

decoded.rssi = msg.rssi;
decoded.snr = msg.snr; = msg.payload;
decoded.addTime = msg.time;

Click Deploy to save the flow, then you can check the decoded result with specific attribute variables in debug page.

Note: Milesight gateway supports to add below variables:

                                                                             ----END- --