From 785062d55481124b29da24e7e51381961911c5c2 Mon Sep 17 00:00:00 2001 From: simonox Date: Sat, 16 Sep 2023 15:26:39 +0200 Subject: [PATCH] mode node chapter smaller by splitting it up --- README.md | 11 +++++--- docs/flow/README.md | 49 +---------------------------------- docs/flow/docs/node-influx.md | 44 +++++++++++++++++++++++++++++++ 3 files changed, 53 insertions(+), 51 deletions(-) create mode 100644 docs/flow/docs/node-influx.md diff --git a/README.md b/README.md index 12d4107..74e8b08 100644 --- a/README.md +++ b/README.md @@ -76,14 +76,19 @@ You can login to Grafana: http://localhost:3000/login (admin:admin) ## Usage -### Setting up Grafana -Have a look at the [HowTo in this repository](./docs/dashboard/README.md). ### Setting up a simple flow in Node-RED -A simple introduction to Node-RED can be found - along with the nodes / the code - in [this repository, please have a look](./docs/flow/README.md)! +A simple introduction to Node-RED can be found - along with the nodes / the code - in [this repository](./docs/flow/README.md). +### Connecting Node-RED to Influx + +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). ## Contribution diff --git a/docs/flow/README.md b/docs/flow/README.md index 0800fb9..2ac8647 100644 --- a/docs/flow/README.md +++ b/docs/flow/README.md @@ -1,7 +1,3 @@ -# About - -> This folder will be mounted into the Node-RED runtime. So be careful. - # Node-RED If you boot up our tech stack using `docker-compose` you already have a Node-RED instance running on [your local machine](http://localhost:1880/). @@ -61,47 +57,4 @@ You can view the dashboard in an (also mobile) web browser. Have a look at the flow also in [this repository](./00-dashboard-example/dashboard.json). -## InfluxDB - -Already added to this project is [node-red-contrib-influxdb](https://flows.nodered.org/node/node-red-contrib-influxdb). You can use it's nodes to write and query data from an InfluxDB time series database. These nodes support both InfluxDB 1.x and InfluxDb 2.0 databases. At the time of this writing we are using [version 2.6 of InfluxDB on port 8086](http://admin:adminadmin@localhost:8086). - -In Node-RED we will be passing the power consumption number through MQTT. - -![Overview](./docs/images/influx-flow.png) - -By default this will be passed as a string, so we need to create a function to convert it into a Number before storing it in InfluxDB. - -Add a function node to the page and put the following code into the node: - -```JavaScript -msg.payload = Number(msg.payload) -return msg; -``` - -![Function](./docs/images/influx-function.png) - -You can forward this message to InfluxDB. - -![Influx Node](./docs/images/influx-node.png) - -The `URL`of our InfluxDB is `http://influxdb:8086`. In InfluxDB you have to create a `token` to connect: [Load Data -> API Tokens](http://localhost:8086/orgs/721027680173bf2f/load-data/tokens). - -![Influx Create Token](./docs/images/influx-create-token.png) - -You can use this `token` to create a connection in Node-RED. - -![Influx Connection](./docs/images/influx-connection.png) - -Then the measurements should be visible in [Influx Data Explorer](http://localhost:8086/orgs/721027680173bf2f/data-explorer?bucket=test). - -![Influx Data Explorer](./docs/images/influx-data-explorer.png) - -As the data is now stored in Influx, [let's create a dashboard in Grafana](../dashboard/README.md). - -# Links - -* [IoT Made Easy with Node-RED and InfluxDB](https://www.influxdata.com/blog/iot-easy-node-red-influxdb/) -* A great tutorial can be found at [microcontrollerlab.com](https://microcontrollerslab.com/esp32-mqtt-publish-multiple-sensor-readings-node-red/) - - - +You can also [connect to InfluxDB](./docs/node-influx.md). \ No newline at end of file diff --git a/docs/flow/docs/node-influx.md b/docs/flow/docs/node-influx.md new file mode 100644 index 0000000..3d2cc4e --- /dev/null +++ b/docs/flow/docs/node-influx.md @@ -0,0 +1,44 @@ +# Node-RED and InfluxDB + +Already added to this project is [node-red-contrib-influxdb](https://flows.nodered.org/node/node-red-contrib-influxdb). You can use it's nodes to write and query data from an InfluxDB time series database. These nodes support both InfluxDB 1.x and InfluxDb 2.0 databases. At the time of this writing we are using [version 2.6 of InfluxDB on port 8086](http://admin:adminadmin@localhost:8086). + +In Node-RED we will be passing the power consumption number through MQTT. + +![Overview](./docs/images/influx-flow.png) + +By default this will be passed as a string, so we need to create a function to convert it into a Number before storing it in InfluxDB. + +Add a function node to the page and put the following code into the node: + +```JavaScript +msg.payload = Number(msg.payload) +return msg; +``` + +![Function](./docs/images/influx-function.png) + +You can forward this message to InfluxDB. + +![Influx Node](./docs/images/influx-node.png) + +The `URL`of our InfluxDB is `http://influxdb:8086`. In InfluxDB you have to create a `token` to connect: [Load Data -> API Tokens](http://localhost:8086/orgs/721027680173bf2f/load-data/tokens). + +![Influx Create Token](./docs/images/influx-create-token.png) + +You can use this `token` to create a connection in Node-RED. + +![Influx Connection](./docs/images/influx-connection.png) + +Then the measurements should be visible in [Influx Data Explorer](http://localhost:8086/orgs/721027680173bf2f/data-explorer?bucket=test). + +![Influx Data Explorer](./docs/images/influx-data-explorer.png) + +As the data is now stored in Influx, [let's create a dashboard in Grafana](../dashboard/README.md). + +# Links + +* [IoT Made Easy with Node-RED and InfluxDB](https://www.influxdata.com/blog/iot-easy-node-red-influxdb/) +* A great tutorial can be found at [microcontrollerlab.com](https://microcontrollerslab.com/esp32-mqtt-publish-multiple-sensor-readings-node-red/) + + +