I want to set up a soft access point (a hotspot without an internet connection) on my Raspberry Pi Pico W with a webserver, the reason it needs to also be a soft access point is because I want to take it with me on the road so most of the times there won't be wifi networks around me to join. I need to use CircuitPython instead of MicroPython, it worked on MicroPython and I keep getting errors that I can't import network.
I tried installing newer firmware of CircuitPython on the Pico W from the original site: https://circuitpython.org/board/raspberry_pi_pico_w/ the latest release is CircuitPython 8.0.3 and I also tried installing older versions of CircuitPython, but it just won't work. I also tried importing the wifi module, that worked but it can't create a soft access point.
This is the code that I'm using:
import network
ap_ssid = "myAP"
ap_password = "password123"
# create access point interface
ap_if = network.WLAN(network.AP_IF)
# disable default access point
ap_if.active(False)
# configure access point settings
ap_if.active(True)
ap_if.config(essid=ap_ssid, password=ap_password)
# print access point settings
print("Access point created with SSID: {}, password: {}".format(ap_ssid, ap_password))
print("Access point IP address:", ap_if.ifconfig()[0])
CircuitPython does not use MicroPython's network module, instead, it uses its own wifi module, which comes preinstalled on most wifi-equipped boards, including the Raspberry Pi Pico W.
First, import the module:
Then start the access point:
To stop the access point run:
Here would be your full code:
Here's a description of the start_ap command from the docs:
For more information, head to CircuitPython's documentation: https://docs.circuitpython.org/en/latest/shared-bindings/wifi/index.html#wifi.Radio.start_ap
Here's a tutorial on using the wifi module with a Raspberry Pi Pico W: https://learn.adafruit.com/pico-w-wifi-with-circuitpython/pico-w-basic-wifi-test