DHT 11 INTERFACE

   DHT-11 sensor is a anolog sensor that has three pins . It can be connected to arduino,raspberry pi etc., In this how to collect data from DHT-11 sensor and save it in a file is explained.

CIRCUIT DIAGRAM

Interface DHT 11 with PI
Interface DHT 11 with PI
Raspberry Pi                       DHT11 Module
5v P2              —————————–        VCC (V)
GND P6             —————————-        GND (G)
GPIO4 P7           —————————–        DATA (S)

RPI-GPIO

PROCEDURE:

Open the terminal and type the following commands

Step 1: Enter sudo apt-get install git-core. If any error in installing git-core update the software using sudo apt-get update .

Step 2: Enter git clone https://github.com/adafruit/Adafruit_Python_DHT.git to clone the library.

Step 3: Open the folder using cd Adafruit_Python_DHT.

Step 4: Enter sudo aptget install buildessential pythondev

Step 5 : Enter sudo python setup.py install to install setup.py

Step 6: Enter sudo aptget install pythondev pythonrpi.gpio  to install GPIO if it is not installed

PROGRAMS :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import sys
import time
import Adafruit_DHT
localtime = time.asctime( time.localtime(time.time()) )
#To create a file to store the data
#Iam taking data for 10 minutes
for i in range(10):
    hum, temp = Adafruit_DHT.read_retry(11, 4)
    #Read value every one second
     time.sleep(60)
     print(localtime)
     print "\n"
     print("Temperature = %d "%temp)
     print "\n"
     print("Humidity = %d "%hum)
     print "\n"

Save this as run the program ,data will be printed every one minute .

THANKYOU

                         

SHARE THIS!!!

Gowtham S

Gowtham is a programming enthusiast. His field of interest includes Arduino, NodeMCU, Raspberry Pi, and Python. To know more about him visit https://mybtechprojects.tech/about-us/.

1 Comment

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.