diff --git a/README.md b/README.md index 6f6be6e..e861915 100644 --- a/README.md +++ b/README.md @@ -47,4 +47,5 @@ See the [documentation in this repository](./hardware/README.md). ## Hardware sensors * [Energy Monitor](./software/firmware/energy-monitor/README.md) +* [Plant Monitor](./software/firmware/plant-monitor/README.md) * [Shelly Example](./software/firmware/shelly-monitor/README.md) \ No newline at end of file diff --git a/software/dashboard/grafana/grafana.db b/software/dashboard/grafana/grafana.db index 4411342..e34c65c 100644 Binary files a/software/dashboard/grafana/grafana.db and b/software/dashboard/grafana/grafana.db differ diff --git a/software/firmware/plant-monitor/README.md b/software/firmware/plant-monitor/README.md new file mode 100644 index 0000000..55d0449 --- /dev/null +++ b/software/firmware/plant-monitor/README.md @@ -0,0 +1,99 @@ +# Plant Monitor + +## + +We use our existing plant monitor for this project. + + +## Tasmota + +[Tasmota](https://tasmota.github.io/docs/) is an alternative Firmware for ESP8266. It's easy to use with it's graphical user interface. + +You can flash Tasmota right from the browser using the [Tasmota Web Installer](https://tasmota.github.io/). + +![Flash it](./docs/images/01-flash-1.png) + +You have to connect your device through USB and select the right port. Exisisting firmware will be delete. + +![Erase everything](./docs/images/02-flash-2.png) + +After Tasmota has been flashed to your ESP, you can already set up your wifi. + +![Set up Wifi](./docs/images/03-wifi.png) + +After your device is connected to Wifi, you can switch over to the web UI of your device. Yes, your device now runs an embedded web server. There you can configure your device. + +![Embedded web server](./docs/images/04-web-ui.png) + +### Configure + +Using this Web UI you can setup up your device: `Configure -> Configure Module` + +Our Wemos D1 mini clone is a `generic device with 18 ports`. We have a DHT11 connected to D1 and an analogue measurement on A0. + +![Basic configuration](./docs/images/05-configuration.png) + + +After configuring it this way, we can see you data in the web UI. + +![Flash it](./docs/images/06-overview.png) + +### MQTT + +Tasmota's main protocol is MQTT. You can setup MQTT under `Configuration -> MQTT`. + + ![MQTT](./docs/images/07-setup-mqtt.png) + +To send data more frequent (nice for debugging) you have to change the telemetry period to a lower leven (than 300 s / 5 min). + + ![Telemetry interval](./docs/images/08-configure-telemetry-interval.png) + + Then our device will send data like this: + + ``` + { + "Time": "2023-02-26T17:19:55", + "ANALOG": { + "A0": 6 + }, + "DHT11": { + "Temperature": 19, + "Humidity": 44, + "DewPoint": 6.4 + }, + "TempUnit": "C" +} + + ``` +You can subscribe to this MQTT event in Node-RED. + +![Node-RED](./docs/images/08-node-red-overview.png) + +There is a small converter function, so we only store the interesting values in InfluxDB. + +``` +return { + payload: { + temperature: Number(msg.payload.DHT11.Temperature), + humidity: Number(msg.payload.DHT11.Humidity) + } +}; +``` +We can query this data in InfluxDB. + +![InfluxDB](./docs/images/09-influx.png) + +This is our query. + +``` +from(bucket: "plant") + |> range(start: v.timeRangeStart, stop: v.timeRangeStop) + |> filter(fn: (r) => r["_measurement"] == "msg") + |> filter(fn: (r) => r["_field"] == "temperature" or r["_field"] == "humidity") + |> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false) + |> yield(name: "mean") +``` + +We can use this query to create a dashboard in Grafana. +![InfluxDB](./docs/images/10-grafana.png) + diff --git a/software/firmware/plant-monitor/docs/images/01-flash-1.png b/software/firmware/plant-monitor/docs/images/01-flash-1.png new file mode 100644 index 0000000..2335d85 Binary files /dev/null and b/software/firmware/plant-monitor/docs/images/01-flash-1.png differ diff --git a/software/firmware/plant-monitor/docs/images/02-flash-2.png b/software/firmware/plant-monitor/docs/images/02-flash-2.png new file mode 100644 index 0000000..e96dc3b Binary files /dev/null and b/software/firmware/plant-monitor/docs/images/02-flash-2.png differ diff --git a/software/firmware/plant-monitor/docs/images/03-wifi.png b/software/firmware/plant-monitor/docs/images/03-wifi.png new file mode 100644 index 0000000..ae7f1b0 Binary files /dev/null and b/software/firmware/plant-monitor/docs/images/03-wifi.png differ diff --git a/software/firmware/plant-monitor/docs/images/04-web-ui.png b/software/firmware/plant-monitor/docs/images/04-web-ui.png new file mode 100644 index 0000000..fde4987 Binary files /dev/null and b/software/firmware/plant-monitor/docs/images/04-web-ui.png differ diff --git a/software/firmware/plant-monitor/docs/images/05-configuration.png b/software/firmware/plant-monitor/docs/images/05-configuration.png new file mode 100644 index 0000000..f291b6b Binary files /dev/null and b/software/firmware/plant-monitor/docs/images/05-configuration.png differ diff --git a/software/firmware/plant-monitor/docs/images/06-overview.png b/software/firmware/plant-monitor/docs/images/06-overview.png new file mode 100644 index 0000000..dfd83a6 Binary files /dev/null and b/software/firmware/plant-monitor/docs/images/06-overview.png differ diff --git a/software/firmware/plant-monitor/docs/images/07-setup-mqtt.png b/software/firmware/plant-monitor/docs/images/07-setup-mqtt.png new file mode 100644 index 0000000..1a56b72 Binary files /dev/null and b/software/firmware/plant-monitor/docs/images/07-setup-mqtt.png differ diff --git a/software/firmware/plant-monitor/docs/images/08-configure-telemetry-interval.png b/software/firmware/plant-monitor/docs/images/08-configure-telemetry-interval.png new file mode 100644 index 0000000..9b2354e Binary files /dev/null and b/software/firmware/plant-monitor/docs/images/08-configure-telemetry-interval.png differ diff --git a/software/firmware/plant-monitor/docs/images/08-node-red-overview.png b/software/firmware/plant-monitor/docs/images/08-node-red-overview.png new file mode 100644 index 0000000..daffd15 Binary files /dev/null and b/software/firmware/plant-monitor/docs/images/08-node-red-overview.png differ diff --git a/software/firmware/plant-monitor/docs/images/09-influx.png b/software/firmware/plant-monitor/docs/images/09-influx.png new file mode 100644 index 0000000..ffaa073 Binary files /dev/null and b/software/firmware/plant-monitor/docs/images/09-influx.png differ diff --git a/software/firmware/plant-monitor/docs/images/10-grafana.png b/software/firmware/plant-monitor/docs/images/10-grafana.png new file mode 100644 index 0000000..a7e695e Binary files /dev/null and b/software/firmware/plant-monitor/docs/images/10-grafana.png differ diff --git a/software/firmware/plant-monitor/tasmota/Config_tasmota_A4D1F3_4595_12.4.0.dmp b/software/firmware/plant-monitor/tasmota/Config_tasmota_A4D1F3_4595_12.4.0.dmp new file mode 100644 index 0000000..742f5f9 Binary files /dev/null and b/software/firmware/plant-monitor/tasmota/Config_tasmota_A4D1F3_4595_12.4.0.dmp differ diff --git a/software/flow/.config.users.json b/software/flow/.config.users.json index 77dff85..0b8d491 100644 --- a/software/flow/.config.users.json +++ b/software/flow/.config.users.json @@ -24,6 +24,9 @@ "workflow": { "mode": "manual" } + }, + "debug": { + "filter": "filterAll" } } } \ No newline at end of file diff --git a/software/flow/.config.users.json.backup b/software/flow/.config.users.json.backup index bbed7a1..1b92d6d 100644 --- a/software/flow/.config.users.json.backup +++ b/software/flow/.config.users.json.backup @@ -6,7 +6,7 @@ "view-store-position": false, "view-show-grid": true, "view-snap-grid": true, - "view-grid-size": 20, + "view-grid-size": "20", "view-node-status": true, "view-node-show-label": true, "view-show-tips": true, @@ -15,6 +15,18 @@ "tours": { "welcome": "3.0.2" } + }, + "git": { + "user": { + "name": "", + "email": "" + }, + "workflow": { + "mode": "manual" + } + }, + "debug": { + "filter": "filterSelected" } } } \ No newline at end of file diff --git a/software/flow/.flows.json.backup b/software/flow/.flows.json.backup index dc5ff10..fe30396 100644 --- a/software/flow/.flows.json.backup +++ b/software/flow/.flows.json.backup @@ -206,72 +206,6 @@ "url": "http://influxdb:8086", "rejectUnauthorized": true }, - { - "id": "3cc11d24.ff01a2", - "type": "comment", - "z": "f6f2187d.f17ca8", - "name": "WARNING: please check you have started this container with a volume that is mounted to /data\\n otherwise any flow changes are lost when you redeploy or upgrade the container\\n (e.g. upgrade to a more recent node-red docker image).\\n If you are using named volumes you can ignore this warning.\\n Double click or see info side panel to learn how to start Node-RED in Docker to save your work", - "info": "\nTo start docker with a bind mount volume (-v option), for example:\n\n```\ndocker run -it -p 1880:1880 -v /home/user/node_red_data:/data --name mynodered nodered/node-red\n```\n\nwhere `/home/user/node_red_data` is a directory on your host machine where you want to store your flows.\n\nIf you do not do this then you can experiment and redploy flows, but if you restart or upgrade the container the flows will be disconnected and lost. \n\nThey will still exist in a hidden data volume, which can be recovered using standard docker techniques, but that is much more complex than just starting with a named volume as described above.", - "x": 330, - "y": 100, - "wires": [] - }, - { - "id": "39aa2ca9.804da4", - "type": "debug", - "z": "f6f2187d.f17ca8", - "name": "", - "active": true, - "tosidebar": true, - "console": false, - "tostatus": false, - "complete": "payload", - "targetType": "msg", - "statusVal": "", - "statusType": "auto", - "x": 670, - "y": 360, - "wires": [] - }, - { - "id": "262a3923.e7b216", - "type": "influxdb in", - "z": "f6f2187d.f17ca8", - "influxdb": "eeb221fb.ab27f", - "name": "", - "query": "SELECT * from test", - "rawOutput": false, - "precision": "", - "retentionPolicy": "", - "org": "my-org", - "x": 450, - "y": 360, - "wires": [ - [ - "39aa2ca9.804da4" - ] - ] - }, - { - "id": "803d82f.ff80f8", - "type": "inject", - "z": "f6f2187d.f17ca8", - "name": "", - "repeat": "", - "crontab": "", - "once": false, - "onceDelay": 0.1, - "topic": "", - "payload": "", - "payloadType": "date", - "x": 240, - "y": 360, - "wires": [ - [ - "262a3923.e7b216" - ] - ] - }, { "id": "00a750cdfb54579e", "type": "mqtt in", @@ -335,18 +269,95 @@ "id": "499e0f3651d818db", "type": "debug", "z": "f6f2187d.f17ca8", + "name": "consumption", + "active": true, + "tosidebar": true, + "console": false, + "tostatus": false, + "complete": "payload", + "targetType": "msg", + "statusVal": "", + "statusType": "auto", + "x": 810, + "y": 420, + "wires": [] + }, + { + "id": "b14166f65d5aec75", + "type": "mqtt in", + "z": "f6f2187d.f17ca8", + "name": "", + "topic": "tele/tasmota_A4D1F3/SENSOR", + "qos": "1", + "datatype": "auto-detect", + "broker": "7ce136dbb8c897d1", + "nl": false, + "rap": true, + "rh": 0, + "inputs": 0, + "x": 210, + "y": 720, + "wires": [ + [ + "e3742f5060cf6cb7", + "29cd45a4f1feb505" + ] + ] + }, + { + "id": "23c62c30ebabca6e", + "type": "influxdb out", + "z": "f6f2187d.f17ca8", + "influxdb": "d61a7da6caeb26aa", + "name": "Influx plant sensor", + "measurement": "msg", + "precision": "", + "retentionPolicy": "", + "database": "database", + "precisionV18FluxV20": "ms", + "retentionPolicyV18Flux": "", + "org": "Curious Community Labs", + "bucket": "plant", + "x": 790, + "y": 640, + "wires": [] + }, + { + "id": "e3742f5060cf6cb7", + "type": "debug", + "z": "f6f2187d.f17ca8", "name": "debug 1", "active": true, "tosidebar": true, "console": false, "tostatus": false, - "complete": "false", + "complete": "payload", + "targetType": "msg", "statusVal": "", "statusType": "auto", - "x": 800, - "y": 420, + "x": 500, + "y": 780, "wires": [] }, + { + "id": "29cd45a4f1feb505", + "type": "function", + "z": "f6f2187d.f17ca8", + "name": "toNumber", + "func": "var newMsg = {\n payload: {\n temperature: Number(msg.payload.DHT.Temperature),\n humidity: Number(msg.payload.DHT11.Humidity)\n }\n};\nreturn newMsg;", + "outputs": 1, + "noerr": 0, + "initialize": "", + "finalize": "", + "libs": [], + "x": 520, + "y": 640, + "wires": [ + [ + "23c62c30ebabca6e" + ] + ] + }, { "id": "e0977f2582bfaaa6", "type": "mqtt in", diff --git a/software/flow/flows.json b/software/flow/flows.json index 54dda92..ca6eed9 100644 --- a/software/flow/flows.json +++ b/software/flow/flows.json @@ -269,18 +269,95 @@ "id": "499e0f3651d818db", "type": "debug", "z": "f6f2187d.f17ca8", + "name": "consumption", + "active": true, + "tosidebar": true, + "console": false, + "tostatus": false, + "complete": "payload", + "targetType": "msg", + "statusVal": "", + "statusType": "auto", + "x": 810, + "y": 420, + "wires": [] + }, + { + "id": "b14166f65d5aec75", + "type": "mqtt in", + "z": "f6f2187d.f17ca8", + "name": "", + "topic": "tele/tasmota_A4D1F3/SENSOR", + "qos": "1", + "datatype": "auto-detect", + "broker": "7ce136dbb8c897d1", + "nl": false, + "rap": true, + "rh": 0, + "inputs": 0, + "x": 210, + "y": 720, + "wires": [ + [ + "29cd45a4f1feb505" + ] + ] + }, + { + "id": "23c62c30ebabca6e", + "type": "influxdb out", + "z": "f6f2187d.f17ca8", + "influxdb": "d61a7da6caeb26aa", + "name": "Influx plant sensor", + "measurement": "msg", + "precision": "", + "retentionPolicy": "", + "database": "database", + "precisionV18FluxV20": "ms", + "retentionPolicyV18Flux": "", + "org": "Curious Community Labs", + "bucket": "plant", + "x": 790, + "y": 640, + "wires": [] + }, + { + "id": "e3742f5060cf6cb7", + "type": "debug", + "z": "f6f2187d.f17ca8", "name": "debug 1", "active": true, "tosidebar": true, "console": false, "tostatus": false, - "complete": "false", + "complete": "payload", + "targetType": "msg", "statusVal": "", "statusType": "auto", - "x": 800, - "y": 420, + "x": 760, + "y": 760, "wires": [] }, + { + "id": "29cd45a4f1feb505", + "type": "function", + "z": "f6f2187d.f17ca8", + "name": "toNumber", + "func": "var newMsg = {\n payload: {\n temperature: Number(msg.payload.DHT11.Temperature),\n humidity: Number(msg.payload.DHT11.Humidity)\n }\n};\nreturn newMsg;", + "outputs": 1, + "noerr": 0, + "initialize": "", + "finalize": "", + "libs": [], + "x": 520, + "y": 640, + "wires": [ + [ + "23c62c30ebabca6e", + "e3742f5060cf6cb7" + ] + ] + }, { "id": "e0977f2582bfaaa6", "type": "mqtt in",