0
votes

Have integrated Raspberry pi4 with a DHT sensor. The data pin is connected to pin GPIO 26

Have tried connecting the VCC to both 3.3V and 5V

Have tried with both Adafruit_DHT.DHT11 and Adafruit_DHT.DHT22 in the code for the same sensor but I get 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:

None None

Is the sensor broken??Should I replace it or is there any other solution??

1
Try changing pin = 26 to pin = 37 (gpio 26).programandoconro
@programandoconro I tried still no diffrence I get none none. Could you please provide any other solution?Dev
Only use 3.3V - all Pi GPIO uses 3.3Vbalmy
@barny I did still no diffrenceDev

1 Answers

1
votes
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