As we all know that there are instruments for measuring the temperature and humidity of our environment. They are employed by the meteorological centers in the process of rain prediction. The cost of those devices is a few thousand and we can't afford them easily. But by using the DHT11 sensor we can measure the temperature and humidity level of our room on a small scale.
The values can be acquired by interfacing the DHT11 sensor with the raspberry pi module and LCD display. This interfacing is pretty simple and can be used as a reference for measuring temperature and humidity levels at a large scale in the future. We are going to learn about the entire process involved in this interfacing, starting from the list of required components.
The following list provides the hardware and software components required to perform this interfacing.
DHT11 sensor is a low-cost digital sensor used to measure temperature and humidity levels. They can be easily interfaced with microcontroller-based devices such as Arduino board, raspberry pi module. The sensor contains a capacitive humidity sensor for detecting the humidity level. The change in capacitance value occurs with the change in humidity level. The IC process changed value and convert them into digital form.
For measuring the temperature this sensor employs a thermistor that has a negative temperature coefficient. This DHT11 sensor is small-sized and has an operating voltage from 3 to 5 volts.
2.Raspberry Pi 3:
We are using Raspberrypi to connect with the fingerprint module and display the output. It contains several I/O pins using which we can connect the module and then by coding the Raspberrypi, we will receive the commands/signals that are sent from the fingerprint sensor.
These are simple connecting wires, that are used to connect the ends without any soldering. The male wires have the ends that can be connected to other ends and the female wires are the ones that have the receiving end. In this interfacing, female to female wires is used.
This cable is used to connect the RaspberryPi to the power supply. It also helps in the transmission of data.
This 16x2 LCD display has 2 rows and 16 columns and a total of 32 characters can be displayed. The operating voltage of this display is fro 4.7V to 5.3 V. The display is available in black, blue backlight and it can also display any custom generated characters.
6. 12C module for LCD display:
This 12C module has an inbuilt PCF8574 I2C chip that converts the serial data to the parallel data for the LCD display. This module has a contrast adjustment pot beneath the display. This helps to display the text correctly. The potentiometer toggles the brightness level of the LCD and the LED controls the backlight of the display.
The SHH Terminal is used in this project to connect the Raspberry Pi module to the terminal of another computer.
Python Programming is done in an IDE (Integrated Development Environment) is a platform where we can write the code, run, and test the working.
The DHT11 sensor if first interfaced with the raspberry pi module. Then the 16x2 LCD display is connected to the circuit so as to view the results.
What goes where?
The yellow wire connects the signal pin of the DHT11 sensor to the pin GPIO 4 of the raspberry pi 3 board.
The red wire connects the voltage pin(power supply) of the sensor to the 5V pin of the raspberry pi board.
The black wire connects the GND (ground) pin of the sensor to the GND pin of the raspberry pi device.
By performing these connections, the DHT11 sensor can be interfaced with the raspberry pi module. Now, this circuit has to be interfaced with the 16x2 LCD display.
The black wire connects the GND (ground) pin of the LCD display to the GND pin of the raspberry pi device.
The red wire connects the voltage pin(power supply) of the LCD display to the 5V pin of the raspberry pi board.
The blue wire connects the SDA pin of the LCD display to the SDA pin of the raspberry pi device.
The orange wire connects the SCL pin of the LCD display to the SCL pin of the raspberry pi board.
After performing the above connections, the power supply is given. The raspberry pi device gets boot up.
Few more steps are needed to be performed before acquiring the temperature and humidity level values. For newer versions of raspberry pi, to enable the one-wire interface, certain code has to be executed.
The following steps have to be followed to install the Adafruit library for interfacing the DHT11 sensor with the raspberry pi device.
Step-1: Install the Adafruit library for DHT11/DHT22 by running the command given below on the RPi terminal
git clone https://github.com/adafruit/Adafruit_Python_DHT.git
Step-2: Run through these commands given below one by one to successfully install the library on you RPi
sudo apt-get install build-essential python-dev
sudo python setup.py install
Step-3 (Optional, for newer versions of RPi): If the device you are using returns "None" values, then use the commands given below
(i) Run "sudo raspi-config" in the terminal
(ii) Select "Interfacing Options" from the list that appears on the screen
(iii) Select the "One-wire Interface" option from the list, enable it, and reboot
(iv) Run the program to check the output
While performing the experiments with newer versions of the raspberry pi the step-3 has to be performed. After performing, the device needs to be restarted. When these processes have completed the main code should be executed.
Download the code from here
When the circuit is powered up, before displaying the temperature and humidity values, the following string is displayed.
Then after a delay, the first reading measured by the sensor will be displayed in the LCD display.
After sometime, again a set of values will be displayed depending on the surrounding environment.
If we place any warm object near the sensor, the value will be changed accordingly.
In case of giving any keyboard interrupt, the following string will be displayed.
Check the Project Working video here - Interfacing Temperature Sensor - DHT11 with Raspberry Pi and LCD Display
Learn Electronics. (Aug 16, 2020). "Interfacing Temperature Sensor - DHT11 with Raspberry Pi and LCD Display". https://www.youtube.com/watch?v=t6hWaDLS9DA
NOTE: By keeping this DHT11 sensor tutorial as basic, we can develop several advanced projects. Some of the applications include IoT weather stations, condition monitoring.