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)
评论列表
文章目录