markruys / arduino-DHT

Efficient DHT library for Arduino
Other
162 stars 119 forks source link

Can I use with 2 DHT22s? #8

Open BruceCrowthorne opened 7 years ago

BruceCrowthorne commented 7 years ago

I have been using two DHT11s and the library that is specific to the DHT11 allows for specifying each sensor with a specific pin.

Can I do this with this new library using two DHT22s? Thanks Bruce

factoidforrest commented 4 years ago

Couldnt you instantiate two DHTs by doing

DHT dht;
DHT dht2;
htmltiger commented 4 years ago

Adding the following also works

DHT dht[2];
setup(){
    Serial.begin(9600);
    dht[0].setup(5); //pin 5
    dht[1].setup(23); //pin 23
}
loop(){
    int i=0;
    while(i<2){
        serial.println( dht[i].getTemperature() );
        serial.println( dht[i].getHumidity() );
        i++;
    }
    delay(3000);
}