Go Down

Topic: Wiring up the DHT11 (Read 3361 times) previous topic - next topic

MancunianLee

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

marco_c

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.
Arduino libraries http://arduinocode.codeplex.com
Parola for Arduino http://parola.codeplex.com

MancunianLee

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

marco_c

#3
Jul 20, 2012, 01:19 am Last Edit: Jul 20, 2012, 06:38 am by marco_c Reason: 1
Code: [Select]
// 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 :)
Arduino libraries http://arduinocode.codeplex.com
Parola for Arduino http://parola.codeplex.com

Docedison

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

MancunianLee

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.

marco_c

Have you tried turning on a LED with the input/output pin just to test it works ok?
Arduino libraries http://arduinocode.codeplex.com
Parola for Arduino http://parola.codeplex.com

marko05nikolic

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

please help!!!

robtillaart


-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
Rob Tillaart

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

Go Up