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

Raspberry Pi DHT11 Module 5v P2 —————————– VCC (V) GND P6 —————————- GND (G) GPIO4 P7 —————————– DATA (S)
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 apt–get install build–essential python–dev
Step 5 : Enter sudo python setup.py install to install setup.py
Step 6: Enter sudo apt–get install python–dev python–rpi.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
1 Comment
Descargar
(March 16, 2018 - 3:06 pm)Hi, yahoo lead me here, keep up great work.