This is an advanced step in case you want to connect LoRaWAN Sensors that are not yet added to the LoRaWAN Payload decoder of the Smart UI Application! It is important that you have the payload decoder in LUA code available for this step!
The currently supported LoRaWAN payload decoders in the Smart UI applications are from the sensor brands below. In case you are connecting one or multiple sensors from the below brands, please follow this tutorial instead. In case your sensor brand is not listed below, please continue to read below.
- Browse to the “Main Menu” → “Applications” tab.
- Enable “LoRa” in the input section. A button called “LoRa” will appear on the right side.
Please note! It can take up to 30seconds before the Lora page is loaded!
- Click on this “LoRa” button to add new LoRa devices.
- In the "LoRa Setup" section, select the desired region and press the “Save changes” button.
- EU (Europe), IN (India) or RU (Russia) for 868MHz devices.
- US for 915MHz devices.
- Other LoRaWAN regions are currently not supported.
- In the OTA Devices section, press the icon to add a new LoRa sensor.
- Select "Generic" as the "Device Type" and "Model" of the sensor you’d like to add.
- Enter the DevEUI (16byte) and Appkey (32byte) as provided by the sensor manufacturer. The LoRa Class for most battery operated sensors is “A”. For mains powered sensors or actuators this is often "Class C". Class B devices are currently not supported.
- Press the button once completed to add the new sensor.
- Some new fields are generated as you can see. A “Description” and “My Device ID” can be configured, but these are not mandatory. However, it is recommended to change the Description to something recognizable as it will be used to identify the messages from this sensor in a later step!
- Next step is to identify objects in the payload message from the sensor as there are no pre-defined (system or standard) objects available at this point. First, head back to the main Smart UI page and click the "Edit code" button in the "User app (advanced) section.
- A new tab will open, showing LuvitRED, the graphical drag and drop editor for CloudGate Gateways. In the top left corner, use the search function to search for the "5A Intercept", "5A Intercept Action", "Function" and "Debug" nodes. Drag and drop them one by one on the editor screen in the middle and connect them to each other by connecting the grey dots, as can be screenshot below.
- Double click on the left "5A Intercept" node to configure it. Set the topic to "tmf.lora.decode" and press the red "OK" button in the top left corner to go back.
- Double click on the right "5A Intercept Action" node to configure it. If not set already, set the mode to "Modify" and press the red "OK" button in the top left corner to go back.
- Double click on the "Debug" node to configure it. Select "complete msg object" as output. If desired, you can also select a highlight color to emphasize the outputted messages in the debug screen.
- Double click on the right "Function" node to configure it. This is where the payload decoder in LUA coding needs to be posted. As there is no global "LoRaWAN Payload" standardization, this decoder is very different for every LoRa device manufacturer and even for some device types from certain device manufacturers. The decoder for the sensor in our example (a XIRDEC NightHawk multisensor), can be seen in the screenshot below:
Three very important things to notice in the example above:
It's important to add the following line to your decoder on the first row, as it is used by the application to count the received uplink messages from your sensor!
test = (test or 0) + 1
It's important, in case you are using sensors of different types, to only run this function node in case a message is received for this type of sensor. Otherwise the payload decoder will not work properly! You can filter out messages from other sensors by including a line as can be seen below, where "NightHawk" is the sensor description as indicated in step 9 above.
if msg.payload.device == "NightHawk" then
It's important to notice that all payload objects (i.e. temperature, humidity, lux, pir, battery, etc.) should be stored in the msg.payload.values table for the application to work properly!
- Press the red "OK" button in the top left corner to go back.
- Press the red "Deploy" button in the top right corner to deploy the LuvitRED flow.
- You can now power on the sensor and let it perform a Join-Sequence in order to join to the private CloudGate LoRaWAN Network. Once joined, you will see the messages arrive in the debug screen on the right side of the screen. Make sure to select the "debug" screen first. Any error messages can be ignored at this stage.
- Go back to the "CloudGate" tab in your browser and browse to the "LoRa" tab in the "Main Menu".
- Click on the "magnifying glass" icon of your newly added sensor to select the newly defined user Objects.
- In the "OTA devices" section, you will see the newly created User Objects listed.
- Click on the "magnifying glass" icon in front of each object that you want to select for transmission to the Cloud. Set "Enabled" to yes and change the Object ID if desired.
- Press the "Save" button to save all changes.
Congratulations, your LoRa sensor is now connected to your CloudGate.
You can now proceed to step 3: Connecting your CloudGate to the Cloud.
Please find below a video tutorial with more detail on all steps above: