Newbie with WIFI problem

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
Post Reply
jpbrs
Posts: 1
Joined: Mon Mar 25, 2019 10:13 pm

Newbie with WIFI problem

Post by jpbrs » Mon Mar 25, 2019 10:17 pm

Hi, im newbie and i am using an ESP8266 nodeMCU board. I am trying to connect to my wifi with the code:

import network

ssid="casa_1001"
password="xxxxxxxxxxx"

network.WLAN(network.AP_IF).active(False)
sta_if = network.WLAN(network.STA_IF)

sta_if.active(True)
sta_if.connect(ssid, password)

But i am getting the error below

Traceback (most recent call last):
File "/Users/mac/anaconda3/bin/ampy", line 11, in <module>
load_entry_point('adafruit-ampy==1.0.7', 'console_scripts', 'ampy')()
File "/Users/mac/anaconda3/lib/python3.6/site-packages/click/core.py", line 722, in __call__
return self.main(*args, **kwargs)
File "/Users/mac/anaconda3/lib/python3.6/site-packages/click/core.py", line 697, in main
rv = self.invoke(ctx)
File "/Users/mac/anaconda3/lib/python3.6/site-packages/click/core.py", line 1066, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/Users/mac/anaconda3/lib/python3.6/site-packages/click/core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/Users/mac/anaconda3/lib/python3.6/site-packages/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/Users/mac/anaconda3/lib/python3.6/site-packages/adafruit_ampy-1.0.7-py3.6.egg/ampy/cli.py", line 337, in run
output = board_files.run(local_file, not no_output)
File "/Users/mac/anaconda3/lib/python3.6/site-packages/adafruit_ampy-1.0.7-py3.6.egg/ampy/files.py", line 303, in run
out = self._pyboard.execfile(filename)
File "/Users/mac/anaconda3/lib/python3.6/site-packages/adafruit_ampy-1.0.7-py3.6.egg/ampy/pyboard.py", line 275, in execfile
return self.exec_(pyfile)
File "/Users/mac/anaconda3/lib/python3.6/site-packages/adafruit_ampy-1.0.7-py3.6.egg/ampy/pyboard.py", line 269, in exec_
raise PyboardError('exception', ret, ret_err)
ampy.pyboard.PyboardError: ('exception', b'', b'Traceback (most recent call last):\r\n File "<stdin>", line 19, in <module>\r\nTypeError: function takes 2 positional arguments but 3 were given\r\n')


Someone has any idea to help me?

User avatar
MorseIot
Posts: 38
Joined: Fri Jun 29, 2018 12:32 am

Re: Newbie with WIFI problem

Post by MorseIot » Tue Mar 26, 2019 1:08 am

jpbrs wrote:
Mon Mar 25, 2019 10:17 pm
Hi, im newbie and i am using an ESP8266 nodeMCU board. I am trying to connect to my wifi with the code:

import network

ssid="casa_1001"
password="xxxxxxxxxxx"

network.WLAN(network.AP_IF).active(False)
sta_if = network.WLAN(network.STA_IF)

sta_if.active(True)
sta_if.connect(ssid, password)

But i am getting the error below

Traceback (most recent call last):
File "/Users/mac/anaconda3/bin/ampy", line 11, in <module>
load_entry_point('adafruit-ampy==1.0.7', 'console_scripts', 'ampy')()
File "/Users/mac/anaconda3/lib/python3.6/site-packages/click/core.py", line 722, in __call__
return self.main(*args, **kwargs)
File "/Users/mac/anaconda3/lib/python3.6/site-packages/click/core.py", line 697, in main
rv = self.invoke(ctx)
File "/Users/mac/anaconda3/lib/python3.6/site-packages/click/core.py", line 1066, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/Users/mac/anaconda3/lib/python3.6/site-packages/click/core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/Users/mac/anaconda3/lib/python3.6/site-packages/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/Users/mac/anaconda3/lib/python3.6/site-packages/adafruit_ampy-1.0.7-py3.6.egg/ampy/cli.py", line 337, in run
output = board_files.run(local_file, not no_output)
File "/Users/mac/anaconda3/lib/python3.6/site-packages/adafruit_ampy-1.0.7-py3.6.egg/ampy/files.py", line 303, in run
out = self._pyboard.execfile(filename)
File "/Users/mac/anaconda3/lib/python3.6/site-packages/adafruit_ampy-1.0.7-py3.6.egg/ampy/pyboard.py", line 275, in execfile
return self.exec_(pyfile)
File "/Users/mac/anaconda3/lib/python3.6/site-packages/adafruit_ampy-1.0.7-py3.6.egg/ampy/pyboard.py", line 269, in exec_
raise PyboardError('exception', ret, ret_err)
ampy.pyboard.PyboardError: ('exception', b'', b'Traceback (most recent call last):\r\n File "<stdin>", line 19, in <module>\r\nTypeError: function takes 2 positional arguments but 3 were given\r\n')


Someone has any idea to help me?
Use this code, add while......

Code: Select all

import network
ssid="casa_1001"
password="xxxxxxxxxxx"
network.WLAN(network.AP_IF).active(False)
sta_if = network.WLAN(network.STA_IF)
sta_if.active(True)
sta_if.connect(ssid, password)
while not sta_if.isconnected():
   pass

kevinkk525
Posts: 969
Joined: Sat Feb 03, 2018 7:02 pm

Re: Newbie with WIFI problem

Post by kevinkk525 » Tue Mar 26, 2019 5:43 am

I'm not even sure what the exception has to do with your micropython code because the exception occurs on the host system, not the esp8266.
Kevin Köck
Micropython Smarthome Firmware (with Home-Assistant integration): https://github.com/kevinkk525/pysmartnode

Post Reply