DHT11 sensor shows 0 temperature 0 humidity...

Hi guys,

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. I will appreciate all kind of help!


#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 setup() {
Serial.begin(9600);
Serial.print("Soil moisture sensor");
pinMode(moistureAO, INPUT);
pinMode(buzzPin, OUTPUT);
pinMode(LED, OUTPUT);
}

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
}

If you have a DHT11 why are you using DHT.read22()?

Steve

slipstick:
If you have a DHT11 why are you using DHT.read22()?

Steve

Hi Steve, thank you by your reply. I did not write the code and was not aware that this line refers to the DHT22 model. Can you explain me better what means 'DHT.read22?

All I know is that read11 is intended for the DHT11 and read22 is for the DHT22 and they are different.

Steve

slipstick:
All I know is that read11 is intended for the DHT11 and read22 is for the DHT22 and they are different.

Steve

You`re right Steve. Problem solved here bro. Many thanks!