简体   繁体   English

Raspberry Pi DHT 11 传感器不工作。 我得到 无 无

[英]Raspberry Pi DHT 11 sensor not working. I get None None

Have integrated Raspberry pi4 with a DHT sensor.集成了带有 DHT 传感器的 Raspberry pi4。 The data pin is connected to pin GPIO 26数据引脚连接到引脚 GPIO 26

Have tried connecting the VCC to both 3.3V and 5V已尝试将 VCC 连接到 3.3V 和 5V

Have tried with both Adafruit_DHT.DHT11 and Adafruit_DHT.DHT22 in the code for the same sensor but I get None None已尝试在同一传感器的代码中同时使用 Adafruit_DHT.DHT11 和 Adafruit_DHT.DHT22,但我得到 None None

import Adafruit_DHT

# Sensor should be set to Adafruit_DHT.DHT11,
# Adafruit_DHT.DHT22, or Adafruit_DHT.AM2302.
sensor = Adafruit_DHT.DHT22
pin = 26

while True:
    humidity, temperature = Adafruit_DHT.read_retry(sensor, pin)
    print(temperature, humidity)

Output: Output:

None None无 无

Is the sensor broken??Should I replace it or is there any other solution??传感器坏了吗??我应该更换它还是有其他解决办法??

from pigpio_dht import DHT11, DHT22

gpio = 4 # BCM Numbering

sensor = DHT11(gpio)
#sensor = DHT22(gpio)

result = sensor.read()
print(result)

This worked for me.这对我有用。 Before running the code enter the below commands on the terminal在运行代码之前,在终端上输入以下命令

sudo pigpiod #Start daemon

pigs pud 4 u # Set internal pull up

If pigpio-dht is not installed enter pip3 install pigpio-dht and run the above program如果没有安装 pigpio-dht 输入pip3 install pigpio-dht并运行上述程序

After 3 days with the same issue and trying all of the above (even bought a new DHT11), the issue with just with the GPIO's.在遇到同样的问题 3 天并尝试了上述所有方法(甚至买了一个新的 DHT11)后,问题只出在 GPIO 上。 I manually had to "push" the pin GPIO-4 to make it contact with the recevier end of the DHT11 cable.我不得不手动“推动”引脚 GPIO-4 以使其与 DHT11 电缆的接收端接触。

my code was simpler version:我的代码是更简单的版本:

import Adafruit_DHT
import sys

while True:
 humidity, temperature = Adafruit_DHT.read_retry(11,4)
 print(temperature, humidity)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用DHT11传感器在Raspberry Pi上读取温度 - Reading temperature on Raspberry Pi using DHT11 sensor 当我尝试运行此脚本时,出现错误:OverflowError: unsigned short is greater than maximum。 树莓派 4B,传感器为 DHT11 - When i try to run this script, i get a error: OverflowError: unsigned short is greater than maximum. Raspberry pi 4B, the sensor is DHT11 从 DHT-11 温度/湿度传感器到 CSV 文件的传感器数据(python/树莓派 3) - Sensor data from DHT-11 temperature/ humidity sensor to CSV file (python/ raspberry pi 3) Adafruit_DHT 不适用于 python 3 Raspberry Pi 3 B - Adafruit_DHT not working for python 3 Raspberry Pi 3 B DHT11传感器在Edison上发生故障,而在RPi上成功工作 - DHT11 sensor failure on Edison whereas working successful on RPi 传感器Python DHT11 - Sensor Python DHT11 带有Raspberry Pi的PIR传感器 - PIR sensor with Raspberry Pi 如何从 Nonin Xpod PulseOxy 传感器获取数据到 Raspberry Pi - How do I get data from Nonin Xpod PulseOxy Sensor to Raspberry Pi 如何在没有 SDK 的情况下将数据传感器数据从 Microsoft band 2 获取到 Raspberry pi? (对于编程语言) - How do I get data sensor data from Microsoft band 2 to a Raspberry pi without SDK? (To a programming language) 为什么我无法在带有 BPM 传感器的 Raspberry Pi 中获得 BLE 指示响应? - Why I can't get the BLE indication response in Raspberry Pi with a BPM Sensor?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM