Mine DHT11 was working ok and suddenly it started to throw -2 error code and outputs only zeros.
Wiring is ok, code is ok i stripped everything and left only sensor on protoboard and it still looks dead.
So, how durable DHT11 sensors are? Could i somehow carelessly fry it?
The timeout error is caused whenever ur DHT11 is not respoding . Check u have wire it properly and also check for the DATA pin u've connected is on correct pin or not and try running the example code of the library .
Nothing special there...I tought some of my other code might interfere with DHT, so at the end, i used example code (found here on Arduino playground: Arduino Playground - HomePage).
robtillaart:
Did you connect the DHT to an analog pin?
Yes. I also tested it on all analog pins.
The timeout error is caused whenever ur DHT11 is not respoding . Check u have wire it properly and also check for the DATA pin u've connected is on correct pin or not and try running the example code of the library .
Some of the datasheet says it requires 5k or 4k7 resistor as a pull up ... and also it mentions 5.5v as max voltage for the dht11 may be u've fried it up earlier.
Please, could someone help me with this? I am receiving a zero (0) reading for temperature and humidity from my DHT11 sensor. I am using a Leonardo board, powered on the usb 5v source. There is also a soil moisture sensor with controller pinned in the same board. I am using the DHTlib library provided by Rob Tillaart (thanks!) and the code is the following above. My objective is just show in the serial monitor the output from both sensors.
//-----------------
#include <dht.h>
#define dataPin 8
dht DHT; // creates a DHT object
const int moistureAO = 0;
int AO = 0;
int tmp = 0;
int buzzPin = 11;
int LED = 13;
void loop () {
tmp = analogRead( moistureAO );
if ( tmp != AO ) {
AO = tmp;
Serial.print("A = ");
Serial.println(AO);
}
delay (1000);
if (analogRead(0) > 900) {
digitalWrite(buzzPin, HIGH);
digitalWrite(LED, HIGH);
delay(1000);
digitalWrite(buzzPin, LOW);
digitalWrite(LED,HIGH);
}
else {
digitalWrite(buzzPin, LOW);
digitalWrite(LED, LOW);
}
int readData = DHT.read22(dataPin); // Reads the data from the sensor
float t = DHT.temperature; // Gets the values of the temperature
float h = DHT.humidity; // Gets the values of the humidity
// Printing the results on the serial monitor
Serial.print("Temperature = ");
Serial.print(t);
Serial.print(" *C ");
Serial.print(" Humidity = ");
Serial.print(h);
Serial.println(" % ");
delay(2000); // Delays 2 secods, as the DHT22 sampling rate is 0.5Hz
}