Replies: 11 comments 9 replies
-
After # seems more reliable to start with a fresh connect()
if wlan.isconnected():
wlan.disconnect()
print (f'started in the connected state, but now disconnected')
else:
print (f'started in the disconnected state') and after any wlan.active(False) |
Beta Was this translation helpful? Give feedback.
-
You did print out |
Beta Was this translation helpful? Give feedback.
-
Which frequency & channel is used by your AP? |
Beta Was this translation helpful? Give feedback.
-
Whenever I'm making a network connection, whatever the chip, I put the connect code in a while loop to try multiple times in succession. I also trap and ignore any errors in the loop though you don't seem to get those. It often takes a number of tries to connect. |
Beta Was this translation helpful? Give feedback.
-
Hi All, Thanks Steve. Here is the code I wrote to test:
I have two access points I should be able to connect to. My internet box and I setup an access point with my mobile to test. Here are the results of the code above trying accessing these access points:
Here, box_ap is not found on the radio with the wlan.connect(accessPoint, apPWD), but it's listed from the wlan.scan(). Now connecting to my mobile ap:
As you can see, it's connected straight. Unfortunately, I need to connect to my box access point. Is it possible to configure the phy_mode in ESP32? I'll give it a try. Thanks and regards, Eric. |
Beta Was this translation helpful? Give feedback.
-
Unfortunatelly, py_mode doesn't look implemented for ESP32:
|
Beta Was this translation helpful? Give feedback.
-
This may be a silly question. I'm wondering if you can connect your smartphone to the 'box_ap'. That should probably be OK. Trying with my ESP32-S2FN4R2 boards, one as AP, the other as STA, I have never seen status 201 (STAT_NO_AP_FOUND). Attempt to connect to non-existent AP, I get status 1001 (STAT_CONNECTING) until I give up. This is my 'wifi_connect.py' script import time, network
network.WLAN(network.AP_IF).active(False)
wlan = network.WLAN(network.STA_IF)
wlan.active(True)
wlan.disconnect()
ssid, pwd = "ABC", "abc123def"
wlan.connect(ssid, pwd)
cnt = 0
while True:
stat = wlan.status()
if stat == network.STAT_GOT_IP:
print('Connected with IP:', wlan.ifconfig()[0])
break
else:
if stat == network.STAT_CONNECTING:
# print('Connecting ... status', stat)
time.sleep_ms(500)
cnt += 1
if cnt>10:
print('Give up, trying to connect', cnt, 'times')
break
else:
print('Give up with status', stat)
break This is my 'AP.py' script import network, time
SID = 'ABC'
PWD = 'abc123def'
IP = '10.10.4.1'
network.WLAN(network.STA_IF).active(False)
time.sleep(1) # wait for IF to reset
ap = network.WLAN(network.AP_IF)
ap.active(True)
ap.config(essid=SID)
ap.config(authmode=3, password=PWD)
# IP address, netmask, gateway, DNS
z = (IP, '255.255.255.0', IP, '8.8.8.8')
ap.ifconfig(z)
print(ap.ifconfig()) |
Beta Was this translation helpful? Give feedback.
-
Hi All, I tried to connect with BSSID, resulting with same status. I changed the channel, same result.... Stuck here. |
Beta Was this translation helpful? Give feedback.
-
There is one more thing you can try. You can connect your smartphone to your 'box_ap' and enable Wi-Fi Hotspot on your phone. Then try to connect your esp32-s2 to your smartphone. I did the same test here with my old Android phone and the wemos s2 mini card. I managed to connect and get an IP. |
Beta Was this translation helpful? Give feedback.
-
Since the early times of the ESP8266 I use the below script for the connection to the AP. It is derived from the example script in the documentation. connect() is only called once, and then it just checks the state using is_connected(). I verified that it works with a ESP32S2 board (UM Feather S2).
|
Beta Was this translation helpful? Give feedback.
-
This is not related to the problem you are experiencing, but installing a NAT router may somewhat solve the problem of connecting your esp32-s2 board directly to your main Internet router. YouTube: https://www.youtube.com/watch?v=41Lymi6rXA8 URL: https://github.com/martin-ger/esp32_nat_router I have installed this and am using the network it provides for my IoT experiments. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi guys,
I am trying to connect to WIFI with a S2-mini clone. The vendor says it's ESP32-S2FN4R2.
I have compile the following firmware:
MicroPython v1.20.0-450-g3637252b7-dirty on 2023-09-07; LOLIN_S2_MINI with ESP32-S2FN4R2
Here is my code in Thonny:
SSID and PWD are validated with my laptop.
I have no idea where to look.
Thanks and regards,
Eric.
Beta Was this translation helpful? Give feedback.
All reactions