//SDA接腳位
#include <DHTesp.h>
const int DHT_PIN = 15;
DHTesp dhtSensor;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("Hello, ESP32!");
dhtSensor.setup(DHT_PIN,DHTesp::DHT22);
}
void loop() {
// put your main code here, to run repeatedly:
delay(10); // this speeds up the simulation
TempAndHumidity data = dhtSensor.getTempAndHumidity();
Serial.println("Temp:" + String(data.temperature,2) + "°C"); //(,控制小數點後幾位)
Serial.println("Humidity:" + String(data.humidity,1) + "%");
delay(1000);
}