In this tutorial, you will learn how to send data from the iFrogLab LoRa Gateway to QNAP QIoT Suite Lite.

 

Prepare


Set up the iFrogLab LoRa USB to QIoT Suite Lite and iFrogLab LoRa Gateway Container. Setup steps can be found at http://www.ifroglab.com/en/?p=6613  (If in Step 10 the expected output is not displayed, using SSH to access the NAS and enter the following commands:
           insmod /usr/local/modules/cdc-acm.ko
           insmod /usr/local/modules/cp210x.ko
           insmod /usr/local/modules/ftdi_sio.ko )

If the NAS restarts, then the commands must be entered again.

 

Set up iFrogLab LoRa Gateway MQTT



0

 

  • Open Container Station, choose your iFrog Lora Gateway, and click "Terminal".


1

 

  • Enter the command: "nano /ifroglab/IL-LORA1272/LoRa-Gateway/Gateway/Python/ap-01-lora-gateway-2-read-httpGet.py" and click "OK".



  • Move to "mqtt=" mosquitto_pub -d -t ifroglab/mqtt -m '%s' -h test.mosquitto.org"%(HexString);" and add a "#" in front of it. As below:


2

  • Add a new string as below:


2-1

-h : Enter the QIoT service IP (If QIoT Suite Lite and iFrogLab LoRa Gateway are in the same NAS, enter the Container Station NAT Gateway IP -the default value is                     10.0.3.1)
-p : Default value: 21883, modify this according to your resourceinfo.json data
-t : (topic) Modify this according to your resourceinfo.json data
-u : (username) Modify this according to your resourceinfo.json data
-P : (password) Modify this according to your resourceinfo.json data
-m : (message type) Modify this according the above example

The change as below:

3

 

  • Click "Ctrl+O" and click "Enter" to save then click "Crtl+X" to leave


4

 

  • Open the "iFrogLora Gateway" Container. The following screen will appear if it has been modified successfully


5

 

  • Open "QIoT Suite Lite" >  "IoT Application". The "Thing Data Log" display this status


6

 

  • Go to "Rule" and you can start your IoT Application. The received data will be HEX. (Example rule as below)


7

 

Example rule:
[
{
"id": "e2bd8ea5.5c613",
"type": "debug",
"z": "8cc3c0a1.b6949",
"name": "Click debug tab to watch data stream",
"active": true,
"console": "false",
"complete": "false",
"x": 557.5,
"y": 92,
"wires": []
},
{
"id": "8ff255de.850808",
"type": "qiotbroker in",
"z": "8cc3c0a1.b6949",
"name": "MQTT Message In",
"flow": "8cc3c0a1.b6949",
"opt_customtopic": false,
"customtopic": "custom_topic_c13af1572d9611e8adc49f3a1551c296",
"thing": "ec626e0b-0524-4f06-9f8d-6c590730f7a9",
"qtopic": "qiot/things/admin/loradevice/data",
"username": "admin",
"rules": [
{
"v": "5ab347b29c31dc00322c43d0",
"meta": {
"unit": "°C",
"datatype": "String"
},
"resid": "data"
}
],
"outputs": 1,
"key": "r:5197487d0ab31b464c745aa7b8fa2616",
"x": 108.5,
"y": 43,
"wires": [
[
"d0d1710e.b9a8d"
]
]
},
{
"id": "d0d1710e.b9a8d",
"type": "change",
"z": "8cc3c0a1.b6949",
"name": "",
"rules": [
{
"t": "move",
"p": "payload.value",
"pt": "msg",
"to": "payload",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 332,
"y": 43,
"wires": [
[
"1a8b6d9a.197722"
]
]
},
{
"id": "1a8b6d9a.197722",
"type": "function",
"z": "8cc3c0a1.b6949",
"name": "Decoded",
"func": "function convertFromHex(hex) {\n hex = hex.toString();//force conversion\n var str = '';\n for (var i = 1; i < hex.length + 1; i += 2)\n str += String.fromCharCode(parseInt(hex.substr(i, 2), 16));\n return str;\n}\n\nmsg.payload = convertFromHex(msg.payload.substring(0, msg.payload.length - 4));\n\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 284,
"y": 92,
"wires": [
[
"e2bd8ea5.5c613"
]
]
}
]
arrow
arrow
    全站熱搜

    tttt 發表在 痞客邦 留言(0) 人氣()