DHT 11 sensor not found, check wiring
![userHead](https://dfimg.dfrobot.com/dfPortrait2.png)
I am using raspberry pi 4 model b and sensor DHT 11 for checking the humidity and temperature. When I am using the codehttp://abyz.me.uk/rpi/pigpio/code/DHT.py, the result is:
ut when I run my own code by using the command of
Code: Select all
1604263139.922 4 3 0.0 0.0
1604263142.192 4 3 0.0 0.0
1604263144.463 4 3 0.0 0.0
1604263146.732 4 3 0.0 0.0
1604263149.002 4 3 0.0 0.0
1604263151.273 4 3 0.0 0.0
1604263153.544 4 3 0.0 0.0
1604263155.816 4 3 0.0 0.0
ut when I run my own code by using the command of
Code: Select all
:
python3 q1.py -f 5 -p 20 -o test.csv
Code: Select all
the error is :from board import D4
import adafruit_dht
import argparse
import datetime
parser = argparse.ArgumentParser()
parser.add_argument('-f',type=float)
parser.add_argument('-p',type=float)
parser.add_argument('-o',type=str)
args = parser.parse_args()
num_samples = int(args.p / args.f )
dht_device = adafruit_dht.DHT11(D4)
fp = open(args.o, 'w')
for i in range(num_samples):
now = datetime.datetime.now()
temperature = dht_device.temperature
humidity = dht_device.humidity
ptint(now.day,temperature,humidity,file = fp)
time.sleep(args.f)
fp.close()
Code: Select all
Traceback (most recent call last):
File "q1.py", line 23, in <module>
temperature = dht_device.temperature
File "/home/pi/WORK_DIR/py37/lib/python3.7/site-packages/adafruit_dht.py", line 253, in temperature
self.measure()
File "/home/pi/WORK_DIR/py37/lib/python3.7/site-packages/adafruit_dht.py", line 205, in measure
raise RuntimeError("DHT sensor not found, check wiring")
RuntimeError: DHT sensor not found, check wiring