nodered_dht22.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:micropython-dev-kit 作者: db4linq 项目源码 文件源码
def run():  
    global oled 
    global CLIENT_ID    
    while True:
        try:
            t, h = get_temperature()
            msg =  json.dumps({ 'Heap': gc.mem_free(),  'Type':7, 'id': CLIENT_ID, 'temperature': '{0:.2f}'.format(t), 'humidity': '{0:.2f}'.format(h)})
            print(msg)
            client.publish('micro/{0}/temperature'.format(CLIENT_ID.decode("utf-8")), msg)
        except OSError as e:
            if e.args[0] == errno.ETIMEDOUT:
                print('error dht: ', e)
        time.sleep(5)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号