Grafana is the 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.

Requirements

You will need these components to make it work:

  • Debian-based Linux

  • Mosquitto - MQTT broker

Installing InfluxDB

The database to store collected data.

  1. Install dependency packages:

    sudo apt install apt-transport-https curl -y
    
  2. Add repository key:

    curl -sL https://repos.influxdata.com/influxdb.key | sudo apt-key add -
    
  3. Add repository to source list:

    • On Debian and/or Raspbian use:

      echo "deb https://repos.influxdata.com/debian jessie stable" | sudo tee /etc/apt/sources.list.d/influxdb.list
      
    • On Ubuntu 16.04 use:

      echo "deb https://repos.influxdata.com/ubuntu/ xenial stable" | sudo tee /etc/apt/sources.list.d/influxdb.list
      
  4. Update the package list and install the packages:

    sudo apt update && sudo apt install influxdb
    
  5. Now you can start the InfluxDB service:

    sudo systemctl start influxdb
    

Installing Grafana

  1. Install dependencies:

    sudo apt install adduser libfontconfig -y
    
  2. Based on your taget platform, select the appropriate procedure:

    • For Raspberry Pi and Omnia LXC:

      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
        
      2. Then install the package:

        sudo dpkg -i grafana.deb
        
    • For desktop (Ubuntu and Debian):

      1. Add repository key:

        curl -sL https://packagecloud.io/gpg.key | sudo apt-key add -
        
      2. Add repository to source list:

        echo "deb https://packagecloud.io/grafana/stable/debian/ jessie main" | sudo tee /etc/apt/sources.list.d/grafana.list
        
      3. Then update the package list and install the package:

        sudo apt update && sudo apt install grafana -y
        
  3. Reload the systemd configuration:

    sudo systemctl daemon-reload
    
  4. Enable Grafana on boot:

    sudo systemctl enable grafana-server
    
  5. Now you can start the Grafana server:

    sudo systemctl start grafana-server
    

Connect Mosquitto and InfluxDB

  1. Install the MQTT to InfluxDB service:

    sudo pip3 install --upgrade --no-cache-dir mqtt2influxdb
    
  2. Open the configuration file:

    sudo nano /etc/bigclown/mqtt2influxdb.yml
    
  3. Paste this snippet to the configuration file:

    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]
    
  4. Configuration file test:

    mqtt2influxdb -c /etc/bigclown/mqtt2influxdb.yml --test
    
  5. Start the MQTT to InfluxDB service:

    pm2 start /usr/bin/python3 --name "mqtt2influxdb" -- /usr/local/bin/mqtt2influxdb -c /etc/bigclown/mqtt2influxdb.yml
    
  6. Save the PM2 state (so it will start after reboot):

    pm2 save
    

Configure the Grafana.

  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

  2. Create a data source.

    Just click on Add data source and:

    • 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 tries to connect to the data source and reports back the message Data source is working.

  3. Download dashboard.json or Copy to clipboard

    dashboard.json

  4. Import the visualization dashboards, click the Graphana icon (at the top left), select Dashboarts in the menu, then Import

  5. Upload .json File or Paste JSON.

  6. Choose node as a data source and click on Import:

  7. Result for Wireless Climate Monitor and Wireless CO2 Monitor