Authorized Online Retailer

Objective:

In this project, we will get temperature and humid data from DHT11 and send it to Raspberry Pi, then display the temperature and humid on 16×2 LCD screen.

If you don’t know what is GPIO layout, check our tutorial How to read Raspberry Pi i/o pin diagram (GPIO pin graph)

Parts:

1 pc Raspberry Pi 2/3/zero raspi
1 pc 8GB MicroSD memory card preinstalled Raspbian OS. 8gtf
1 pc DHT11 Temperature/Humid Sensor dht11
1 pc 1602 LCD screen 1602LCD
1 pc Potentiometer Potentiometer
1 pc breadboard BREADBOARD
1 pc GPIO breakout kit(optional) breakout

Prerequisite:

1)Raspbian should be upgraded to latest version in order to support RPI.GPIO module

Please run following commands in shell:

2)Enable I2C and SPI protocol

To enable the protocol, run shell command

sudo raspi-config

Then select Advance Options and enable I2C and SPI

You need to reboot to effect the configuration

Raspberry Pi and 1602 LCD pin connection

LCD Pin Description Pi Function RasPi Pin
01 GND GND 06
02 +5V +5V 02
03 Contrast To Potentiometer middle pin
04 RS GPIO7 26
05 RW GND 06
06 Enable GPIO8 24
11 D4 GPIO25 22
12 D5 GPIO24 18
13 D6 GPIO23 16
14 D7 GPIO18 12
DHT11 signal pin GPI14 08
DHT11 +vcc PIN +3V 01
DHT11 GND(-) GND 06

Circuit Graph:

dht11-pi

Caution: Unlike Arduino board 5V input voltage, Raspberry GPIO pin accept only 3 Volt. Wrong voltage input might damage the Pi board. Please be very careful!

download python code

Please typing following shell commands to download two python files(dht11.py and temperature.py):

sudo wget http://osoyoo.com/driver/dht11.py

sudo wget http://osoyoo.com/driver/temperature.py

Finally, run following command in shell window:

sudo python temperature.py

Adjust the Potentiometer to make LCD text displaying clearly. You will see Temperature and Humid info in LCD screen:

Video Demo: