 #include <DHT.h>
 #include <DHT_U.h>
 
-#define DHTPIN            2         // Pin which is connected to the DHT sensor.
+#define DHTPIN1            2         // Pin which is connected to the DHT sensor.
+#define DHTPIN2            3         // Pin which is connected to the DHT sensor.
 
+#define N_SENSORS   2   //!< The number of sensors used
 // Uncomment the type of sensor in use:
 //#define DHTTYPE           DHT11     // DHT 11 
 #define DHTTYPE           DHT22     // DHT 22 (AM2302)
 //#define DHTTYPE           DHT21     // DHT 21 (AM2301)
 
+
 // See guide for details on sensor wiring and usage:
 //   https://learn.adafruit.com/dht/overview
 
-DHT_Unified dht(DHTPIN, DHTTYPE);
+DHT_Unified *dht_array[N_SENSORS];
 
 uint32_t delayMS;
 
 void setup() {
   Serial.begin(9600); 
   // Initialize device.
-  dht.begin();
   Serial.println("DHTxx Unified Sensor Example");
+
+  dht_array[0] = new DHT_Unified(DHTPIN1,DHTTYPE);
+  dht_array[1] = new DHT_Unified(DHTPIN2,DHTTYPE);
+  dht_array[0]->begin();
+  dht_array[1]->begin();
   // Print temperature sensor details.
   sensor_t sensor;
-  dht.temperature().getSensor(&sensor);
+  dht_array[0]->temperature().getSensor(&sensor);
   Serial.println("------------------------------------");
   Serial.println("Temperature");
   Serial.print  ("Sensor:       "); Serial.println(sensor.name);

  Serial.print  ("Resolution:   "); Serial.print(sensor.resolution); Serial.println(" *C");  
  Serial.println("------------------------------------");
  // Print humidity sensor details.
  dht.humidity().getSensor(&sensor);
  Serial.println("------------------------------------");
  Serial.println("Humidity");
  Serial.print  ("Sensor:       "); Serial.println(sensor.name);

}

void loop() {
  uint8_t i;
  // Delay between measurements.
  delay(delayMS);
  // Get temperature event and print its value.
  sensors_event_t event; 

  // Read all sensors
  for(i=0;i<N_SENSORS;i++)
  {
    Serial.print("Sensor ");
    Serial.println(i);
    dht_array[i]->temperature().getEvent(&event);
    if (isnan(event.temperature)) {
      Serial.println("Error reading temperature!");
    }
    else {
      Serial.print("Temperature: ");
      Serial.print(event.temperature);
      Serial.println(" *C");
    }
    // Get humidity event and print its value.
    dht_array[i]->humidity().getEvent(&event);
    if (isnan(event.relative_humidity)) {
      Serial.println("Error reading humidity!");
    }
    else {
      Serial.print("Humidity: ");
      Serial.print(event.relative_humidity);
      Serial.println("%");
    }
  }
}
