Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <DHT.h>
- #define dht1_dpin A1 //Pino DATA do Sensor ligado na porta Analogica A1
- #define dht2_dpin A0 //Pino DATA do Sensor ligado na porta Analogica A1
- DHT dht1(dht1_dpin, DHT11); //Inicializa o sensor
- DHT dht2(dht2_dpin, DHT11);//Inicializa o sensor2
- float h1;
- float t1;
- float h2;
- float t2;
- //-------------------------
- void setup()
- {
- Serial.begin(9600);
- //delay(1000);//Aguarda 1 seg antes de acessar as informações do sensor
- dht1.begin();
- dht2.begin();
- }
- //-------------------------
- void loop()
- {
- h1 = dht1.readHumidity();
- t1 = dht1.readTemperature();
- if (isnan(t1) || isnan(h1))
- {
- Serial.println("Failed to read from DHT1");
- }
- else
- {
- Serial.print("Umidade = ");
- Serial.print(h1);
- Serial.print(" % ");
- Serial.print("Temperatura = ");
- Serial.print(t1);
- Serial.println(" Celsius ");
- delay(1000);
- }
- h2 = dht2.readHumidity();
- t2 = dht2.readTemperature();
- if (isnan(t2) || isnan(h2))
- {
- Serial.println("Failed to read from DHT1");
- }
- else
- {
- Serial.print("Umidade = ");
- Serial.print(h2);
- Serial.print(" % ");
- Serial.print("Temperatura = ");
- Serial.print(t2);
- Serial.println(" Celsius ");
- delay(1000);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement