关注分享主机优惠活动
国内外VPS云服务器

Python控制微控制器TPYBoard MicroPython v202链接DTH11温湿度M

TPYBoard MicroPython v202链接DTH11 mqtt上传数据,具体实现。打起来不容易。给物联网人点个赞。先看效果图和硬件连接图。

DHT连接图

前端显示:总共有四个python文件。我用GPIO5。代码是这样写的。simple.py应该这样写。这是一个通过socket连接mqtt的简单包。

import u socket as socketimport ustrct as struct from ubinascii import hexlifyclass MQTTException(Exception):pass class MQTTClient:def _ _ init _ _(self,client_id,server,port=0,user=None,password=None,keepalive=0,SSL _ params = { }):if port = = 0:port = 8883 if SSL else 1883 self . client _ id = client _ id self . sock = None self . server = server self . porth ",len(s)))self . sock . write(s)def _ recv _ len(self):n = 0 sh = 0 while 1:b = self . sock . read(1)[0]n | =(b & 0x7f)

未经允许不得转载:主机频道 » Python控制微控制器TPYBoard MicroPython v202链接DTH11温湿度M

评论 抢沙发

评论前必须登录!