diff --git a/README.md b/README.md index 74e8b08..7e84a81 100644 --- a/README.md +++ b/README.md @@ -74,9 +74,7 @@ InfluxDb is running here: http://localhost:8086/ (you have to create an initial You can login to Grafana: http://localhost:3000/login (admin:admin) -## Usage - - +## Examples and set-up ### Setting up a simple flow in Node-RED @@ -86,10 +84,16 @@ A simple introduction to Node-RED can be found - along with the nodes / the code A more sophisticated exampe on how to connect Node-RED to influx is also available in [this repository](./docs/flow/docs/node-influx.md). + ### Setting up Grafana Have a look at the [HowTo in this repository](./docs/dashboard/README.md). + +### Attaching a Shelly plug + +As an example you can use a Shelly plug flashed with Tasmota and feed MQTT data with Node-RED into InfluxDB and visualize it with Grafana. Have a look, [here](./docs/shelly/README.md). + ## Contribution Feel free to open an issue for bugs, feature requests, or questions. Contributions are welcome. diff --git a/docs/shelly/README.md b/docs/shelly/README.md new file mode 100644 index 0000000..748c39f --- /dev/null +++ b/docs/shelly/README.md @@ -0,0 +1,55 @@ +# Shelly Plug (S) + +Shelly Plugs S are quite cheap but relatively accurate to measure power consumptions less than 2.5 kW. + +![Shelly Plug](https://shelly.hr/wp-content/uploads/2020/11/shelly_plug_s_1-1.jpg) + +In our [smart-energy-montior](https://code.curious.bio/curious.bio/smart-energy-monitor) project we already have set up a Shelly using Tasmota, on Open Source alternative firmware, that also runs on various other consumer off the shelf devices. + + +## InfluxDB Bucket + +In Influx I created a bucket called `shelly`in InfluxDB, so we can store the messages in this bucket. + +### Node-RED + +I create a usual flow in Node-RED. A MQTT node fetches the values. + +![Node-RED](./docs/images/node-red.png) + +The message is fed into a filter function to only store usefull information: + +``` +return { + payload: { + power: Number(msg.payload.ENERGY.Power), + voltage: Number(msg.payload.ENERGY.Voltage), + current: Number(msg.payload.ENERGY.Current) + } +}; +```` + +The `payload` will be stored in InfluxDB in the bucket "shelly". + +### InfluxDB Data Explorer + +In Influx DB Data Explorer you can query the stored data. + +![Data Explorer](./docs/images/data-explorer.png) + +The query created by Data Explorer looks like that: + +``` +from(bucket: "shelly") + |> range(start: v.timeRangeStart, stop: v.timeRangeStop) + |> filter(fn: (r) => r["_measurement"] == "msg") + |> filter(fn: (r) => r["_field"] == "power" or r["_field"] == "voltage" or r["_field"] == "current") + |> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false) + |> yield(name: "mean") +``` + +### Grafana + +Using this query you can crate a dashboard in Grafana. + +![Grafana](./docs/images/grafana.png) diff --git a/docs/shelly/docs/images/blitzwolf.png b/docs/shelly/docs/images/blitzwolf.png new file mode 100644 index 0000000..deb3ca2 Binary files /dev/null and b/docs/shelly/docs/images/blitzwolf.png differ diff --git a/docs/shelly/docs/images/configure-wifi.png b/docs/shelly/docs/images/configure-wifi.png new file mode 100644 index 0000000..cb38d7e Binary files /dev/null and b/docs/shelly/docs/images/configure-wifi.png differ diff --git a/docs/shelly/docs/images/data-explorer.png b/docs/shelly/docs/images/data-explorer.png new file mode 100644 index 0000000..d17a8c5 Binary files /dev/null and b/docs/shelly/docs/images/data-explorer.png differ diff --git a/docs/shelly/docs/images/grafana.png b/docs/shelly/docs/images/grafana.png new file mode 100644 index 0000000..1002f91 Binary files /dev/null and b/docs/shelly/docs/images/grafana.png differ diff --git a/docs/shelly/docs/images/mqtt.png b/docs/shelly/docs/images/mqtt.png new file mode 100644 index 0000000..3618697 Binary files /dev/null and b/docs/shelly/docs/images/mqtt.png differ diff --git a/docs/shelly/docs/images/node-red.png b/docs/shelly/docs/images/node-red.png new file mode 100644 index 0000000..fc3e632 Binary files /dev/null and b/docs/shelly/docs/images/node-red.png differ diff --git a/docs/shelly/docs/images/telemetry-period.png b/docs/shelly/docs/images/telemetry-period.png new file mode 100644 index 0000000..204bb56 Binary files /dev/null and b/docs/shelly/docs/images/telemetry-period.png differ diff --git a/docs/shelly/docs/images/wifi.png b/docs/shelly/docs/images/wifi.png new file mode 100644 index 0000000..85142cb Binary files /dev/null and b/docs/shelly/docs/images/wifi.png differ