From 981c1e1958c6fce075fcf48630cc41c876ccb171 Mon Sep 17 00:00:00 2001
From: andreas <a.strasser@student.tugraz.at>
Date: Wed, 10 May 2023 08:29:10 +0200
Subject: [PATCH] added flow for sensor data collection

---
 flows/sensor-data-collection.json | 249 ++++++++++++++++++++++++++++++
 1 file changed, 249 insertions(+)
 create mode 100644 flows/sensor-data-collection.json

diff --git a/flows/sensor-data-collection.json b/flows/sensor-data-collection.json
new file mode 100644
index 0000000..be4e77f
--- /dev/null
+++ b/flows/sensor-data-collection.json
@@ -0,0 +1,249 @@
+[
+    {
+        "id": "584b4f01cb5e2a99",
+        "type": "tab",
+        "label": "sensor data collection",
+        "disabled": false,
+        "info": "",
+        "env": []
+    },
+    {
+        "id": "cd9705cb41db546e",
+        "type": "influxdb out",
+        "z": "584b4f01cb5e2a99",
+        "influxdb": "c5d33de34968e61f",
+        "name": "insert data - melonfield/station/1",
+        "measurement": "",
+        "precision": "",
+        "retentionPolicy": "",
+        "database": "database",
+        "precisionV18FluxV20": "ms",
+        "retentionPolicyV18Flux": "",
+        "org": "rcm",
+        "bucket": "melonfield/station/1",
+        "x": 1010,
+        "y": 140,
+        "wires": []
+    },
+    {
+        "id": "f8d96925b15bac6c",
+        "type": "mqtt in",
+        "z": "584b4f01cb5e2a99",
+        "name": "soil moisture",
+        "topic": "melonfield/station/+/moisture",
+        "qos": "0",
+        "datatype": "auto-detect",
+        "broker": "cdd2ed1d59e64cb9",
+        "nl": false,
+        "rap": true,
+        "rh": 0,
+        "inputs": 0,
+        "x": 170,
+        "y": 100,
+        "wires": [
+            [
+                "fdbc250a814bea16"
+            ]
+        ]
+    },
+    {
+        "id": "f2af91e72ab65220",
+        "type": "mqtt in",
+        "z": "584b4f01cb5e2a99",
+        "name": "soil temperature",
+        "topic": "melonfield/station/+/temperature",
+        "qos": "0",
+        "datatype": "auto-detect",
+        "broker": "cdd2ed1d59e64cb9",
+        "nl": false,
+        "rap": true,
+        "rh": 0,
+        "inputs": 0,
+        "x": 180,
+        "y": 180,
+        "wires": [
+            [
+                "fdbc250a814bea16"
+            ]
+        ]
+    },
+    {
+        "id": "5dd9920ca47e892e",
+        "type": "mqtt in",
+        "z": "584b4f01cb5e2a99",
+        "name": "illuminance",
+        "topic": "melonfield/station/+/illuminance",
+        "qos": "0",
+        "datatype": "auto-detect",
+        "broker": "cdd2ed1d59e64cb9",
+        "nl": false,
+        "rap": true,
+        "rh": 0,
+        "inputs": 0,
+        "x": 160,
+        "y": 260,
+        "wires": [
+            [
+                "fdbc250a814bea16"
+            ]
+        ]
+    },
+    {
+        "id": "839dbc43ea1865ca",
+        "type": "mqtt in",
+        "z": "584b4f01cb5e2a99",
+        "name": "battery level",
+        "topic": "melonfield/station/+/battery",
+        "qos": "0",
+        "datatype": "auto-detect",
+        "broker": "cdd2ed1d59e64cb9",
+        "nl": false,
+        "rap": true,
+        "rh": 0,
+        "inputs": 0,
+        "x": 170,
+        "y": 340,
+        "wires": [
+            [
+                "fdbc250a814bea16"
+            ]
+        ]
+    },
+    {
+        "id": "fdbc250a814bea16",
+        "type": "function",
+        "z": "584b4f01cb5e2a99",
+        "name": "extract bucket, measurement",
+        "func": "const topic = msg.topic.split('/');\nmsg.bucket = topic.slice(0, 3).join('/');\nmsg.measurement = topic[3];\nreturn msg;",
+        "outputs": 1,
+        "noerr": 0,
+        "initialize": "",
+        "finalize": "",
+        "libs": [],
+        "x": 480,
+        "y": 220,
+        "wires": [
+            [
+                "72ddb174f053ad0b"
+            ]
+        ]
+    },
+    {
+        "id": "72ddb174f053ad0b",
+        "type": "switch",
+        "z": "584b4f01cb5e2a99",
+        "name": "select bucket",
+        "property": "bucket",
+        "propertyType": "msg",
+        "rules": [
+            {
+                "t": "eq",
+                "v": "melonfield/station/1",
+                "vt": "str"
+            },
+            {
+                "t": "eq",
+                "v": "melonfield/station/2",
+                "vt": "str"
+            },
+            {
+                "t": "eq",
+                "v": "melonfield/station/3",
+                "vt": "str"
+            }
+        ],
+        "checkall": "true",
+        "repair": false,
+        "outputs": 3,
+        "x": 730,
+        "y": 220,
+        "wires": [
+            [
+                "cd9705cb41db546e"
+            ],
+            [
+                "be96663431be9971"
+            ],
+            [
+                "6512bd090dbfb4cd"
+            ]
+        ]
+    },
+    {
+        "id": "be96663431be9971",
+        "type": "influxdb out",
+        "z": "584b4f01cb5e2a99",
+        "influxdb": "c5d33de34968e61f",
+        "name": "insert data - melonfield/station/2",
+        "measurement": "",
+        "precision": "",
+        "retentionPolicy": "",
+        "database": "database",
+        "precisionV18FluxV20": "ms",
+        "retentionPolicyV18Flux": "",
+        "org": "rcm",
+        "bucket": "melonfield/station/2",
+        "x": 1010,
+        "y": 220,
+        "wires": []
+    },
+    {
+        "id": "6512bd090dbfb4cd",
+        "type": "influxdb out",
+        "z": "584b4f01cb5e2a99",
+        "influxdb": "c5d33de34968e61f",
+        "name": "insert data - melonfield/station/3",
+        "measurement": "",
+        "precision": "",
+        "retentionPolicy": "",
+        "database": "database",
+        "precisionV18FluxV20": "ms",
+        "retentionPolicyV18Flux": "",
+        "org": "rcm",
+        "bucket": "melonfield/station/3",
+        "x": 1010,
+        "y": 300,
+        "wires": []
+    },
+    {
+        "id": "c5d33de34968e61f",
+        "type": "influxdb",
+        "hostname": "127.0.0.1",
+        "port": "8086",
+        "protocol": "http",
+        "database": "database",
+        "name": "influxdb",
+        "usetls": false,
+        "tls": "",
+        "influxdbVersion": "2.0",
+        "url": "http://localhost:8086",
+        "rejectUnauthorized": false
+    },
+    {
+        "id": "cdd2ed1d59e64cb9",
+        "type": "mqtt-broker",
+        "name": "mqtt-broker",
+        "broker": "localhost",
+        "port": "1883",
+        "clientid": "",
+        "autoConnect": true,
+        "usetls": false,
+        "protocolVersion": "4",
+        "keepalive": "60",
+        "cleansession": true,
+        "birthTopic": "",
+        "birthQos": "0",
+        "birthPayload": "",
+        "birthMsg": {},
+        "closeTopic": "",
+        "closeQos": "0",
+        "closePayload": "",
+        "closeMsg": {},
+        "willTopic": "",
+        "willQos": "0",
+        "willPayload": "",
+        "willMsg": {},
+        "userProps": "",
+        "sessionExpiry": ""
+    }
+]
\ No newline at end of file
-- 
GitLab