Description

This article provides the Node-RED example to use VS121 or WS202 to trigger the WS50X to turn on/off the light.

 

 

Requirement

  • Milesight LoRaWAN Gateway: UG56/UG65/UG67
  • Milesight LoRaWAN Sensor: VS121, WS202, WS50x

 

Configuration

Step 1: Launch Node-RED and Import Flow Example

1. Follow guide How to Connect LoRaWAN Nodes to Milesight Gateway to activate sensors to network server of gateway.

2. Go to App > Node-RED page to enable Node-RED program and wait for a while to load the program, click Launch button to start Node-RED web GUI.

 

3. Log in the Node-RED web GUI. The account information is the same as gateway web GUI. 

 

 

4. Click Import to import the node-red flow example by pasting the content or import the json format file.

 

 

Step 2: Node-RED Configuration

Flow structure:

1. LoRa Input : To get all sensor uplink message from network server.

2. Device Filter: Filter device by Device EUI. Here we configure it to filter VS121 and WS202 by their device EUI. You can modify the EUI for your sensor.

 

3. Function 1/2: Use for decoding payload of VS121 and WS202. Kindly refer to this document to add decoders.

4. Switch: Use to set up judgement condition(If…). In this example the condition is VS121 detects people or WS202 is triggered. The variable names can be found from Milesight decoder: https://github.com/Milesight-IoT/SensorDecoders

 

 

 

 

5. Change: This module is used to set global /flow variables. The variables here will be used for the judgement of the IF statement in the subsequent function.

 

 

6. Function3: Use to determine the trigger condition. Here, you can set the trigger condition with an IF statement. The example is to send a msg message when all variables are 1

 

7. Debug: Display selected message properties in the debug sidebar tab and optionally the runtime log. Here, we use it to see WS202 and VS121 uplink package content, keep Output as payload by default.

 

8. LoRa Output: Send downlink command to device. Here, we can send downlink command to WS50X device to turn off the light.


Step 3: Deploy and Check Result

1. Click Deploy to save all node-red configurations.


2. Wait for the condition to trigger and you can see the command sent show in the node-red sidebar or the gateway Packets page.




----END----