Temperature and humidity sensor DHT11 experiment

Temperature sensor DHT11 experiment

Experimental phenomena

Read the value of DHT11 temperature and humidity sensor, and then send it to the PC to display it through the serial port

Theoretical study

Insert picture description here

Code writing

Install DHT11 library

#include <DHT.h>
DHT dht(8,DHT11);
void setup() {
    
    
  // put your setup code here, to run once:
  Serial.begin(9600);
  dht.begin();
}
void loop() {
    
    
  // put your main code here, to run repeatedly:
  delay(2000);
  Serial.println();
  Serial.print(" 温度是 : ");
  Serial.println(dht.readTemperature());
  Serial.print(" 湿度是 : ");
  Serial.println(dht.readHumidity());
}

Guess you like

Origin blog.csdn.net/qq_45671732/article/details/109558168