DHT11 on Raspberry Pi 3

Posted on

DHT11 (Temperature and Humidity Sensor)

Setup and configuring sensor using Adafruit Python library to read the DHT series of humidity and temperature sensors on a Raspberry Pi. *library is tested with Python 2.6, 2.7, 3.3 and 3.4 using PIP.  Setup Python3, PiP and Git with the following commands.

sudo apt-get update
sudo apt-get install python3-pip
sudo python3 -m pip install --upgrade pip setuptools wheel
sudo apt-get install git

Download GitHub repository of Adafruit lilbrary

git clone https://github.com/adafruit/Adafruit_Python_DHT.git

change directory to Adafruit_Python_DHT folder (*example below)

cd /home/pi/Adafruit_Python_DHT

Install Library from PyPI

sudo pip3 install Adafruit_DHT

Navigate to examples folder and open AdafruitDHT.py and read through the code.

Close the file, open simpletest.py and read through the file and change the values for sensor = Adafruit_DHT.DHT11   and pin = P8_11
Save the file and run in python

python3 simpletest.py