//安裝Adafruit Unified Sensor Library DHT Sensor Library #include #include #include #define DHTPIN 3 #define DHTTYPE DHT11 DHT_Unified dht(DHTPIN, DHTTYPE); void setup() { // put your setup code here, to run once: Serial.begin(115200); dht.begin(); } void loop() { // put your main code here, to run repeatedly: sensors_event_t event; dht.temperature().getEvent(&event); Serial.print("Temperature: "); Serial.print(event.temperature); Serial.println(" *C"); dht.humidity().getEvent(&event); Serial.print("Humidity: "); Serial.print(event.relative_humidity); Serial.println("%"); delay(1000); }