Running 2+ DHT22 sensors problems

Basically I want to run 2 DHT22 sensors but they don't want to work together.

When I have them both connected, first one is working ok and the second one is not returning any data, not even invalid.
When I disconnect first one from board, the second one works fine.

This is how I connected them, don't mind the parts because I did not have dht22 parts in this program so I used anything with 4 pins.

Connection Scheme: http://i.imgur.com/gHhTbH7.png

How can I get them to work simultaneously?

What did I do wrong?

(deleted)

You definitely need the resistor. Read a tutorial:

Oh, my bad. I do have the resistors connected between first and second pin in both sensors, It would not read anything otherwise

I really cannot figure this out, just re-made everything, checked code, sensors, resistors, everything works well when connected alone, together still not working :/. Maybe voltage drops low after first sensor uses it?

//edit: just measured it, it's ok and pretty stable 3.3

Are you sure it's not a software problem? As a quick test, why don't you change the order of reading the sensors, and see if the problem is reversed?

(deleted)

spycatcher2k:
Can you post :

a Photo of you setup (with connections clearly visible)
Your source code

It may be something you are overlooking (been there so many times myself)

first sensor is outside, signal is going trough normal twisted wire, about 2 meters maybe less, working well.
second sensor on the right will get temp inside and currently is not returning any data (sometimes is returning random values)

edit: photos in a sec

my code, pardon the mess:

#include <DHT22.h>
#include <SPI.h>
#include <Ethernet.h>

#define DHT_OUT 2
#define DHT_IN 3

byte mac[] = { 
  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192,168,1,177);
EthernetServer server(80);

DHT22 DHT_outside(DHT_OUT);
DHT22 DHT_inside(DHT_IN);


void setup(void)
{
  Serial.begin(9600);
  Ethernet.begin(mac, ip);
  server.begin();
  Serial.print("server is at ");
  Serial.println(Ethernet.localIP());
}

void loop(void)
{ 
   DHT22_ERROR_t first_err, second_err;
    EthernetClient client = server.available();
    
  if (client) {
    Serial.println("new client");

    boolean currentLineIsBlank = true;
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
        Serial.write(c);
        if (c == '\n' && currentLineIsBlank) {
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          client.println("Connection: close"); 
	  client.println("Refresh: 5"); 
          client.println();
          client.println("<!DOCTYPE HTML>");
          client.println("<html>");
          
            Serial.print("Requesting data...");
          first_err = DHT_outside.readData();
          second_err = DHT_inside.readData();
          switch(first_err)
          {
            case DHT_ERROR_NONE:
            Serial.print("Got Data ");
            Serial.print(DHT_outside.getTemperatureC());
            client.println("Na zewn.: 
Temperatura: ");
            client.print(DHT_outside.getTemperatureC());
            Serial.print("C ");
            client.println("*C 
Wilgotnosc: ");
            Serial.print(DHT_outside.getHumidity());
            client.print(DHT_outside.getHumidity());
            Serial.println("%");
            client.println("%");
            client.println("

W pokoju: 
Temperatura: ");
            client.println(DHT_inside.getTemperatureC());
            client.println("*C 
Wilgotnosc: ");
            client.println(DHT_inside.getHumidity());
            client.println("%

Na dole w pokoju: 
Temperatura: ");
            client.println("x*C 
Wilgotnosc: x%
");
          break;
  
        }
          client.println("</html>");
          break;
        }
        if (c == '\n') {
          currentLineIsBlank = true;
        } 
        else if (c != '\r') {
          currentLineIsBlank = false;
        }
      }
    }
    delay(1);
    client.stop();
    Serial.println("client disonnected");
  }
 


}

live demo straight from arduino via ethernet shield: http://tt.no-ip.org:6677/

big edit: oh my god, I just re-arranged everything so it looks tidy for the photos and it started working

sorry for the bother guys and thanks for tips :smiley: I'm little embarrassed now for starting this thread

According to my DHT22 datasheet:

(6) Attentions to connection wires
The connection wires' quality will effect communication's quality and distance, high quality shielding-wire is recommended.

Are you using high quality shielding-wire?

Looks OK to me:

Na zewn.:
Temperatura: 9.90*C
Wilgotnosc: 80.10%

W pokoju:
Temperatura: 24.50 *C
Wilgotnosc: 51.20 %

Na dole w pokoju:
Temperatura: x*C
Wilgotnosc: x%

Translated:

Outside.:
Temperature: 9.90 * C
Humidity: 80.10%

In the Room:
Temperature: 24.50 * C
Humidity: 51.20%

At the bottom of the room:
Temperature: x * C
Humidity: x%

So it's colder outside.

just look at added 'edit' in the bottom of my previous post :sweat_smile:

big edit: oh my god, I just re-arranged everything so it looks tidy for the photos and it started working

Changing previous posts makes the thread confusing to read.