Tag Archives: linux

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

MicroPython – Nodes examples with DHT11, Relay and MQTT

In a series of articles seen previously  on Mqtt, Beaglebone and ESP8266

Mqtt with Beaglebone and ESP8266 – Articles List

we have created the infrastructure for managing the ESP8266 nodes .

In this article we program the two ESP8266 nodes  using MicroPython instead of Nodemcu and Lua.

The infrastructure remains identical; on the Beaglebone there is Mqtt Mosquitto Server and Freeboard for the management of the mqtt topics, visualization and interaction.

The ESP8266 node examples with relay and DHT11 sensor use the umqtt MicroPython libraries, available on the site

umqtt simple

In the following examples, only the umqtt simple is used; in the code several delays have been inserted to allow the board to manage the messages and not run into errors; in the case the Mqtt server is not available the code restarts the board.

Below the code used for these examples.

Node with DHT11 sensor

  • boot.py: code executed at startup

  • umqtt/simple.py:  mqtt library

  • dht11.py: module for reading the temperature and humidity on the GPIO2

  • main.py: code executed after boot

  •  client_mqtt.py: Main module for node management

  • riavvia.py: service code to restart the module from uPyCraft

 

Node with relay

  • boot.py: code executed at startup

  • umqtt/simple.py: mqtt library

    • main.py: code executed after boot

    •  client_mqtt.py: Main module for node management

  • riavvia.py: service code to restart the module from uPyCraft

Below is the filesystem on ESP8266 for the relays sample

ESPFilesystemBy accessing Freeboard we have the same informations obtained with Nodemcu and LUA on ESP8266 nodes

FreeboardMicroPythonBelow are the screens with MQTT Dashboard installed on an Android smartphone, with the possibility to check the status of the relay, read the sensor parameters, restart and sleep the two nodes

MqttPublish

MqttSubscribe

Here are the links to download the two examples

DHT11 sensor sample

Relay sample

In the next article we will compile the MicroPython firmware for ESP8266

MicroPython – MicroPython compiling for ESP8266

 

 

 

 

OctoPrint installation on Orange PI PC – Print Test File

After the OctoPrint server configuration

Printer settings

we set the connection parameters for the printer.

After connecting to the OctoPrint server with the octoprint user and password as password, we set up the printer connection

octoprint-connessione

With these settings it is possible to print a gcode file already generated with Cura or Slic3r

Cura

Slic3r

or upload a stl file on which the slice will be executed using the loaded cura profile and the CuraEngine on the Orange Pi PC system.

In the case where a stl file is imported, the slicing of the file is proposed

octoprint-sliceAt this point the file is ready for printing

octoprint-fileslicedOnce the printing is started, the progress and temperature can be checked

octoprint-progressbaras the layers that are being created

octoprint-sliceprogressIn this example, the basic settings were used to start the system for the first time.

For further information and configurations on OctoPrint refer to the software documentation

Octoprint Documentation

At the following link the supported printers are listed

Supported printers

OctoPrint installation on Orange PI PC – Printer Settings

After  defining the local hostname resolution

Local Hostname Resolution

at this point it is necessary to configure the printer.

WARNING: Use of the settings shown is at your own risk. We assume no responsibility if these settings cause malfunctions or breakage of the printer.

At the first access to OctoPrint, the basic parameters for managing the printer are requested. In our case, we connect the Orange PI PC to an Anet A8 3d printer via the USB port. At the first access to the address

http://3dprinter.local

 a configuration mask is shown

octoprint-accesspressing next we access the next screen where to define the user who manages the printer with his password

octoprint-accesscontrolWe press Keep Access Control; the next step is  the control of the Internet connection in which we disable the Connectivity Check

octoprint-accessconnectivityWe have to import our cura profile for Anet A8 and set  the path to the executable CuraEngine, compiled in the previous article

Octoprint Installation

octoprint-printerprofile

octoprint-curaengine

The imported profile must be generated by Cura 15.04.x or older. Below is the link to the various versions of the Cura software

Cura

We can now define the parameters of the printer, in our case Anet A8

octoprint-printer1We set the bed size and print volume

octoprint-printer2The speed of movement using the control panel is defined in the next step; we set up conservative parameters

octoprint-printer3Finally, we set the extruder parameters

octoprint-printer4

At the next screen we set the commands to be sent to Debian directly from OctoPrint; they are set as follows

octoprint-command

where in the password you must enter the password to run the root commands on Debian.


The folder in which Octoprint has been installed is inserted for the software update

octoprint-swupdateWe do not insert anything for the webcam

octoprint-webcamFinally, the configuration is completed with the Finish button.

octoprint-finishFor more OctoPrint settings and addons refer to the site

OctoPrint

In the next article we’ll print a test model

Print test file

OctoPrint installation on Orange PI PC – Local Hostname Resolution

After configuring haproxy for the use of content in http on the standard port

HAProxy Installation

we configure the Linux machine to publish the hostname on the network with the avahi daemon.

On Linux and OSX machines this service is natively visible, while for Windows systems it is necessary to install the Bonjour service

Bonjour application for windows

On the Orange PI PC the avahi daemon must be installed with the command

We change the name to which our 3D print server must match in the two files /etc/hosts and /etc/hostname

In our case the name orangepcpc has been changed to 3dprinter.

Restarting the linux box, the services are accessible  using the name 3dprinter.local.

avahiIn the next article we’ll show a printer configuration

Printer Settings