How am i put two dht22 in only a arduino?

Hi, i'm new in programming and i don't know how make the code for read two dht11 in a only arduino

This is my code____________________

#include <DHT.h>
#define DHTPIN 2
#define DHTTYPE DHT11
int SENSOR = 2;
int SENSOR1= 3;
int temp, humedad;
int temp1, humedad1;
DHT dht (SENSOR,DHT11);
DHT dht (SENSOR1,DHT11);
void setup() {
Serial.begin(9600); // put your setup code here, to run once:
dht.begin();
}

void loop() {

float h=dht.readHumidity(); // in this part i don't know how read the second dht11
float temp = dht.readTemperature();
Serial.println("Temperatura: ");
Serial.println(temp);
Serial.println("°C Humedad: ");
Serial.print(h);
Serial.println("%");

delay(1000);
}

Hi and welcome,

as this is your first posting, pls read carefully the instructions how to use this forum, so that you make it easier for the supporters and readers of your post. You can use the link in my signature to get to the instructions.

So for the future, pls use code tags (</>), when you post your sketch -> see the button leftmost in the quick reply mode.

And: there is a powerful search function within this forum as e.g. your question is not the first of that kind, using multiple DHTxy.

To get you a step further, have a look at this thread:
http://forum.arduino.cc/index.php?topic=146524.0

Welcome :slight_smile:

When you do:

DHT dht (SENSOR,DHT11);

, you create an object named "dht" of a class named DHT.

Like any other variables, you can't have another object with the same name as the first object.

So:

const uint8_t dht1_pin = 2; 
const uint8_t dht2_pin = 3;
...
DHT dht1( dht1_pin, DHT11 );
DHT dht2( dht2_pin, DHT11 );
...
dht1.begin();
dht2.begin();
...
etc