User Tools

Site Tools


Feet Grafana with MQTT data inserted in an influxDB

When having various switches or temperature, humidity, light and/or motion sensors, there might be an interest in storing these over a periodical time for getting an overview what happened when. A great tool to simply store abstract values is influxDB. There is a good documentation how to set it up and install simple values here.

As a next step install Grafana and let it connect to influxdb using one of the default connectors. Within Grafana all the setup is done in the end. One of the best practice processes is to connect to the local MQTT broker, grab the data and store it into the influxdb. Finally Grafana presents the data in a nice way.

Installing influxDB

Download and install the last packages. Using a usual Ubuntu/Debian server on common architecture download

sudo dpkg -i influxdb_1.2.0_amd64.deb

On a RasperryPi run:

curl -sL | sudo apt-key add -
echo "deb jessie stable" | sudo tee /etc/apt/sources.list.d/influxdb.list

sudo apt-get update && sudo apt-get install influxdb
sudo systemctl start influxdb

Initiate MQTT-DB on influxDB

When DB is setup, there needs to be a database being setup, which is named “mqtt” here:

curl -i -XPOST http://localhost:8086/query --data-urlencode "q=CREATE DATABASE mqtt"

Alternative commands can be sent right from the command line, where influxdb is installed:

Show all installed databases (and verify the former command):

influx -execute 'SHOW DATABASES'

Or show all series (aka “tables”) of an influxdb:

influx -execute 'SHOW SERIES' -database="mqtt"

Asking for the last two values of a - in this case via MQTT stored - power plug:

influx -execute 'SELECT * FROM "zuhause/haus/433MHz/steckdose/10001/1" LIMIT 2' -database="mqtt"
name: zuhause/haus/433MHz/steckdose/10001/1
time                value
----                -----
1487603211087000000 1
1487603214268000000 0

Install MQTT2influxDB

There is a modified source from etobi for installing an nodejs module to translate mqtt messages to etobi

Download and install:

git clone
cd influx4mqtt
sudo npm install -g

Then try and run it with connecting to local MQTT:

influx4mqtt -n influxdb-mqtt -u mqtt:// --influx-db mqtt

Install Grafana

On a RaspberryPi there is need for an arm package, so install the specific Grafana-On-Raspberry packages from GitHub for e.g. raspberry pi 2 and 3 (armv7).

sudo dpkg -i grafana_4.1.1-1484347088_armhf.deb

Or for older RaspberryPis (armv6) from here Grafana-On-Raspberry

sudo dpkg -i grafana_4.1.2-1487023486_armhf.deb

On a usual Ubuntu/debian server the amd64 release needs to be installed:

sudo apt-get install -y adduser libfontconfig
sudo dpkg -i grafana_4.1.1-1484211277_amd64.deb

Finally install it as a daemon:

sudo /bin/systemctl daemon-reload
sudo /bin/systemctl enable grafana-server
sudo /bin/systemctl start grafana-server

Grafana will now start-up on port 3000.

Call http://yourIp:3000 in a browser and proceed with the setup.

Add an influxdb-source:

Remind to change the IP to the one of the influxDB-server.

grafanainfluxdb.txt · Last modified: 22.02.2017 20:42 by tigermatze