2 dht22

Thanks for the answer, I have two dht22 and if I change the pins the result does not change I only see the pin 2, But the really strange thing is that suddenly it stopped working, so I thought you had taken away the possibility of having two sensors on the same board.

/*
This example shows how to connect to Cayenne using an Ethernet W5100 shield and send/receive sample data.

The CayenneMQTT Library is required to run this sketch. If you have not already done so you can install it from the Arduino IDE Library Manager.

Steps:
1. Set the Cayenne authentication info to match the authentication info from the Dashboard.
2. Compile and upload the sketch.
3. A temporary widget will be automatically generated in the Cayenne Dashboard. To make the widget permanent click the plus sign on the widget.
*/

#define CAYENNE_DEBUG       // Uncomment to show debug messages
//#define CAYENNE_PRINT Serial  // Comment this out to disable prints and save space
#include <CayenneMQTTEthernet.h>

//DTH
#include "DHT.h"
//#define DHTPIN 2//
//#define DHTTYPE DHT22
DHT dht(2, DHT22);
DHT dht7(7,DHT22);
#define DTH_hum_Virtual_Channel 1
#define DTH_tempC_Virtual_Channel 2
#define DTH_tempF_Virtual_Channel 3
#define DTH_hic_Virtual_Channel 4
#define DTH_hif_Virtual_Channel 5
#define DTH7_hum_Virtual_Channel 6
#define DTH7_tempC_Virtual_Channel 7
#define DTH7_tempF_Virtual_Channel 8
#define DTH7_hic_Virtual_Channel 9
#define DTH7_hif_Virtual_Channel 10
unsigned long lastMillis_dht = 0;

// Cayenne authentication info. This should be obtained from the Cayenne Dashboard.
char username[] = "";
char password[] = "";
char clientID[] = "";


void setup() {
    //DTH
  dht.begin();
  Serial.begin(9600);
  Cayenne.begin(username, password, clientID);
}

void loop() {
  Cayenne.loop();
  //DTH
  if (millis() - lastMillis_dht > 10000) {
    lastMillis_dht = millis();
    // 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();
    // Read temperature as Celsius (the default)
    float t = dht.readTemperature();
    // Read temperature as Fahrenheit (isFahrenheit = true)
    float f = dht.readTemperature(true);

    // Check if any reads failed and exit early (to try again).
    if (isnan(h) || isnan(t) || isnan(f)) {
      Serial.println("Failed to read from DHT sensor!");
      return;
    }

    // Compute heat index in Fahrenheit (the default)
    float hif = dht.computeHeatIndex(f, h);
    // Compute heat index in Celsius (isFahreheit = false)
    float hic = dht.computeHeatIndex(t, h, false);
    Serial.print("Humidity: ");
    Serial.print(h);
    Serial.print(" %\t");
    Serial.print("Temperature: ");
    Serial.print(t);
    Serial.print(" *C ");
    Serial.print(f);
    Serial.print(" *F\t");
    Serial.print("Heat index: ");
    Serial.print(hic);
    Serial.print(" *C ");
    Serial.print(hif);
    Serial.println(" *F");
    Cayenne.virtualWrite(DTH_hum_Virtual_Channel, h, "rel_hum", "p");
    Cayenne.virtualWrite(DTH_tempC_Virtual_Channel, t, "temp", "c");
    Cayenne.virtualWrite(DTH_tempF_Virtual_Channel, f, "temp", "f");
    Cayenne.virtualWrite(DTH_hif_Virtual_Channel, hif, "temp", "f");
    Cayenne.virtualWrite(DTH_hic_Virtual_Channel, hic, "temp", "c");

    //dht7

    // Reading temperature or humidity takes about 250 milliseconds!
    // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
    float h7 = dht7.readHumidity();
    // Read temperature as Celsius (the default)
    float t7 = dht7.readTemperature();
    // Read temperature as Fahrenheit (isFahrenheit = true)
    float f7 = dht7.readTemperature(true);

    // Check if any reads failed and exit early (to try again).
    if (isnan(h7) || isnan(t7) || isnan(f7)) {
      Serial.println("Failed to read from DHT sensor!");
      return;
    }

    // Compute heat index in Fahrenheit (the default)
    float hif7 = dht7.computeHeatIndex(f, h);
    // Compute heat index in Celsius (isFahreheit = false)
    float hic7 = dht7.computeHeatIndex(t, h, false);
    Serial.print("Humidity: ");
    Serial.print(h7);
    Serial.print(" %\t");
    Serial.print("Temperature: ");
    Serial.print(t7);
    Serial.print(" *C ");
    //Serial.print(f7);
    Serial.print(" *F\t");
    Serial.print("Heat index: ");
    Serial.print(hic7);
    Serial.print(" *C ");
    Serial.print(hif7);
    Serial.println(" *F");
    Cayenne.virtualWrite(DTH7_hum_Virtual_Channel, h, "rel_hum", "p");
    Cayenne.virtualWrite(DTH7_tempC_Virtual_Channel, t, "temp", "c");
    Cayenne.virtualWrite(DTH7_tempF_Virtual_Channel, f, "temp", "f");
    Cayenne.virtualWrite(DTH7_hif_Virtual_Channel, hif, "temp", "f");
    Cayenne.virtualWrite(DTH7_hic_Virtual_Channel, hic, "temp", "c");

  }
}