也许更多信息将有助于解决您的问题。我有和你一样的传感器。
我遵循了本教程:https ://learn.adafruit.com/dht-humidity-sensing-on-raspberry-pi-with-gdocs-logging/software-install-updated
git clone https://github.com/adafruit/Adafruit_Python_DHT.git
cd Adafruit_Python_DHT
sudo apt-get update
sudo apt-get install build-essential python-dev
sudo python setup.py install
这是我的测试 python 脚本:
#!/usr/bin/python
import sys
import Adafruit_DHT
humidity, temperature = Adafruit_DHT.read_retry(11, 4)
if humidity is not None and temperature is not None:
print 'Temp={0:0.1f}*C Humidity={1:0.1f}%'.format(temperature, humidity)
else:
print 'Failed to get reading. Try again!'
将其保存为例如 dht_test.py , Chmod : sudo chmod a+x dht_test.py 并运行为 sudo : sudo ./dht_test.py 也许这对你有帮助。