|
大佬们求助 esp8266 micropython问题
[复制链接]
本帖最后由 endlingbo 于 2019-3-27 18:29 编辑
各位大佬,小白求助 如图,直接点击Execute成功运行main.py,但是重新上电自动运行main.py就出现下一张图的错误
- # main.py
- import time
- from simple import MQTTClient
- from machine import Pin
- led=Pin(2,Pin.OUT)
- def sub_cb(topic, msg):
- print(topic, msg)
- if topic==b'ledctl':
- if msg==b'ledon':
- led.off()
- if msg==b'ledoff':
- led.on()
- c = MQTTClient("umqtt_client", "111.67.206.175")
- c.set_callback(sub_cb)
- c.connect()
- c.subscribe(b"ledctl")
- while True:
- c.check_msg()
- if led.value()==1:
- c.publish('ledstatus','ledoff')
- if led.value()==0:
- c.publish('ledstatus','ledon')
- time.sleep(1)
复制代码
|
|