Introduction: Weather Monitoting System Using Raspberry Pi3 and DHT11 Sensor
In this tutorial, I’ll show you how to connect the DHT11 to the Raspberry Pi and output the humidity and temperature readings to an LCD.
The DHT11 temperature and humidity sensor is a nice little module that provides digital temperature and humidity readings. It’s really easy to set up, and only requires one wire for the data signal. These sensors are popular for use in remote weather stations, soil monitors, and home automation systems
Connecting the DHT11 to the Raspberry Pi
There are two variants of the DHT11 you’re likely to come across. One is a three pin PCB mounted module and the other is a four pin stand-alone module. The pinout is different for each one, so connect the DHT11 according to which one you have:
Also, some of the PCB mounted modules might have a different pinout than the one above, so be sure to check your sensor for any labels indicating which pin is Vcc, ground or signal.
Step 1: Components Required
1. Raspberry Pi 3 Model B+ :- The Raspberry Pi 3 Model B+ is the latest product in the Raspberry Pi 3 range,boasting a 64-bit quad core processor running at 1.4GHz, dual-band 2.4GHz and 5GHz wireless LAN, Bluetooth 4.2/BLE, faster Ethernet, and PoE capability via a separate PoE HAT.
2. DHT11 Humidity/ Temperature Sensor:- This sensor features a calibrated digital signal output with the temperature and humidity sensor capability. It is integrated with a high-performance 8-bit microcontroller. This sensor includes a resistive element and a sensor for wet NTC temperature measuring devices. It has excellent quality, fast response, anti-interference ability and high performance.
3. 16x2 LCD Display (Green BackLight) :- The 16×2 LCD display is a very basic module commonly used in DIYs and circuits. The 16×2 translates o a display 16 characters per line in 2 such lines. In this LCD each character is displayed in a 5×7 pixel matrix.
4. Female to Female Jumper Wires.
Step 2: Installing the Libraries
We’ll be using the Adafruit DHT11 Python library. You can download the library using Git, so if you don’t have Git installed on your Pi already, enter this at the command prompt:
sudo apt-get install git-core
Note: If you get an error installing Git, run sudo apt-get update and try it again.
To install the Adafruit DHT11 library:
1. Enter this at the command prompt to download the library:
git clone https://github.com/adafruit/Adafruit_Python_DHT.g...
2. Change directories with: cd Adafruit_Python_DHT
3. Now enter this: sudo apt-get install build-essential python-dev
4. Then install the library with: sudo python3 setup.py install
To install the Adafruit Char LCD library:
1. Enter this at the command prompt to download the library:
git clone https://github.com/adafruit/Adafruit_Python_CharL...
2. Change directories with: cd Adafruit_Python_CharLCD
3. Then install the library with: sudo python3 setup.py install
Step 3: Connecting Components Together
LCD PIN_RS ------------------ 40 of Raspberry Pi
LCD PIN_RW ------------------ 6 of Raspberry Pi
LCD PIN_EN -------------------38 of Raspberry Pi
LCD PIN_D0 ------------------- NC
LCD PIN_D1 ------------------- NC
LCD PIN_D2 ------------------- NC
LCD PIN_D3 ------------------- NC
LCD PIN_D4 ------------------- 36 of Raspberry Pi
LCD PIN_D5 ------------------- 32 of Raspberry Pi
LCD PIN_D6 ------------------- 24 of Raspberry Pi
LCD PIN_D7 ------------------- 26 of Raspberry Pi
LCD PIN_VSS------------------ 9 of Raspberry Pi
LCD PIN_VDD------------------ 4 of Raspberry Pi
DHT PIN_OUT------------------ 7 of Raspberry Pi
DHT PIN_VCC------------------ 2 of Raspberry Pi
DHT PIN_GND------------------ 14 of Raspberry Pi
Step 4: The Code
Download the code attached here and upload it on your board, and wire everything as shown in previous diagram.
Download code : https://github.com/soorajece1993/weather_monitoring_Raspberry_pi.git
That should about cover most of what you’ll need to get the DHT11 up and running on your Raspberry Pi. Hope this made it easier for you. Be sure to subscribe if you liked this article and found it useful, and if you have any questions or need help with anything, just leave a comment below…