Loading... <div class="tip inlineBlock info"> 2019-10-24更新 </div> 新版本的raspbian内核包括一些传感器,在`/boot/overlays/README`里有相关说明,以DHT11为例: 在`/boot/config`最后一行添加 ``` dtoverlay=dht11,gpiopin=4 ``` 重启. `gpiopin`为读取数据的引脚,可自行更改,引脚号码为BCM编码. 读取数据直接读取`/dev/dht11`即可 ---------- <div class="tip inlineBlock warning"> 2018-7-15 </div> 驱动:https://github.com/adafruit/Adafruit-Raspberry-Pi-Python-Code 具体: ```shell git clone https://github.com/adafruit/Adafruit_Python_DHT.git cd Adafruit_Python_DHT sudo python3 setup.py install ``` 使用: ```python import Adafruit_DHT sensor = Adafruit_DHT.DHT11 #DHT22型号的传感器就填Adafruit_DHT.DHT22 humidity, temperature = Adafruit_DHT.read_retry(sensor, 26) #26 是 GPIO 的引脚编号 print (humidity) print (temperature) ``` Last modification:October 24, 2019 © Allow specification reprint Support Appreciate the author AliPayWeChat Like 0 如果觉得我的文章对你有用,请随意赞赏