Sensor Logging Using InfluxDB, Grafana & Hassio

Introduction: Sensor Logging Using InfluxDB, Grafana & Hassio

About: #BnBe is a platform to help teach electronics no matter what the age or skill level. We’re currently designing a wide range of products from beginner level kits to industry-standard microcontroller platforms.

In this post, we learn how to use InfluxDB for long term sensor data storage and we use Grafana for data analysis. This is part of the home automation series where we learn how to set up and use Home Assistant so all this will be done using Hassio.

Step 1: Watch the Video

Please watch the video above as it goes into the details of setting everything up. It is also much easier to follow everything through and see how it all integrates together using video. This written post will only contain the important bits.

Step 2: Add Sensor Nodes

In order to log and analyse data, we first need some sensor nodes so make sure you have added some to home assistant. The previous post shows you how to create a node using the DHT22 sensor along with ESPHome. We also create new nodes that use the DS18B20 and SGP30 sensors in the video embedded into step one.

Step 3: Install InfluxDB

Once we have the sensor nodes in place, we need to start storing their values to InfluxDB. First, we need to install it. This can be done by heading to the add-on store, searching for "InfluxDB" and then clicking the install button. This step will take a minute or two so be sure to give it some time.

Before we can start the add-on, we need to scroll down to the config section and disable SSL by replacing "true" with "false". Save the config and you can then start the add-on. Optionally, you can also enable the "Show in sidebar" option for easier access. The add-on will take a bit of time to start so give it some time. Alternatively, you can scroll down to check the logs and wait for the "Starting Nginx" message to appear which will signify that the add-on has started.

We then need to open the InfluxDB WEB UI and navigate to the admin tab where we can create the database and username. Start by creating a database with the name "homeassistant". Then create a new user with the name and password as "homeassistant". Be sure to give it all permissions before moving further.

Now that we have InfluxDB setup, we need to update the Home Assistant configuration so that the two can communicate with each other. This can be done by updating the configuration.yaml file and the easiest way to update that is by using the configurator add-on. Head over to the add-on store and install configurator. Start it and then open the WEB UI. Use the folder icon in the top-left corner to open the configuration.yaml file and then add the lines with details of the InfluxDB install as shown in the image.

These can also be obtained from the link below:

Once that is done, restart Home Assistant. Once it is back up again, open up InfluxDB and you should now be able to see the sensor data.

Step 4: Install Grafana

Now that InfluxDB has been configured, we need to install Grafana. This can also be installed using the add-on store. Once installed, be sure to disable SSL like before and then start the add-on. Give it a few minutes to start.

Grafana needs to access the data from InfluxDB so it is a good idea to open InfluxDB and create a new user as we did in the previous step. I'm assuming the username and password is "grafana". Once this is done, open up the Grafana WEB UI and select the "Add data source" option. Enter the following URL as the host:

Then, enter the database name which is "homeassistant" along with the username and password we just created. Once done, simply hit the "Save & Test" button which will check if communication is OK. This completes the setup process.

Step 5: Create a Dashboard

Grafana uses something called dashboards which consists of panels. These panels can be charts, graphs and so on. I'd recommend watching the video to learn how to create some basic charts. You can obviously create much more detailed dashboards to represent your data and it is too vast a topic to cover in this post.

Please do consider subscribing to our YouTube channel to help support videos and posts like these:


Thank you for reading!

Be the First to Share


    • Plywood Contest

      Plywood Contest
    • Cheese Challenge

      Cheese Challenge
    • Halloween Contest

      Halloween Contest