Temperature monitor using DHT22 + Grafana + InfluxDB (and a PI) – Part 1

This projected started about 3 years ago as an Arduino project with a Raspberry PI pulling data from a DHT22 sensor and saving it in a csv-file and evolved over time to a DHT22 connected to a Raspberry PI writing data to an InfluxDB and visualising it with Grafana, both running on the RPi. To boost the cool factor, I also added a monochrome LCD display providing the current temperature, but in this part I will only cover the DHT22 Sensor together with Grafana and InfluxDB.

To be honest, you can find allot of projects like this on GitHub, Youtube and other blogs, but most of them are outdated. Mainly the way to install InfluxDB and Grafana has changed allot and that’s why I decided to create my own documentation and write this down in a blogpost.

Requirements + prerequisite

Before starting you should at minimum have following items:

  • 1 x Raspberry Pi (3) with Raspbian
  • 1 x DHT22 sensor
  • 1 x 10kΩ Resistor

The Hardware Stuff

It’s up to you where to start, but in most cases, the fun part is the hardware part and so we start with the hardware and making a basic setup. In this part we will also do a small test-run to see if we can log the data using Python. So let’s get started and connect the components based on the following design:

Once done, start the Raspberry Pi and open a terminal or SSH-Session. Then we start with the installation of the prerequisite:

sudo apt-get install build-essential python-dev python-openssl git

Next, we download the DHT python library’s from Adafruit and install them

git clone https://github.com/adafruit/Adafruit_Python_DHT.git && cd Adafruit_Python_DHT
sudo python setup.py install

Finally we perform a test by going to examples and run the script AdafruitDHT.py with 2 parameters: the first parameter is version of the sensor (in this case 22) and the second parameter is the GPIO Pin (in this case 2)

cd examples
sudo ./AdafruitDHT.py 22 2

You should see a result like:

Pro-Tip: Not sure about the pins. You can install gpiozero and get an overview of the pins

sudo apt install python3-gpiozero
pinout

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.