刚刚把代码又传到8266 里面 , 继续重现这个问题.
UPDATE: 貌似发现问题了 , 我重刷固件之后, 用serial 连接上wifi后, 把下面代码上传上去 , 然后我同时又使用了GPIO15 .
把这个端口 不知道是拉低还是拉高了 ,就会出现这个问题了 .
我GPIO15脚是接LED的负极 , 另一边是接模块供电的VCC
-
- import network
- import time
- import socket
- import machine
- from time import sleep
-
-
- s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
- s.bind(('', 9000))
- s.setblocking(False)
-
- ADDRESS = '192.168.233.11'
- GATEWAY = '192.168.233.233'
- GPIO = 15
-
- def do_connect():
- wlan = network.WLAN(network.STA_IF)
- wlan.active(True)
- if wlan.ifconfig()[0] == ADDRESS:
- return wlan.isconnected()
- elif not wlan.isconnected():
- wlan.ifconfig((ADDRESS, '255.255.255.0', GATEWAY, '114.114.114.114'))
- wlan.connect('SSID', 'PASSWORD')
- while not wlan.isconnected():
- pass
- return wlan.isconnected()
-
-
- def set_pin_hight(pin):
- pin.value(1)
- sleep(0.3)
- pin.value(0)
-
- def set_pin_low(pin):
- pin.value(0)
-
- def reset():
- machine.reset()
-
- def main():
- if do_connect():
- pin = machine.Pin(GPIO, machine.Pin.OUT) # GPIO15 default hight level
-
- while True:
- try:
- msg, address = s.recvfrom(1024)
- except OSError as err:
- if 'ETIMEDOUT' in str(err):
- sleep(1)
- continue
- else:
- print("something else error")
- else:
- print(msg)
- set_pin_hight(pin)
- set_pin_low(pin)
-
- main()
本帖最后由 p0we7 于 2016-12-11 22:40 编辑