Receiving "NaN" from Temperature & Humidity Sensor

Hello,

I'm currently using the temperature and humidity sensor that came with the Arduino sensor kit, but I've been running into a few issues with it. Each time I run the program, it only returns "nan" for both temperature and humidity values. I was wondering if there's something I'm forgetting to add, or if there's just a general issue that I'm not seeing. Any feedback will help.

Below is the code that I'm using. Thanks in advance for your help!

Screenshot 2022-03-11 144705

Care to be more specific. Most of us have no idea what that kit is or contains.

@oddnanolo Installation and Troubleshooting is for Problems with the Arduino itself NOT your project. It says so in the description of the section. Therefore I have moved your post here. Please be more careful where you post in future.

You may want to read this before you proceed:-
how to get the best out of this forum

It helps to know where this message is being generated from, the compiler or when it runs.

It's a DHT11 temperature and humidity sensor, and it's part of the sensor kit sold by Arduino. Here's a link entailing what it is.

https://sensorkit.arduino.cc/

Hello oddnanolo
Take a view and get some ideas.
https://create.arduino.cc/projecthub/arcaegecengiz/using-dht11-b0f365
Have a nice day and enjoy coding in C++.

Hello,
Thanks for the tutorial. I followed the directions as followed, however I keep getting "0.00" values for both the temperature and humidity. Do you know what might cause this?

It might be a defect and/or fake sensor?

@oddnanolo
Are you using the following Temp + Humidity Sensor?

Edit:
dht11Pic

I initially thought this too, but I tried a different kit and I got the same error messages.

Which sensor are you referring to?

Hello oddnanolo
Did you ckeck the correct connection and value of the resistor?


I did not do it through this, as the DHT11 sensor in the kit was pre-wired. I attached an image which I hope better illustrates what I mean.

About the following DHT11 Temp + Hum Sensor:

dht11Pic

That's the type of sensor that I'm using. In this case, the sensor is directly wired to the sensor kit base.

I think it unlikely to be a hardware problem. I found this code on the @paulpaulson "using DHT11" link.
Do you perhaps need to declare to which pin the DHT is attached?

#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);

}

You have a four wire sensor that wants to plug into an I2C port and not the D7/D8 port you have it plugged into. The open leads are reading 00 or NAN (Not A Number) - noise.

Hello,
I had declared the pin to the one that the DHT sensor was attached to, but still no luck, unfortunately.

What do you suggest? Should I try plugging the sensor into an I2C port instead?

Yep. Move it one connector to the right. I can see the SDA and SCL markings on your DHT.

Thanks for the feedback. I was going to run the same code as the one @johnerrington had posted in this thread, however I don't know what pin to assign for "DHT11PIN" in the 2nd line. Do you have any suggestions on that?