查看: 687|回复: 0

DHT11为什么与WULink-Python设备接线正确任然返回0?

[复制链接]

2

主题

2

帖子

35

积分

注册会员

Rank: 2

积分
35
发表于 2025-5-20 20:30:48 | 显示全部楼层 |阅读模式
以下为代码:
from mpython import *
from machine import Timer
import dht
import time

dht11 = dht.DHT11(Pin(Pin.P0))
tim13 = Timer(13)
def timer13_tick(_):
    try: dht11.measure()
    except: pass

tim13.init(period=1000, mode=Timer.PERIODIC, callback=timer13_tick)

while True:
    温度 = dht11.temperature()
    湿度 = dht11.humidity()
    oled.fill(0)
    oled.DispChar(str((''.join([str(x) for x in ['当前温度:', 温度, '℃']]))), 0, 0, 1)
    oled.DispChar(str((''.join([str(x2) for x2 in ['当前湿度:', 湿度, '%RH']]))), 0, 16, 1)
    oled.show()
    time.sleep(1)

(其实就是例程)
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|好好搭搭在线 ( © 好好搭搭在线 浙ICP备19030393号 )

GMT+8, 2026-5-9 22:52 , Processed in 0.089660 second(s), 23 queries .

Powered by Discuz!

© 2001-2026 Comsenz Inc.

快速回复 返回顶部 返回列表