Page 1 of 1

DHT11 basic functional test

Posted: Wed Mar 30, 2022 7:40 pm
by MicroNinja
Hi,

I am just trying to get a DHT11 sensor to play with me on a wemos d1 mini esp8266. I have 2 of them and both fail to read a value, that makes me wonder if I am the issue here as I still sometimes get the pin numbers wrong
I am just hoping someone can tell me if I have connected it correctly or if i am unlucky having 2 broken DHT11 sensors? That would be super helpful for me to understand what I am doing wrong here.

I am using 3.3V, GND and D4 (pin number 2?).

Image

Code: Select all

from machine import Pin
from time import sleep
import dht 

sensor = dht.DHT11(Pin(2))

while True:
  try:
    sleep(2)
    sensor.measure()
    t = sensor.temperature()
    h = sensor.humidity()
    print('Temperature: %3.1f C' %t)
    print('Humidity: %3.1f %%' %h)
  except OSError as e:
    print('Sensor Reading Failed')

Re: DHT11 basic functional test

Posted: Thu Mar 31, 2022 2:30 pm
by tepalia02
Hi, have you tested these sensors with any other board? For example, with an Arduino UNO?

Re: DHT11 basic functional test

Posted: Thu Mar 31, 2022 2:38 pm
by Roberthh
Is there a pullup-resistor between the data line and Vcc?

Re: DHT11 basic functional test

Posted: Fri Apr 15, 2022 10:49 am
by tepalia02
Is the problem solved now? I think you'd better test your DHT11 with this tutorial. This is based on Arduino and DHT11.
https://www.theengineeringprojects.com/ ... duino.html
It explains DHT11's working principle, pinout, protocol and interfacing with other microcontrollers in detail.

Re: DHT11 basic functional test

Posted: Mon May 16, 2022 2:57 pm
by alexO'khar
the same sensor doesn't work for me either. the power supply is also 3.3 V. I measured the voltage that the sensors output to pin DATA. it was 2.6 V. it is possible that this is not enough for the signal from the sensor to be read by the controller. if the sensor is powered from 5.0 V, then the DATA pin will be 4.3 V. in the case of the esp8266, I think this is too much voltage for its I/O pin. I think that the DHT 11 sensor is not suitable for use with esp8266 at all

Re: DHT11 basic functional test

Posted: Mon May 16, 2022 4:53 pm
by Roberthh
@alexO'khar: The DHT11 sensor should work fine. 2.6 is indeed lower than expected. With a proper pull-up resistor, it should be close to 3.3V. But 2.6V is a solid HIGH level. So that's not the problem.