In Part 1 and 2 we made it possible to read out the DHT22 sensor and save the data in an InfluxDB database. But this is not so useful if you can’t visualise the data. In this part we will install Grafana on the RPi and visualise the data in the browser.
Install Grafana
Unfortunatelly, the company behind Grafana doesn’t provide a repository for the RPi, but it does provide a debian package. The following commands wil download and install the package:
wget https://dl.grafana.com/oss/release/grafana-rpi_6.2.5_armhf.deb sudo dpkg -i grafana-rpi_6.2.5_armhf.deb
Note 1: you can get the URL from the latest version on the web page of grafana: https://grafana.com/grafana/download?platform=arm
Note 2: I received the error: grafana-rpi depends on libfontconfig1; however: Package libfontconfig1 is not installed. This was solved with the command: apt --fix-broken install
Edit the file /etc/grafana/grafana.ini and remove the semicolon in front of protocol
and http_addr
. This will make the grafana interface accessible on all IP’s using a webbrowser
Next we enable and restart the service:
sudo systemctl enable grafana-server sudo systemctl restart grafana-server
Open a webbrowser and surf to http://<ip-RPi>:3000 where the <ip-RPi> stands for the IP of you raspberry pi.
Configure Grafana
Once you have access to the web page, log in with the username and password: admin
After clicking on Log In for the first time, the option appears to change the password. This can be skipped by clicking skip
Once logged in, click on Add data source
Click on InfluxDB and change the following fields:
Name | InfluxDB |
URL | http://localhost:8086 |
Database | temperature |
User | admin |
Password | Same password used to configure the admin account of InfluxDB |
Click on Save & Test to add the Data Source and click on the + sign > Dashboard. Click on Add Query
Two queries will be created, one for the temperature and one for humanity. For query A, click on the edit icon (Toggle text edit mode) and enter the following query:
SELECT "temperature" FROM "TemperatureSensor" WHERE $timeFilter
Enter Temperature for ALIAS BY for query A. Click on Add Query, click on the edit icon
(Toggle text edit mode) for query B and enter the following query:
SELECT "humidity" FROM "TemperatureSensor" WHERE $timeFilter
Enter Humidity forALIAS BY for query B. On the left side click on General
Enter a panel title and (optional) a description. Finally on top, click the save icon, enter a dashboard name and click Save again.
Now the dashboard can be found under recent dashboards and you have a visual overview of the temperature/humidity.
Thank you so much for putting this online. Even with your detailed instructions it still took me 3 hours.
It’s a mix of networking, security, database management and programming. I’ll sleep tonight, cheers.