Receiving 0 with DHT11

I'm trying to use an Arduino Mega to get temperature and humidity readings from a 3-pin DHT11. I don't have any other components attached. Connections are as follows: leftmost to 5V, middle to GND, rightmost to Pin 4.
I've also tried using a different DHT11 and am still getting the same problem.
I'm using the code and library from here

Code is as follows:

#include <dht11.h>
#define DHT11PIN 4

dht11 DHT11;

void  setup()
{
  Serial.begin(9600);
 
}

void loop()
{
  Serial.println();

  int chk = DHT11.read(DHT11PIN);

  Serial.print("Humidity (%): ");
  Serial.println((float)DHT11.humidity, 2);

  Serial.print("Temperature  (C): ");
  Serial.println((float)DHT11.temperature, 2);

  delay(2000);

}

Could anyone please help?

No mention of the resistor, how is it connected and what value?

A bare DHT11 would require a 5.1K pullup resistor on the signal line. Are you using a module with the pullup already installed?

If you're using a module, are you sure about those connections? They don't match the one I pulled off the shelf here.

1 Like

The schematic I was using for the 3-pin DHT11 didn't have a resistor for some reason.
I've just attached a 5.6k Ohm resistor (didn't have any 5.1k) on the data line (middle pin), but still having the same problem of values of 0.

Interesting. The bare DHT11s I've seen have 4 pins. The modules have 3 pins and (generally) include the pullup.

And confusing: initially you said you had the middle pin tied to ground, and now you've just said the middle pin is the data pin? I think this is too confusing for me. Good luck with your project.

Hi! Welcome to the Forum and congrats for using code tags on your very first post.

As you saw, your description was not enough for people to identify what exactly is the sensor that you have and how you wired it.

This is the bare sensor (4 pins, one of them is not connected to anything):

This is the module (one of many different, 3 pins):

So, which is the one you have?

This resistor is a pullup, it has to be connected between the data line and the +5V. Is this the way you connected it? Some pictures of your hardware and connections would help.

1 Like

I never got to post that about the variants and that OP got the formatting right! :+1:
Always encourage good behavior.

Besides two variants, 3 and 4 pins, there are various pinouts of the 3 pin as well! Sigh Op should check the marking.

1 Like

Thank you for your helpful response, I am fairly new to Arduino and am a bit confused.
I have the 3-pin version, one of the modules, but the pins aren't labelled on the module itself, so I am relying on online schematics, of which there seem to be multiple different versions, with pins labelled differently? Sometimes the Vcc is one of the outside pins, and sometimes the central one?
Case in point:

(the one on the left)
And the form that appears to be more common:

I don't know which version I have as it has insufficient labelling...

Take a photo of yours and upload?

That's a pitty, but I can understand your confusion. The second picture on your post #8 comes from a reputable site, but yet seems to be wrong, since the legend doesn't agree with the silk on the module :confused_face:

One of the options is trying to look for information where you bought the module.

Another, I agree with @ledsyn, you can take a picture of the 2 sides of your module in order to try to identify the rails if we can, but considering that you probably tested different wiring positions, your module can be already dead at this point.

This modules aren't expensive, maybe buying another would be a better option.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.