Go Down

Topic: dht11 and Arduino Uno (Read 1 time) previous topic - next topic

Is not first with this problem but i can not find solution.

I take code from this link:

http://learn.adafruit.com/dht

this is error:

Read failFailed to read from DHT
Humidity: 0.00 %   Temperature: 0.00 *C
Humidity: 0.00 %   Temperature: 0.00 *C
Humidity: 0.00 %   Temperature: 0.00 *C

dannable

I think you need to post YOUR code and a photo of how you have it all connected.

Telling us where you got the code from doesn't tell us that you copied it completely and correctly!
Beginners guide to using the Seeedstudio SIM900 GPRS/GSM Shield

Okey,

this is program code

Code: [Select]
// Example testing sketch for various DHT humidity/temperature sensors
// Written by ladyada, public domain

#include "DHT.h"

#define DHTPIN 2     // what pin we're connected to

// Uncomment whatever type you're using!
#define DHTTYPE DHT11   // DHT 11
//#define DHTTYPE DHT22   // DHT 22  (AM2302)
//#define DHTTYPE DHT21   // DHT 21 (AM2301)

// Connect pin 1 (on the left) of the sensor to +5V
// Connect pin 2 of the sensor to whatever your DHTPIN is
// Connect pin 4 (on the right) of the sensor to GROUND
// Connect a 10K resistor from pin 2 (data) to pin 1 (power) of the sensor

DHT dht(DHTPIN, DHTTYPE);

void setup() {
  Serial.begin(9600);
  Serial.println("DHTxx test!");

  dht.begin();
}

void loop() {
  // Reading temperature or humidity takes about 250 milliseconds!
  // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
  float h = dht.readHumidity();
  float t = dht.readTemperature();

  // check if returns are valid, if they are NaN (not a number) then something went wrong!
  if (isnan(t) || isnan(h)) {
    Serial.println("Failed to read from DHT");
  } else {
    Serial.print("Humidity: ");
    Serial.print(h);
    Serial.print(" %\t");
    Serial.print("Temperature: ");
    Serial.print(t);
    Serial.println(" *C");
  }
}


thanks

i have some problem with picture, i hope now is okey

dannable

I don't know who's module you are using, but ground is normally the fourth pin - pin three has no connection.

The Data sheet (in Chinese!), http://www.adafruit.com/datasheets/DHT11-chinese.pdf - look at the diagram on page 2 and check against your module.
Beginners guide to using the Seeedstudio SIM900 GPRS/GSM Shield

i can not find data sheet but my modul have 3 pins only.

http://dx.com/p/arduino-digital-temperature-humidity-sensor-module-121350

that is mine!

dannable

Hmm! I can't find a lot out about that. I can guess how the pins are connected but that's not always a good idea. Do you have a multimeter to confirm how they are connected?

However, I would suspect that the resistor on the board means that you don't need to add one - the one you have between pins 1 and 2, so you can remove that.

Which version of the IDE are you using?

Do you get any errors when you compile the program? I have downloaded it and it compiles and works with a plain DHT11, but I am using 0022!
Beginners guide to using the Seeedstudio SIM900 GPRS/GSM Shield

robtillaart

there must be a delay of 2 seconds between readings

Code: [Select]
void loop()
{
  // Reading temperature or humidity takes about 250 milliseconds!
  // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)

  delay(2000);

  float h = dht.readHumidity();
  float t = dht.readTemperature();

  // check if returns are valid, if they are NaN (not a number) then something went wrong!
  if (isnan(t) || isnan(h))
  {
    Serial.println("Failed to read from DHT");
  } else {
    Serial.print(millis());
    Serial.print("\t");
    Serial.print("Humidity: ");
    Serial.print(h);
    Serial.print(" %\t");
    Serial.print("Temperature: ");
    Serial.print(t);
    Serial.println(" *C");
  }
}


furthermore the DHT11 does return integers, no floats (but that cannot cause the problem)

you can try my DHT lib, it tells something about error conditions if they occur - http://playground.arduino.cc/Main/DHTLib -
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

I find the problem, wired is wrong. I set 5V on first pin but  he is signal pin,

http://www.automatika.rs/forum/elektronika/1932-arduino-uno-i-dht11-senzor#2022

this is good pictures.

thanks everyone, now i will test more and enjoy.

dannable

Not the order I would have guessed, but looking at it now one pin is marked 'S' (signal?) and another '-' (ground?).
Beginners guide to using the Seeedstudio SIM900 GPRS/GSM Shield

Go Up