MEGA 2560 + DHT11 library

Hello,
I have an issue with the mega 2560 and a temperature/humidity sensor. All seems to be ok, but the dht11 library sends a “time out message” and no result.
I installed the file provided with the sunfounder home kit.
Any idea of what is going wrong with that?

Thank you for answer.

Can you confirm what output / communication is used for the sensor? Try a very general example using that communication protocol (one which won’t change the values - just provide them raw).

Unfortunately I am a very beginner with arduino.
I just used the code provided with the kit, just tried to vary the speed (9600 baud),
the code is very simple and just send the datas.

here is the code*********

[code]#include <dht11.h>

DHT11 DHT11;

#define DHT11PIN 10 // DHT11 attach to digital pin 10 on controller board

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

void loop()
{
// READ DATA
Serial.print(“DHT11,\t”);
//read the value returned from sensor
int chk = DHT11.read(DHT11PIN);
switch (chk)
{
case DHTLIB_OK:
Serial.print(“OK \t”);
break;
case DHTLIB_ERROR_CHECKSUM:
Serial.print(“Checksum error,\t”);
break;
case DHTLIB_ERROR_TIMEOUT:
Serial.print(“Time out error,\t”);
break;
default:
Serial.print(“Unknown error,\t”);
break;
}
Serial.println();
// DISPLAY DATA
Serial.print(“Tem: “);
Serial.print(DHT11.temperature); //print the temperature on serial monitor
Serial.println(” C”);
Serial.print(“Hum: “);
Serial.print(DHT11.humidity); //print the humidity on serial monitor
Serial.println(” %”);
Serial.println();
delay(500); //wait a while[/code]

Ah, it includes a library which essentially handles everything. Since the library seems to be provided by them, can you give them a shout and see if they can quickly diagnose / troubleshoot the issue? [email protected]
If they are not able to resolve the issue, or determine that the part is defective, we’ll see if we can exchange the module, or communicate with them on your behalf.

Hi,
thanks for your help.
I’m new in arduino’s world, but I know a little of “cpp”.
The problem was very simple in fact. In the manual it is written to plug the sensor on digital pin 36. If you examine the code, you can see that the third line is defining the digital pin 10 as functionnal.
So I replaced 10 by 36 in the script and all was right.

Sorry to have bothered you with such a trivial problem.

We’ve all gone through this (and still continue to go through it when things don’t work).
Welcome to programming :slight_smile:

Happy to hear it’s working.