Pages: [1]   Go Down
Author Topic: Wiring up the DHT11  (Read 2789 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

Hello please help out an idiot, im very new to this and am trying to get the DHT11 temp/humidity sensor working, the sketch compiles and uploads fine but the serial data shows humidity -999% and temp -999 degrees, clearly this is because im wiring it onto my breadboard wrong.

Pin 1 goes to 5v.
pin 2 has a 10k resistor then to pin2 on the arduino.
pin 3 has nothing
pin 4 is to GND.

This is the tutorial im using, do I need another wire that goes on pin 2 to pin 1 after the resistor? It's confusing.

http://learn.adafruit.com/dht/connecting-to-a-dhtxx-sensor


* photo.JPG (290.76 KB, 960x720 - viewed 150 times.)
Logged

Sydney, Australia
Offline Offline
Edison Member
*
Karma: 33
Posts: 1260
Big things come in large packages
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

You should find the 10 k resistor is either connected to 5v or gnd. In that case this is the signal pin and the pin with no connection can be ignored.
Logged

Arduino libraries http://arduinocode.codeplex.com
Parola hardware & library http://parola.codeplex.com

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

Thanks the resistor is now sitting between 5v and pin 1. But it still says failed to read so maybe there is something else wrong.

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


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");
  }
}
Logged

Sydney, Australia
Offline Offline
Edison Member
*
Karma: 33
Posts: 1260
Big things come in large packages
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Have you connected it this way, because you say that
Quote
Thanks the resistor is now sitting between 5v and pin 1

If it is all connected correctly and you are sure the library works ok, then maybe you need to check that the voltage is correct (5V) on the sensor with a multimeter. Next step is to try a different sensor smiley
« Last Edit: July 19, 2012, 11:38:47 pm by marco_c » Logged

Arduino libraries http://arduinocode.codeplex.com
Parola hardware & library http://parola.codeplex.com

Anaheim CA.
Offline Offline
Faraday Member
**
Karma: 46
Posts: 2865
...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I used onre of the DHT libraries from the playground ant it worked real fine for me... was a DHT11 and I had to "Fudge' the measurement a little for calibration, matter of fact I have 3 of the sensors and all were within a half percent or so of each other and about 5% low over all, Bought a DHT22 (AM2302) because I didn't like the stated accuracy and humidity range. BUT the sketch and library I downloaded from the playground worked from the gate...

Doc
Logged

--> WA7EMS <--
“The solution of every problem is another problem.” -Johann Wolfgang von Goethe
I do answer technical questions PM'd to me with whatever is in my clipboard

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

THanks I couldnt get it working, i guess ive got a duff arduino because I havent managed to get anything working on it. All lights come on fine but no readings from this or an ultrasonic sensor.
Logged

Sydney, Australia
Offline Offline
Edison Member
*
Karma: 33
Posts: 1260
Big things come in large packages
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Have you tried turning on a LED with the input/output pin just to test it works ok?
Logged

Arduino libraries http://arduinocode.codeplex.com
Parola hardware & library http://parola.codeplex.com

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

same problem, i have resistor 10k, and i change sensor, this is my third, smiley-sad all pin out is okey.

please help!!!
Logged

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


 -999 is an error code of the lib, - try run the example here - http://playground.arduino.cc/Main/DHTLib - it can give more info about the error
Logged

Rob Tillaart

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

Pages: [1]   Go Up
Jump to: