[SOLVED] Multiple DHT instances returns just NaN

Hi all!
I'm trying to use 2 DHT 22 sensors (inside and outside) to compare datas and make fans work via PWM.
Unfortunately I found a problem and cannot get rid of it: sensors work fine if connected singularly but, when I set 2 instances, I have just NaN readings.
I even tried coping-pasting the code from a tutorial HERE

#include "DHT.h"
 
#define DHT1PIN 2     // what pin we're connected to
#define DHT2PIN 3
 
// Uncomment whatever type you're using!
#define DHT1TYPE DHT22   // DHT 22 
#define DHT2TYPE 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 dht1(DHT1PIN, DHT1TYPE);
DHT dht2(DHT2PIN, DHT2TYPE);
 
void setup() {
  Serial.begin(9600); 
  Serial.println("DHTxx test!");
 
  dht1.begin();
  dht2.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 h1 = dht1.readHumidity();
  float t1 = dht1.readTemperature();
  float h2 = dht2.readHumidity();
  float t2 = dht2.readTemperature();
 
  // check if returns are valid, if they are NaN (not a number) then something went wrong!
  if (isnan(t1) || isnan(h1)) {
    Serial.println("Failed to read from DHT #1");
  } else {
    Serial.print("Humidity 1: "); 
    Serial.print(h1);
    Serial.print(" %\t");
    Serial.print("Temperature 1: "); 
    Serial.print(t1);
    Serial.println(" *C");
  }
  if (isnan(t2) || isnan(h2)) {
    Serial.println("Failed to read from DHT #2");
  } else {
    Serial.print("Humidity 2: "); 
    Serial.print(h2);
    Serial.print(" %\t");
    Serial.print("Temperature 2: "); 
    Serial.print(t2);
    Serial.println(" *C");
  }
  Serial.println();
}

Using this, serial monitor return the error message for both sensors.

It looks like the problem is using "dht1.begin()" or any other way I want to name the sensor instance, in fact using "dht.begin()" (using dht instead of dht1 in all operations, declarations, etc) sensors will work.
This way I cannot read 2 sensors in parallel
I tried to use Arduino UNO Rev.3, Nano and UNO WIFI Rev.2 on Mac and IDE 1.8.5

Did you have a look at the Adafruit tutorial?

Also, I just looked at the Adafruit library examples. They have a delay at the beginning of each loop. Which sounds necessary from their statement in the tutorial.

Both use a single digital pin and are 'sluggish' in that you can't query them more than once every second or two.

Klaus_K:
Did you have a look at the Adafruit tutorial?

Using a DHTxx Sensor with Arduino | DHT11, DHT22 and AM2302 Sensors | Adafruit Learning System

Overview | DHT11, DHT22 and AM2302 Sensors | Adafruit Learning System

Yes, I did. The code posted here is quite the same. It is present as an example in library and just modified to have 2 sensors by the tutorial maker. I also tried to use directly the library example code. It works until I add anything after dht in declaration and others.

Klaus_K:
Also, I just looked at the Adafruit library examples. They have a delay at the beginning of each loop. Which sounds necessary from their statement in the tutorial.

My intention is to read sensor once in 10 seconds, so I first tried with a millis instance to let other sensors work normally. It was not working so I thought to an issue in millis coding and changed in a delay(10000). Not working again.

Solved! there were too many sensors under the same power line and not enough mA for all of them