Pages: [1]   Go Down
Author Topic: dht11 and Arduino Uno  (Read 1014 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Leeds, England
Offline Offline
God Member
*****
Karma: 16
Posts: 755
Quick, chuck it in the bin before the boss finds out...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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!
Logged

Beginners guide to using the Seeedstudio SIM900 GPRS/GSM Shield

Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Okey,

this is program code

Code:
// 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
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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


* IMG_20130417_173927.jpg (152.23 KB, 800x600 - viewed 35 times.)
Logged

Leeds, England
Offline Offline
God Member
*****
Karma: 16
Posts: 755
Quick, chuck it in the bin before the boss finds out...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Beginners guide to using the Seeedstudio SIM900 GPRS/GSM Shield

Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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!
Logged

Leeds, England
Offline Offline
God Member
*****
Karma: 16
Posts: 755
Quick, chuck it in the bin before the boss finds out...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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!
Logged

Beginners guide to using the Seeedstudio SIM900 GPRS/GSM Shield

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 227
Posts: 14013
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

there must be a delay of 2 seconds between readings

Code:
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 -
Logged

Rob Tillaart

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

Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Leeds, England
Offline Offline
God Member
*****
Karma: 16
Posts: 755
Quick, chuck it in the bin before the boss finds out...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Not the order I would have guessed, but looking at it now one pin is marked 'S' (signal?) and another '-' (ground?).
Logged

Beginners guide to using the Seeedstudio SIM900 GPRS/GSM Shield

Pages: [1]   Go Up
Jump to: