Grafana is an open platform for beautiful analytics and monitoring. It allows you to create a nice looking dashboards that will give you quick insights into your sensor data.
You will need these components to make it work:
- Debian-based Linux, or macOS
- Mosquitto - MQTT broker
{% hint style="warning" %}
This setup has been tested on:
- Raspberry Pi 3 + Raspbian Jessie
- Turris Omnia + Ubuntu 16.04 (via LXC container)
- macOS 10.13
sudo apt install apt-transport-https curl -y
curl -sL https://repos.influxdata.com/influxdb.key | sudo apt-key add -
{% tabs %} {% tab title="Debian / Raspbian" %}
echo "deb https://repos.influxdata.com/debian stretch stable" | sudo tee /etc/apt/sources.list.d/influxdb.list
{% endtab %}
{% tab title="Ubuntu" %}
echo "deb https://repos.influxdata.com/ubuntu/ xenial stable" | sudo tee /etc/apt/sources.list.d/influxdb.list
{% endtab %} {% endtabs %}
sudo apt update && sudo apt install influxdb
sudo systemctl start influxdb
sudo apt install adduser libfontconfig -y
{% tabs %} {% tab title="Raspberry Pi and Omnia LXC" %}
Step 1: You can manualy download latest version from Grafana, or you can use the following helper to download it for you
wget $(wget "https://api.github.com/repos/fg2it/grafana-on-raspberry/releases/latest" -q -O - | grep browser_download_url | grep armhf.deb | head -n 1 | cut -d '"' -f 4) -O grafana.deb
sudo dpkg -i grafana.deb
{% endtab %}
{% tab title="Desktop (Ubuntu and Debian" %}
curl -sL https://packages.grafana.com/gpg.key | sudo apt-key add -
echo "deb https://packages.grafana.com/oss/deb stable main" | sudo tee /etc/apt/sources.list.d/grafana.list
sudo apt update && sudo apt install grafana -y
{% endtab %} {% endtabs %}
sudo systemctl daemon-reload
sudo systemctl enable grafana-server
sudo systemctl start grafana-server
Continue in the section Connect Mosquitto and InfluxDB.
Step 2: Make sure you have Homebrew installed.
brew install influxdb
brew services start influxdb
Step 2: Make sure you have Homebrew installed
brew install grafana
brew services start grafana
sudo pip3 install --upgrade mqtt2influxdb
sudo mkdir /etc/hardwario
{% hint style="info" %}
For text editing, we use nano editor. You can save changes by pressing key combination Ctrl + O
and exit editor by pressing Ctrl + X
.
{% endhint %}
sudo nano /etc/hardwario/mqtt2influxdb.yml
Configuration possibilities and structure are described at article about mqtt2influxdb
.
{% code title="/etc/hardwario/mqtt2influxdb.yml" %}
mqtt:
host: 127.0.0.1
port: 1883
influxdb:
host: 127.0.0.1
port: 8086
database: node
points:
- measurement: temperature
topic: node/+/thermometer/+/temperature
fields:
value: $.payload
tags:
id: $.topic[1]
channel: $.topic[3]
- measurement: relative-humidity
topic: node/+/hygrometer/0:4/relative-humidity
fields:
value: $.payload
tags:
id: $.topic[1]
- measurement: illuminance
topic: node/+/lux-meter/0:0/illuminance
fields:
value: $.payload
tags:
id: $.topic[1]
- measurement: pressure
topic: node/+/barometer/0:0/pressure
fields:
value: $.payload
tags:
id: $.topic[1]
- measurement: co2
topic: node/+/co2-meter/-/concentration
fields:
value: $.payload
tags:
id: $.topic[1]
- measurement: voltage
topic: node/+/battery/+/voltage
fields:
value: $.payload
tags:
id: $.topic[1]
- measurement: button
topic: node/+/push-button/+/event-count
fields:
value: $.payload
tags:
id: $.topic[1]
channel: $.topic[3]
{% endcode %}
{% hint style="info" %}
In the section tags you can your identifiers, e.g.: tags: room: bedroom
{% endhint %}
mqtt2influxdb -c /etc/hardwario/mqtt2influxdb.yml --test
pm2 start `which python3` --name "mqtt2influxdb" -- `which mqtt2influxdb` -c /etc/hardwario/mqtt2influxdb.yml
pm2 save
{% hint style="info" %} If you want to see temperature records from database in CSV format, use this command:
influx -database node -execute "select * from temperature;" -format csv
Then you must restart the service when you change the configuration file
pm2 restart mqtt2influxdb
{% endhint %}
Step 1: Open the Grafana web interface at http://localhost:3000/ or http://hub.local:3000/ or http://ip:3000/ and log in
- Enter the User
admin
- Enter the Password
admin
Select Add data source and then:
- Enter the Name:
node
- Select the Type:
InfluxDB
- Enter the URL:
http://localhost:8086
- Enter the Database:
node
Finish by clicking on the Add button. At this moment Grafana will try to connect to the data source and replies back with the message Data source is working.
{% file src="../.gitbook/assets/dashboard.json" caption="dashboard.json" %}