DHT11 basic functional test

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
Post Reply
MicroNinja
Posts: 16
Joined: Sun Dec 29, 2019 8:38 am

DHT11 basic functional test

Post by MicroNinja » Wed Mar 30, 2022 7:40 pm

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')

tepalia02
Posts: 99
Joined: Mon Mar 21, 2022 5:13 am

Re: DHT11 basic functional test

Post by tepalia02 » Thu Mar 31, 2022 2:30 pm

Hi, have you tested these sensors with any other board? For example, with an Arduino UNO?

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: DHT11 basic functional test

Post by Roberthh » Thu Mar 31, 2022 2:38 pm

Is there a pullup-resistor between the data line and Vcc?

tepalia02
Posts: 99
Joined: Mon Mar 21, 2022 5:13 am

Re: DHT11 basic functional test

Post by tepalia02 » Fri Apr 15, 2022 10:49 am

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.

alexO'khar
Posts: 1
Joined: Mon May 16, 2022 2:54 pm

Re: DHT11 basic functional test

Post by alexO'khar » Mon May 16, 2022 2:57 pm

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

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: DHT11 basic functional test

Post by Roberthh » Mon May 16, 2022 4:53 pm

@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.

Post Reply