Can't set up the network

Questions and discussion about The WiPy 1.0 board and CC3200 boards.
Target audience: Users with a WiPy 1.0 or CC3200 board.
uzi_hs
Posts: 5
Joined: Thu May 28, 2015 5:08 pm

Can't set up the network

Post by uzi_hs » Tue Oct 27, 2015 8:23 pm

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

User avatar
danicampora
Posts: 342
Joined: Tue Sep 30, 2014 7:20 am
Contact:

Re: Can't set up the network

Post by danicampora » Tue Oct 27, 2015 9:20 pm

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:

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
Or, duplicate the REPL on the UART (http://micropython.org/resources/docs/e ... /repl.html):

Code: Select all

from machine import UART
import os
uart = UART(0, 115200)
os.dupterm(uart)

uzi_hs
Posts: 5
Joined: Thu May 28, 2015 5:08 pm

Re: Can't set up the network

Post by uzi_hs » Wed Oct 28, 2015 8:25 am

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!

User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: Can't set up the network

Post by dhylands » Wed Oct 28, 2015 9:37 pm

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.

uzi_hs
Posts: 5
Joined: Thu May 28, 2015 5:08 pm

Re: Can't set up the network

Post by uzi_hs » Thu Oct 29, 2015 5:02 am

OK, now it makes sense.
Thanks!

User avatar
danicampora
Posts: 342
Joined: Tue Sep 30, 2014 7:20 am
Contact:

Re: Can't set up the network

Post by danicampora » Sat Oct 31, 2015 9:36 am

It does say that you should put it in boot.py:
Place this piece of code inside your boot.py so that it’s done automatically after reset.
Just after the code snippet.

uzi_hs
Posts: 5
Joined: Thu May 28, 2015 5:08 pm

Re: Can't set up the network

Post by uzi_hs » Sat Oct 31, 2015 4:32 pm

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?


uzi_hs
Posts: 5
Joined: Thu May 28, 2015 5:08 pm

Re: Can't set up the network

Post by uzi_hs » Sat Oct 31, 2015 9:10 pm

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).

User avatar
s-light
Posts: 3
Joined: Sun Jun 21, 2015 8:18 am
Location: Germany, Nuremberg
Contact:

Re: Can't set up the network

Post by s-light » Mon Nov 02, 2015 8:05 am

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

Post Reply