Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 7513

MicroPython • Micropython utility code to connect pico-W to WiFi

$
0
0
I built a couple of projects using python on a pico-W and wanted to make it possible for an end user to connect them to their home WiFi using a web page in access point mode. I wrote some code for this and have published it on github.
https://github.com/st739/WiFind-pico
On power on the pico starts an unsecured hotspot, scans for WiFi networks and displays them on a web page. The page allows network selection, password entry and the selection of a static IP (between 100 and 250). When the page is saved, the pico attempts to connect to the desired WiFi network and if successful, pings the desired IP. If the IP is free, the pico restarts in hotspot mode and displays the IP and MAC addresses. On save, the pico connects to the network and sets the desired address.
Once the SSID, password and desired IP are saved subsequent power ons connect to the network and start an arbitrary application. Demo code is included that starts a 'hello world' web page.
Continued hotspot use is supported. If the hotspot is chosen as the desired network, a password is required and an arbitrary hotspot name can be entered.
If the hotspot password is forgotten or if the selected WiFi network is replaced or its password changed, the pico can be power cycled 3 times to clear the configuration and restart in basic configuration mode.
Simon

Statistics: Posted by Simon739 — Sat Jan 17, 2026 1:53 pm — Replies 0 — Views 38



Viewing all articles
Browse latest Browse all 7513

Trending Articles