0% found this document useful (0 votes)
174 views

Using The DHT11 Sensor With Raspberry Pi To Measure Temperature and Humidity

The document discusses using a DHT11 sensor with a Raspberry Pi to measure temperature and humidity. It describes the DHT11 sensor's specifications and capabilities. It then provides instructions on installing the Adafruit LCD and DHT11 libraries on the Raspberry Pi to interface the sensor with a LCD display. Circuit connections are also shown between the DHT11 sensor, LCD display, and Raspberry Pi GPIO pins.

Uploaded by

Vimal
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
174 views

Using The DHT11 Sensor With Raspberry Pi To Measure Temperature and Humidity

The document discusses using a DHT11 sensor with a Raspberry Pi to measure temperature and humidity. It describes the DHT11 sensor's specifications and capabilities. It then provides instructions on installing the Adafruit LCD and DHT11 libraries on the Raspberry Pi to interface the sensor with a LCD display. Circuit connections are also shown between the DHT11 sensor, LCD display, and Raspberry Pi GPIO pins.

Uploaded by

Vimal
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Using the DHT11 Sensor with Raspberry Pi to Measure Temperature

and Humidity

Introduction:
Measuring temperature and humidity are useful functions performed by
various sensors. One common sensor is the DHT11 which not only offers
accuracy but a wide range too. We can easily interface the DHT11 with our
microprocessors/microcontrollers. In this article, we will be teaching you
how to interface a DH11 sensor with your Raspberry Pi which will display
its readings on a 16×2 LCD screen.

The DHT11 Sensor:


The DHT11 is a basic, low cost, digital humidity, and temperature sensor. It
measures temperature from 0-50°C with an accuracy of ±2 °C. It also
measures humidity from 20-90% RH with an accuracy of ±5 %. It is
available in a module form and a sensor form. We will be using the module
form in this tutorial. Both of them differ in this sense that the sensor has a
filtering capacitor and a pull-up resistor attached to the output pin of the
sensor.

Working of the DH11 Sensor:


The sensor comes with a blue or white casing which has two important
components we will use. One is a pair of electrodes; the electric resistance
between these two electrodes is controlled by the moisture holding
substrate i.e. the measured resistance is inversely proportional to the
relative humidity of the environment. Keep in mind this relative humidity not
actual humidity so it measured the water content in the air relative to
temperature in the air. The second component is a surface mounted NTC
(Negative Temperature Coefficient) Thermistor. With the increase in
temperature, the value of resistance will decrease.

Pre-Requisites for this Project:


Your Raspberry Pi should be interfaced with an Operating System and
should connect to the internet. You should also have access to your pi
either through terminal windows or through other application through
which you can write and execute python programs and use the terminal
window
Installing the Adafruit LCD library on
your Raspberry Pi:
Sensor data will be displayed on a 16 x 2 LCD display. We will use Adafruit
to easily operate this LCD in 4-bit mode, so we will install it in our
Raspberry Pi. For this follow the following steps:
Step 1:
First, use the below-provided line to install it on your Raspberry Pi. It will
allow us to clone our project file on Github, so we have to install Git in order
to download out the library.
apt-get install git
Step 2:
The provided link is to the Github page where our library is present,
execute this line and the project file will be cloned on your Pi home
directory.
git clone git://github.com/adafruit/Adafruit_Python_CharLCD
Step 3:
Next, use the provided command to change the directory line and open the
project file we just downloaded.
cd Adafruit_Python_CharLCD
Step 4:
You will see a file called setup.py in the directory, we will have to install it to
install the library. Use the provided code below to install the library.
sudo python setup.py install
Now your library should be installed successfully.

Installing the Adafruit DHT11 library on


Your Raspberry Pi:
DHT11 sensor works by sensing the temperature and humidity and then
transmitting the data through the output pin as serial data. We can read this
data through the I/O pin on a microprocessor/microcontroller. In order to
read the values you would have to go through the datasheet of the DHT11
sensor, but for now, to keep things simple we will use a library to talk with
the DHT11 sensor. We will be using the same procedure to install the
DHT11 library as we did for the LCD library. We will only change the link of
the Github page. Use the following commands one by one to install the
DHT library.
git clone https://github.com/adafruit/Adafruit_Python_DHT.git
cd Adafruit_Python_DHT
sudo apt-get install build-essential python-dev
sudo python setup.py install
Now you should have installed both your libraries on your Raspberry Pi.
Circuit Diagram:
For making building circuit you will make the following
connections. Connect the LCD and DHT11 sensor to the 5V pins on the
Raspberry Pi. In case you are using a module you do not need to attach a
resistor on the output pin of the DHT11 sensor. If not then use a pull-up
resistor of 1k. A trimmer potentiometer of 10k is added to the VEE pin of
the LCD. Sensor Output Pin is Connected to GPIO17 ( 11 ) of raspberry pi.

Then next connections are pretty basic but take note of which GPIO pins
you are using to connect the pins since we will need in our program. Make
your connections according to the provided circuit diagram. Since we used
a DHT11 module, we wired it directly to our Raspberry Pi.
DHT11 Sensor Output Pin G

lcd_rs 7 #RS of LCD is c

lcd_en 8 #EN of LCD is c

lcd_d4 25 #D4 of LCD is co

lcd_d5 24 #D5 of LCD is co

lcd_d6 23 #D6 of LCD is co

lcd_d7 18 #D7 of LCD is co

lcd_backlight 0 #LED is not c

You might also like