Forum >DHT 11 sensor not found, check wiring
ArduinoGeneral

DHT 11 sensor not found, check wiring

userHead Account cancelled 2020-11-03 15:06:19 3323 Views1 Replies
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:
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
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()
the error is :
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