Tag Archives: nodered

Sensors Monitoring – Grafana Configuration

After configuring nodered to forward the data to the databases, temperature and humidity sensors are used with ESP8266, as already seen in the previous articles

Mqtt with Beaglebone and ESP8266 – Articles List

Below is the firmware used and the code for sending data from the ESP8266 nodes

ESP8266 Firmware

ESP8266 Temp-Hum

Inside the zip file there is a script to upload the firmware to the COMX port (to be modified with your COM port) on windows.

In the LUA code instead it is necessary to enter the settings of your wireless router, the mqtt ip address, the room settings, replacing roomx, with room1, room2,etc.

You can then set Grafana, accessing the Dashboard, adding Mysql and InfluxDB as data sources

grafanaSourceWith Add data source you access the Data Source screen, from which you can choose InfluxDB and MySql

grafanaAddSourceBelow  the settings for InfluxDB and MySql

InfluxDB

InfluxDBESPMySqlMySqlESPThe two connections are listed in the datasource configuration

AllDataSourceBelow there is the export of the two Dashboards used in the article to be imported on your system with the Import button

importDashboards

Dashboards

Here is the ESPRealtime Dashboard screen with the data available  on the InfluxDB

RealTimeGrafanaTo view the data history, we use MySql data in the ESPHistory Dashboard

HistoryGrafana

 

 

Sensors Monitoring – Nodered Configuration

At this point we set nodered to read the messages on Mosquitto and insert the data into InfluxDB and MySql.

Below the json file to be imported into nodered

Nodered Json

This flow is functional to the explanation of the functioning of the architecture as a whole; the flow must be optimized by programming nodered so as to automatically generate the information of the nodes from which the data arrives without resorting to different nodes for each sensor.

To execute the import proceed as follows, after accessing nodered

http://dashboardora.local/nodered

and after clicking on the menu on the right, choose to import the json from the clipboard

importFlowsAt the next screen, choose to import the json file into a new flow

flowOnce imported, set the credentials to access MySql and InfluxDB, selecting Configuration nodes from the menu on the right and setting the user account and password

configureNodesThe connections to the dbs and mosquitto are shown

configureNodesDBBelow is the MySql setting, accessed by clicking the mouse twice on ESPMYSQL

MySqlSettingUpdate button updates the node.

To make the flows operational click on Deploy

deploy

Now, with nodered we take the contents of the various mqtt topics and insert them into MySql and InfluxDB.

In the next article we display these data in Grafana

Sensors Monitoring – Grafana Configuration

Sensors Monitoring – InfluxDB Configuration

After MySql tables creation

Sensors Monitoring – MySql Configuration

we have to create a database  on InfluxDB.

The first step is to activate an administrative user on the system, as described in the link

Authentication and Authorization

InfluxDB  is accessed from the local client by running the influx command from a shell

Run

In the file /etc/infuxdb/influxdb.conf, using the root user or the sudo command, the auth-enabled parameter is set from false to true

Restart influxdb

Using a command shell on Debian  create the database DATAESP with the following commands

Enter the admin credentials to the auth command and proceed to create the database

Below is the result of the commands listed above

datainfluxdb

For the management of the Influxdb database, it is possible to use Chronograph

Chronograph

The Chronograph download is available at the link

Chronograph Download

Installation can be performed in two ways.

Application start

Log in with the monitor user and in a command shell

Start the chronograf application

 

Start as a Service

Log in with the monitor user; use a command shell to execute

In the /opt/chronograf/usr/lib/chronograf/scripts folder there are scripts for the automatic start of chronograf.

Here are the operations performed in our system:

  • Copy /opt/chronograf/usr/lib/chronograf/scripts/init.sh into /etc/init.d/chronograf and assign execution permissions

  • Copy /opt/chronograf/usr/lib/chronograf/scripts/chronogaf.service  into /etc/systemd/system/chronograf.service

Change in both files the user and path of the various chronograf components, i.e. change the user to monitor and the paths that point to /opt/chronograf

Below is the link to the modified files

Automatic Startup Chronograf

After the modifications run

To enable it at startup and start it run

After starting chronograf in one of the ways described above, it can be accessed via browser and port 8888

http://dashboardora.local:8888

ChronografPress Get Started and set the connection and the credentials of the admin user with relative password defined before

Chronograf2conSet up the Influxdb dashboard

ChronografDashboardDo not set the Kapacitor component

Chronograf3Complete the configuration and by clicking on View All Connections

Chronograf4we access to the newly created connection

ChronografConnections

This component can be useful later to manage and monitor InfluxDB.

In the next article, we ‘ll define the rules on Nodered to populate MySql and InfluxDB databases with the data sent by the sensors

Sensors Monitoring – Nodered Configuration

 

 

 

 

Sensors Monitoring – MySql Configuration

After the software installation on Orange Pi PC we proceed to the their configuration

Sensors Monitoring – Envinronment Setup 2

Creating Tables on MySql

On MySql 3 tables have been created containing the values of temperature, humidity and pressure of the sensors.

Here is the MySql model

MySql Model

to import into MySql Workbench

ESPModelloOnce imported, access the Database-> Forward Engineering menu and import the tables on your MySql system on the Orange Pi PC, by entering the MySql root user and relative password

ESPImportAt the next screen we  use the connection created on MySql Workbench to connect to the database

ESPImport1Leave everything by default and enter the root password when prompted.

The tables are now available on the database

ESPTablesIn the next article we configure InfluxDb to store data in real time sent by the sensors

Sensors Monitoring – InfluxDB Configuration

Sensors Monitoring – Envinronment Setup 2

After the software components installation in the previous article

Sensors Monitoring – Eninronment Setup

we finish this operation with this article.

Infludb

The Influxdb is installed as indicated in the link

Influxdb

For Debian 9 we execute the following commands

Check that everything works correctly by connecting with the infludb client

infux

Nodered

We proceed to the installation of node.js

Then we proceed to  nodered installation, as indicated at the link

Nodered installation

To run nodered at the start up, we use the script available at the following link

Nodered autostart

We did not run the automated script, but executed the following steps

Edit /etc/init.d/nodered and change the user from pi to monitor, ie change the parameter

in

Run

Start  nodered

Check that nodered works by accessing the following link with the browser

http://dashboardora.local:1880

nodered

Restart the system and check that nodered starts automatically.

Proceed to the installation of the nodered add-ons

 

Grafana

We proceed to download the version for arm

Grafana for ARM

Enable and start Grafana

Access the system using the url

http://dashboardora.local:3000

Log in with the user admin and password admin; change the password

GrafanaOnce the new password has been set, the setup interface is available

Grafana2In the next articles we will execute the settings to be able to view the sensors data.

Reverse Proxy installation

To access the system through port 80 of the http server we use nginx as a reverse proxy

nginx

We disable apache

We proceed to the installation of nginx

Everything must be configured to access the two systems using the following links

http://dashboardora.local/nodered for nodered

http://dashboardora.local/grafana for grafana

For Grafana we follow the official documentation

Grafana proxy

We change the file /etc/grafana/grafana.ini by modifying the domain and root_url parameters; in our file the parameteres are modified  as follows

Then we configure nginx, creating the servizi file with the following contents in the /etc/nginx/sites-available folder

Here is the link of the nginx configuration

nginx configuration

We run the following command

and start nginx and grafana services

At this point it is possible to access the two services via the links

http://dashboardora.local/nodered

nodered-nginx

http://dashboardora.local/grafana

grafana-nginxIn the next article we start the configuration of the various modules needed for the sensors monitoring

Sensors Monitoring – MySql Configuration

Sensors Monitoring – Envinronment Setup

In setting up the infrastructure for monitoring sensors made up of ESP8266 devices in previously published articles

Mqtt with Beaglebone ed ESP8266 – Freeboard

Freeboard had been set up to display the data coming from the sensors.

In this new series of articles, we  set up Grafana

Grafana Dashboard

as  environment to view the data of the various sensors.

We implement the environment, in this case,  on an Orange Pi PC board, but other arm or pc system can be used.

Below the architecture used in this series of articles

archGrafana

In these articles we’ll use the maximum authorizations for each environment, we will not use authorizations on mosquitto and no encrypted connections will be used. In a test environment this setting is fine, but in an operating environment it is necessary to set up the correct authorizations and possibly the encryptions in the connections in all environments.

We have installed our compiled version of Debian 9 Stretch for Orange PI PC. The image used is the following

Image Download

The monitor user was created during the Image setup, while the hostname was renamed in dashboardora. If not installed proceed to install the avahi daemon

In this way the services can be accessed by publishing the hostname, i.e. dashboardora.local.

Using the armbian utilities  disable ip6 on the system; to carry out this setting launch armbian-config

ipv6Disable1Proceed to diasble IPV6

ipv6Disable2

As a first step we install the  mqtt broker mosquitto

Install the http services and the databases Mysql and MySqlWorkbench

Apache2

and various prerequisites

Start apache

and check that the server responds to the web address, which in our case corresponds to http://dashboardora.local

apache

MySql

Debian 9  comes with MariaDB; you must set the password for the database administration user root with the following command

We set the root password and the ability to log in from other hosts as root

mariadb-secureThe other chosen options are listed below

mariadb-secure2

We install phpmyadmin for database management

At the next screen choose apache2

phpmyadminFinally choose NO

phpmyadmin1

Run the commands listed below

Check that the system works correctly by accessing via web browser by adding to the apache phpmyadmin address, in our case

http://dashboardora.local/phpmyadmin

phpmyadmin2

Log in with the database root credentials.

Mariadb must be enabled to accept connections from other hosts. To do this, go to the folder

and edit the 50-server.cnf file as root, changing the setting

in

To allow the root database user to be able to access from an external client, it is necessary to log on mariadb locally with his client and enable this option; therefore the following is performed

 

Mysql Workbench Installation on PC

Go to the following link

MySql Workbench

and download the version for your operating system; proceed with the installation.

For Linux the package is also available in the distribution repositories.

After configuring the connection, you access the MySql system control screen.

MySQLWorkbenchIn the next article we will continue the installation of the other components to be able to monitor the sensors

Sensors Monitoring – Envinronment Setup 2