温湿度传感器(DHT11) =================== .. figure:: /_static/products/ledong-module/static/图片/DHT11温湿度.png :width: 55% :align: center 概述 -------------------- 基于DHT11数字温湿度传感器集成IC。用于检测环境温湿度。 技术参数 ------------------- 工作电压: VCC 3.3V -5V 模块尺寸:24*48mm 固定安装:2个兼容塑料积木通孔 温度:-20--60℃ 湿度:5--95% 引脚定义 ------------------- ===== ======== 引脚 定义 ===== ======== GND 地 VCC 电源 DI 数字输出 NC 空 ===== ======== 示例程序 ------------------- **间隔一秒打印温湿度信息** .. code-block:: python from mpython import * from machine import Timer import dht dht11 = dht.DHT11(Pin(Pin.P0)) tim15 = Timer(15) def timer15_tick(_): try: dht11.measure() except: pass tim15.init(period=1000, mode=Timer.PERIODIC, callback=timer15_tick) import time while True: print(dht11.temperature()) print(dht11.humidity()) time.sleep(1) .. figure:: /_static/products/ledong-module/static/examples/dht.png :width: 100% :align: center