I am having trouble to get it working and I don´t understand what I am doing wrong.
Is there anyone kind people who is willing to help me out?
The idea is a board with three dht11.
#include <dht.h>
#define DHTTYPE1 DHT11
#define DHTTYPE2 DHT11
#define DHTTYPE3 DHT11
#define DHT_1_PIN 2
#define DHT_2_PIN 3
#define DHT_3_PIN 4
DHT dht_1(DHT_1_PIN, DHTTYPE1);
DHT dht_2(DHT_2_PIN, DHTTYPE2);
DHT dht_3(DHT_3_PIN, DHTTYPE3);
void setup() {
Serial.begin(9600);
Serial.println("DHTxx test!");
dht_1.begin();
dht_2.begin();
dht_3.begin();
}
void loop() {
float h1 = dht_1.readHumidity();
float t1 = dht_1.readTemperature();
float h2 = dht_2.readHumidity();
float t2 = dht_2.readTemperature();
float h3 = dht_3.readHumidity();
float t3 = dht_3.readTemperature();
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");
}
if (isnan(t3) || isnan(h3)) {
Serial.println("Failed to read from DHT #3");
} else {
Serial.print("Humidity 3: ");
Serial.print(h3);
Serial.print(" %\t");
Serial.print("Temperature 3: ");
Serial.print(t3);
Serial.println(" *C");
}
Serial.println();
}
And I get this error:
dht11_3_test:12: error: 'DHT' does not name a type
dht11_3_test:13: error: 'DHT' does not name a type
dht11_3_test:14: error: 'DHT' does not name a type
dht11_3_test.ino: In function 'void setup()':
dht11_3_test:20: error: 'dht_1' was not declared in this scope
dht11_3_test:21: error: 'dht_2' was not declared in this scope
dht11_3_test:22: error: 'dht_3' was not declared in this scope
dht11_3_test.ino: In function 'void loop()':
dht11_3_test:27: error: 'dht_1' was not declared in this scope
dht11_3_test:29: error: 'dht_2' was not declared in this scope
dht11_3_test:31: error: 'dht_3' was not declared in this scope
Regards
Linus