Can't set up the network
Can't set up the network
Hi,
I'm trying to set up the network, so WiPy will connect to my WiFi router.
I tried to follow the instruction here:
http://micropython.org/resources/docs/e ... /wlan.html
But the connection disconnect as soon as I run:
wlan.init(WLAN.STA)
Do I need to use the UART connection in order to set it up? Unfortunately I also can't connect via UART. When I try to run:
screen /dev/cu.usbserial-DB00IFH7 115200
I just see black screen...
Thanks,
Uzi
I'm trying to set up the network, so WiPy will connect to my WiFi router.
I tried to follow the instruction here:
http://micropython.org/resources/docs/e ... /wlan.html
But the connection disconnect as soon as I run:
wlan.init(WLAN.STA)
Do I need to use the UART connection in order to set it up? Unfortunately I also can't connect via UART. When I try to run:
screen /dev/cu.usbserial-DB00IFH7 115200
I just see black screen...
Thanks,
Uzi
- danicampora
- Posts: 342
- Joined: Tue Sep 30, 2014 7:20 am
- Contact:
Re: Can't set up the network
When you change the WLAN mode from AP to STA, the connection from your PC to the WiPy breaks. There are two ways around it:
Do all that setup inside boot.py, as explained in the docs:
Or, duplicate the REPL on the UART (http://micropython.org/resources/docs/e ... /repl.html):
Do all that setup inside boot.py, as explained in the docs:
Code: Select all
import machine
from network import WLAN
wlan = WLAN() # get current object, without changing the mode
if machine.reset_cause() != machine.SOFT_RESET:
wlan.init(WLAN.STA)
# configuration below MUST match your home router settings!!
wlan.ifconfig(config=('192.168.178.107', '255.255.255.0', '192.168.178.1', '8.8.8.8'))
if not wlan.isconnected():
wlan.connect('mywifi', auth=(WLAN.WPA2, 'mywifikey'), timeout=5000)
while not wlan.isconnected():
machine.idle() # save power while waiting
Code: Select all
from machine import UART
import os
uart = UART(0, 115200)
os.dupterm(uart)
Re: Can't set up the network
So it finally works. Thanks!
BTW - the documentation doesn't state that it should be put in boot.py. It could be helpful it could be stated there.
I love WiPy. It's really very well done. A better documentation would make it even better!
Out of curiosity, what's the purpose of this if:
if machine.reset_cause() != machine.SOFT_RESET:
Soft reset is done by software, or pressing the button? I assume that in this case we don't need to set it up since the configuration is somehow kept on a different chip?
Thank again!
BTW - the documentation doesn't state that it should be put in boot.py. It could be helpful it could be stated there.
I love WiPy. It's really very well done. A better documentation would make it even better!
Out of curiosity, what's the purpose of this if:
if machine.reset_cause() != machine.SOFT_RESET:
Soft reset is done by software, or pressing the button? I assume that in this case we don't need to set it up since the configuration is somehow kept on a different chip?
Thank again!
Re: Can't set up the network
When you press Control-D at the prompt that does what's referred to as a soft-reset.
Basically it renitializes the python engine, but doesn't affect the Wifi, which is why those commands don't need to be executed again. Executing them would cause your telnet session (where you have the REPL) to be dropped.
Basically it renitializes the python engine, but doesn't affect the Wifi, which is why those commands don't need to be executed again. Executing them would cause your telnet session (where you have the REPL) to be dropped.
Re: Can't set up the network
OK, now it makes sense.
Thanks!
Thanks!
- danicampora
- Posts: 342
- Joined: Tue Sep 30, 2014 7:20 am
- Contact:
Re: Can't set up the network
It does say that you should put it in boot.py:
Just after the code snippet.Place this piece of code inside your boot.py so that it’s done automatically after reset.
Re: Can't set up the network
So I guess that I'm not looking at the right place:
http://micropython.org/resources/docs/e ... /wlan.html
What's the right URL?
http://micropython.org/resources/docs/e ... /wlan.html
What's the right URL?
- danicampora
- Posts: 342
- Joined: Tue Sep 30, 2014 7:20 am
- Contact:
Re: Can't set up the network
Oh, know I understand the confusion. I was actually referring to the missing documentation regarding the WLAN setup (See the URL that I included in my previous reply).
Re: Can't set up the network
Hi @all,
i had the same confusion with the wlan-setup.
http://micropython.org/resources/docs/e ... /wlan.html
does not mention where the right place for the given code is.
(i searched and found this topic...)
during my initial reading i think i see some other 'bugs' in the documentation
(cant find them at the moment)
What is the right / prefered way to bring these suggestions to you/the team?
thanks for a cool board & software - it worked out of the box as described in the quick-start!
now i will play around and see what i will do with it
sunny greetings
stefan
i had the same confusion with the wlan-setup.
http://micropython.org/resources/docs/e ... /wlan.html
does not mention where the right place for the given code is.
(i searched and found this topic...)
during my initial reading i think i see some other 'bugs' in the documentation
(cant find them at the moment)
What is the right / prefered way to bring these suggestions to you/the team?
thanks for a cool board & software - it worked out of the box as described in the quick-start!
now i will play around and see what i will do with it
sunny greetings
stefan