Skip to content

实现温度和湿度检测

python
from machine import Pin
import time, dht

data = dht.DHT22(Pin(4))  # 实例化15号管脚

while True:
    data.measure()  # 先调用测量函数,获取温湿度
    temp = data.temperature()
    humi = data.humidity()
    print(temp, humi)
    time.sleep(1)

https://wokwi.com/projects/406354755982132225