#include "DHT.h"
#define sensor_1 13
#define sensor_2 12
#define sensor_3 11
#define sensor_4 10
#define sensor_5 9
#define sensor_6 8
#define sensor_7 7
#define sensor_8 6
#define sensor_9 5
#define sensor_10 4
#define DHTTYPE DHT22 // DHT 22 (AM2302), AM2321
DHT dht1(sensor_1, DHTTYPE);
DHT dht2(sensor_2, DHTTYPE);
DHT dht3(sensor_3, DHTTYPE);
DHT dht4(sensor_4, DHTTYPE);
DHT dht5(sensor_5, DHTTYPE);
DHT dht6(sensor_6, DHTTYPE);
DHT dht7(sensor_7, DHTTYPE);
DHT dht8(sensor_8, DHTTYPE);
DHT dht9(sensor_9, DHTTYPE);
DHT dht10(sensor_10, DHTTYPE);
void setup() {
Serial.begin(9600, SERIAL_8N1); //8bit's, sem paridade, 1 stop bit
Serial.println(F("Diego Nunes"));
dht1.begin();
dht2.begin();
dht3.begin();
dht4.begin();
dht5.begin();
dht6.begin();
dht7.begin();
dht8.begin();
dht9.begin();
dht10.begin();
}
void loop() {
float t1 = dht1.readTemperature();
float h1 = dht1.readHumidity();
if (isnan(t1) || isnan(h1)) {
Serial.println(F("Failed to read from DHT sensor 1!"));
return;
}
float t2 = dht2.readTemperature();
float h2 = dht2.readHumidity();
if (isnan(t2) || isnan(h2)) {
Serial.println(F("Failed to read from DHT sensor 2!"));
return;
}
float t3 = dht3.readTemperature();
float h3 = dht3.readHumidity();
if (isnan(t3) || isnan(h3)) {
Serial.println(F("Failed to read from DHT sensor 3!"));
return;
}
float t4 = dht4.readTemperature();
float h4 = dht4.readHumidity();
if (isnan(t4) || isnan(h4)) {
Serial.println(F("Failed to read from DHT sensor 4!"));
return;
}
float t5 = dht5.readTemperature();
float h5 = dht5.readHumidity();
if (isnan(t5) || isnan(h5)) {
Serial.println(F("Failed to read from DHT sensor 5!"));
return;
}
float t6 = dht6.readTemperature();
float h6 = dht6.readHumidity();
if (isnan(t6) || isnan(h6)) {
Serial.println(F("Failed to read from DHT sensor 6!"));
return;
}
float t7 = dht7.readTemperature();
float h7 = dht7.readHumidity();
if (isnan(t7) || isnan(h7)) {
Serial.println(F("Failed to read from DHT sensor 7!"));
return;
}
float t8 = dht8.readTemperature();
float h8 = dht8.readHumidity();
if (isnan(t8) || isnan(h8)) {
Serial.println(F("Failed to read from DHT sensor 8!"));
return;
}
float t9 = dht9.readTemperature();
float h9 = dht9.readHumidity();
if (isnan(t9) || isnan(h9)) {
Serial.println(F("Failed to read from DHT sensor 9!"));
return;
}
float t10 = dht10.readTemperature();
float h10 = dht10.readHumidity();
if (isnan(t10) || isnan(h10)) {
Serial.println(F("Failed to read from DHT sensor 10!"));
return;
}
Serial.print(F("H1:"));
Serial.print(h1);
Serial.print(F("% T1:"));
Serial.print(t1);
Serial.print(F("°C "));
Serial.print(F("H2:"));
Serial.print(h2);
Serial.print(F("% T2:"));
Serial.print(t2);
Serial.print(F("°C "));
Serial.print(F("H3:"));
Serial.print(h3);
Serial.print(F("% T3:"));
Serial.print(t3);
Serial.print(F("°C "));
Serial.print(F("H4:"));
Serial.print(h4);
Serial.print(F("% T4:"));
Serial.print(t4);
Serial.print(F("°C "));
Serial.print(F("H5:"));
Serial.print(h5);
Serial.print(F("% T5:"));
Serial.print(t5);
Serial.print(F("°C "));
Serial.print(F("H6:"));
Serial.print(h6);
Serial.print(F("% T6:"));
Serial.print(t6);
Serial.print(F("°C "));
Serial.print(F("H7:"));
Serial.print(h7);
Serial.print(F("% T7:"));
Serial.print(t7);
Serial.print(F("°C "));
Serial.print(F("H8:"));
Serial.print(h8);
Serial.print(F("% T8:"));
Serial.print(t8);
Serial.print(F("°C "));
Serial.print(F("H9:"));
Serial.print(h9);
Serial.print(F("% T9:"));
Serial.print(t9);
Serial.print(F("°C "));
Serial.print(F("H10:"));
Serial.print(h10);
Serial.print(F("% T10:"));
Serial.print(t10);
Serial.println(F("°C "));
// Wait a few seconds between measurements.
delay(2000);
}