I have seen people struggle with this in various places on the web so posting here.
My setup is simple, I believe:
Fresh installs of micropython via Thonny.
SERVER PI and CLIENT PI both are running "MicroPython v1.22.1 on 2024-01-05; Raspberry Pi Pico W with RP2040"
Both run:
inches apart.
The server sets an IP of 198.162.4.1 for itself and the client gets 198.162.4.16 but after that neither can do a urequests.get() to port 80.
Both are running the latest microdot.
With or without auth they don't want to connect. I don't have the luxury of using an external AP (which does work BTW) for my intended use case.
My setup is simple, I believe:
Fresh installs of micropython via Thonny.
SERVER PI and CLIENT PI both are running "MicroPython v1.22.1 on 2024-01-05; Raspberry Pi Pico W with RP2040"
Both run:
Code:
import timeimport networkfrom config import mode # server or clientprint("Wireless ", mode)if mode=="server": ap = network.WLAN(network.AP_IF) ap.config(essid="TESTWIFI", password="something') ap.active(True) print(ap.ifconfig()) else: sta_if = network.WLAN(network.STA_IF) sta_if.active(True) count=0 while True: try: sta_if.connect("TESTWIFI", "something") time.sleep(2) except OSError as e: count+=1 print(f"Wifi Err Count: {count}") time.sleep(2) except Exception as e: print(e) if sta_if.isconnected(): print('Connected to Wifi') break time.sleep(2) print(sta_if.ifconfig())
inches apart.
The server sets an IP of 198.162.4.1 for itself and the client gets 198.162.4.16 but after that neither can do a urequests.get() to port 80.
Both are running the latest microdot.
Code:
==SERVER>>> print(ap.ifconfig())('192.168.4.1', '255.255.255.0', '192.168.4.1', '0.0.0.0')==CLIENT>>> sta_if.ifconfig()('192.168.4.16', '255.255.255.0', '192.168.4.1', '192.168.4.1')urequests.get(f"http:/192.168.4.1/mypage")Traceback (most recent call last): File "<stdin>", line 1, in <module> File "requests/__init__.py", line 180, in get File "requests/__init__.py", line 76, in requestOSError: -2
Statistics: Posted by raspmod — Sat Jan 20, 2024 4:39 am