Install Grafana on macOS and Raspbian for Raspberry Pi. Example dashboard for connected object MySensors with Node-RED and InfluxDB [Update]

Grafana is an Open Source software that allows time-dependent dashboards and graphs of data. Grafana runs on Windows PC (64-bit), macOS and Raspbian for Raspberry Pi. Grafana supports 6 databases (CloudWatch, Elasticsearch, Graphite, InfluxDB, OpenTSDB and Prometheus). Grafana is very well suited for displaying data from connected objects. It’s the solution of choice for creating a stylish dashboard for your Arduino, ESP8266 or ESP32 projects.

 

In this tutorial we will see how to install Grafana on Raspberry Pi or macOS. We will use the measurements of a temperature probe developed with Arduino Nano and the MySensors library. The data was collected using Node-RED and stored in an InfluxDB database.

Example, make a dashboard for your DIY connected objects

To show what can be done with Grafana, I propose to use the previous project of temperature probe developed with an Arduino Nano. The measurements are transmitted by radio waves to a Gateway MySensors. Node-RED is used to retrieve and decode the measurements transmitted using the MySensors protocol. The temperature and humidity measurements will be stored in an InfluxDB database. Finally, we will connect Grafana to the InfluxDB database to plot the graphs in real time.

Before you get started with Grafana’s installation and dashboarding, here are some articles to read to get started

Get started with the MySensors v2 Arduino Library
The library makes it possible to develop connected objects that communicate by radio waves. Ideal in the absence of WiFi coverage to create a network of connected objects
Get started with the MySensors v2 Arduino Library
Making a MySensors WiFi Gateway with an ESP8266 Module
It is very easy to communicate with a network of MySensors connected objects from a home automation server by manufacturing a WiFi Gateway using an ESP8266 module
Making a MySensors WiFi Gateway with an ESP8266 Module
Make a temperature probe Arduino Nano DHT22 MySensors
Radio transmission with MySensors v2 and nRF24L01
Make a temperature probe Arduino Nano DHT22 MySensors
Install InfluxDB on Raspberry Pi, Windows, macOS
Discovery of the Shell. Create a database, retention policy
Install InfluxDB on Raspberry Pi, Windows, macOS
MySensors v2 : decoder and send messages with Node-RED
It is very easy to decode the MySensors protocol with Node-RED
MySensors v2 : decoder and send messages with Node-RED
Record measurements of a connected MySensors object in an InfluxDB database using Node-RED
How to use Node-RED to record measurements from MySensors, Arduino Serial, MQTT ... connected objects in an InfluxDB database
Record measurements of a connected MySensors object in an InfluxDB database using Node-RED

Install Grafana on Raspbian for Raspberry Pi

Before installing Grafana, it is necessary to install some resources and to indicate to Raspbian or to recover the sources of Grafana

The installation lasts only a few minutes.

For security, the HTTP protocol that allows access to the WEB interface to the Grafana API is disabled. We will modify the configuration file and activate the HTTP protocol by modifying the file /etc/grafana/grafana.ini

Uncomment the http protocol and the port. For security, you can also restrict access to Grafana to specified positions with the key http_addr

After making these changes, we restart the Grafana service

Install Grafana on macOS

macOS version tested : 10.11.6 (El Captain) on a Mac Mini 2011

Grafana installs on macOS using Brew. BREW is a package manager for Mac ( project official page).

node-red mongodb brew

open a Terminal and paste this command

Answer the questions to complete the installation of Brew on your Mac.

Now we can very easily install Grafana by running this command (source of orders).

At the end of installation Brew gives us some valuable guidance on installation directories (not always well documented)

We start the Grafana service with this command (accept incoming connections in the window that opens after a few moments).

First connexion to Grafana

Open any internet browser and write this address

Grafana has its own user management system with authentication and rights management. You can login with admin / admin.

 

grafana login

Or directly create a new user account. In this case, you must fill in a name, an email and a password.

https://i2.wp.com/www.projetsdiy.fr/wp-content/uploads/2016/11/2-grafana-setup-creation-compte.png?resize=660%2C267

We arrive at a blank home screen

grafana dashboard premier lancement

When we just create an account, the last thing left to do is the creation of an organization.

https://i2.wp.com/www.projetsdiy.fr/wp-content/uploads/2016/11/5-grafana-nouvelle-organisation.png?resize=597%2C292

Add Data source

Before you can draw anything, it must already add data sources. Go to the menu then Data sources.

grafana menu data sources

Grafana supports 6 data sources:

  • CloudWatch . It is a monitoring service for the users of Amazon AWS resources
  • Elasticsearch . It is a database-oriented document that is very efficient to carry out research in very large volumes of data very quickly.
  • graphite. An Open Source database for monitoring tailored to monitor services or sites internet (among others)
  • InfluxDB . An Open Source database developed by the company InfluxData specializes in recording data function of time. It is very well suited for output measures from connected objects
  • OpenTSDB . Equivalent of InfluxDB
  • Prometheus . Also an equivalent to InfluxDB. Prometheus is available for macOS, Linux and Windows .

click Add data source to start adding a new data source.

6-grafana-ajout-data-source

Connect a InfluxDB database

In this tutorial, we will connect to an InfluxDB database powered by measures of a temperature (realized with the MySensors library) DHT22 probe using a Node-RED flow.

Configure data source:

  • Name : enter a name for the data source. This is the name that will be displayed in the list of sources in the creation of a graph.
  • default: check if this is your default data source to win some time
  • Type: choose InfluxDB
  • Url : the address of the database. If Grafana is installed on the same machine as the database, it will be http://localhost:8086. Customize the Url based on your configuration.
  • Http Auth : choose the adequate authentication mode if your base is protected
  • Database : the name of the database on which is connected the source
  • use and Password : If you have set up protection at the database, fill in the fields.
  • save with Save & Test . If everything is correct a Success, Data source is working green message should appear below

grafana edit data source influxdb

In this example, I set up two data sources: Temperatures and humidity.

grafana-source-donnees-temperature-humidite-configurees

Add a new Dashboard

Let’s get serious now and add a new Dashboard that will contain our graphics. Open the Menu then Dashboards then + NEW.

grafana nouveau new dashboard

Give it a name. Press the notched wheel then Settings (in the bar).

grafana-edition-dashboard

Give a name to the Dashboard. Here, I gave the name sensors MySensors.

grafana-general-settings-dashboard

Register with the small disk or CTRL+S.

grafana-sauvegarde-graphique

Add measurements from a DHT22 MySensors probe

Open the Dashboard. The interface is a little confusing. To add a chart (or another element of the Dashboard),  you must open the small green drawer located on the left edge of the screen.

Note. There is a drawer for each line added (Add Row).

grafana-nouveau-graph

The first thing to do and choose the data source. For example select the source Temperature list Panel data source.

grafana-choix-data-source

Then unfold the source a. selected the data to display. Here, we’ll pick Node3 (which corresponds to the node 3 of the MySensors object on which I recover measures). The Alias By field allows to assign a label that will be displayed in the legend. Otherwise, by default, Grafana uses the name of the source.

grafana-edition-source-de-donnees-selection-variable-noeud3

Then go to the General tab and type a title for the chart (which will be displayed at the top of the chart).

grafana-edition-graphique-onglet-general

Now, in the Axes tab, you can specify the unit of measure. In this case, we will choose Celicus.

grafana-graphique-unite-axe-y

you can also set the minimum value (Y – Min) and full scale (Y – Max). It is also possible to create a second Y axis on the right. Finally, you can add lines (or areas) of threshold (Thresholds) that allows to define an area in which we would like to think the measure. Version 4 introduces a very useful alert system that we discovered in a future tutorial.

grafana-parametres-graphique-onglet-axes

on the Legend tab, you can enable or disable its display and choose additional values: minimum, maximum, average (avg for average), current (current), total and finally the number of decimal places.

grafana-editino-graphique-onglet-legend

save the graph with the disc or Ctrl + S.

grafana-sauvegarde-graphique

Discover the first graph

Once setup is complete, here is what you get. This graph shows the measures retrieved from an Arduino running MySensors. It returns the measurements of a Dallas DS18B20 waterproof probe as well as the temperature and humidity of a DHT22

grafana graph dashboard mysensors dht22 temperature humidite

You can zoom in on a portion of the chart with the mouse or using the time selector.

grafana choix periode de temps

Open to set a custom range. We can choose to the right of the presets or manually. The key word now is used to set the current time (now). If you want action on the last hour, simply enter now-1h. Up to now (To -> Now). Finally, if we wish that the graph is updated regularly, we can choose the frequency in the Refreshing every list). Here, the graph will be updated every 5 seconds.

grafana-periode-affichee-frequence-rafraichissement

That’s it for the first part. Grafana is really a graphical presentation tool very powerful and fairly simple to use.

DIY connected objects tutorials

More tutorials to make your DIY connected objects

See all the other tutorials in the category connected objects

 

Updates

[06/06/2018] – Installation procedure of Grafana on Raspbian Stretch. Links to other tutorials to develop a dashboard for IoT with Grafana

Subscribe to the weekly newsletter

No spam and no other use will be made of your email. You can unsubscribe anytime.

DIY Projects