/**
ESP32 + DHT22 Example for Wokwi
https://wokwi.com/arduino/projects/322410731508073042
*/
#include "DHTesp.h"
const int DHT_PIN_0 = 15;
const int DHT_PIN_1 = 14;
const int DHT_PIN_2 = 13;
const int DHT_PIN_3 = 12;
const int DHT_PIN_4 = 4;
const int DHT_PIN_5 = 2;
DHTesp dhtSensor[6];
void setup() {
Serial.begin(115200);
dhtSensor[0].setup(DHT_PIN_0, DHTesp::DHT22);
dhtSensor[1].setup(DHT_PIN_1, DHTesp::DHT22);
dhtSensor[2].setup(DHT_PIN_2, DHTesp::DHT22);
dhtSensor[3].setup(DHT_PIN_3, DHTesp::DHT22);
dhtSensor[4].setup(DHT_PIN_4, DHTesp::DHT22);
dhtSensor[5].setup(DHT_PIN_5, DHTesp::DHT22);
}
void loop() {
TempAndHumidity data = dhtSensor[0].getTempAndHumidity();
Serial.println("Temp1: " + String(data.temperature, 2) + "°C");
Serial.println("Humidity: " + String(data.humidity, 1) + "%");
Serial.println("---");
data = dhtSensor[1].getTempAndHumidity();
Serial.println("Temp2: " + String(data.temperature, 2) + "°C");
Serial.println("Humidity: " + String(data.humidity, 1) + "%");
Serial.println("---");
data = dhtSensor[2].getTempAndHumidity();
Serial.println("Temp3: " + String(data.temperature, 2) + "°C");
Serial.println("Humidity: " + String(data.humidity, 1) + "%");
Serial.println("---");
data = dhtSensor[3].getTempAndHumidity();
Serial.println("Temp4: " + String(data.temperature, 2) + "°C");
Serial.println("Humidity: " + String(data.humidity, 1) + "%");
Serial.println("---");
data = dhtSensor[4].getTempAndHumidity();
Serial.println("Temp5: " + String(data.temperature, 2) + "°C");
Serial.println("Humidity: " + String(data.humidity, 1) + "%");
Serial.println("---");
data = dhtSensor[5].getTempAndHumidity();
Serial.println("Temp6: " + String(data.temperature, 2) + "°C");
Serial.println("Humidity: " + String(data.humidity, 1) + "%");
Serial.println("---");
delay(1000);
}