Built-in project · Raspberry Pi Pico W

MicroPython WiFi access point mode on a Pico W

MicroPython on a Raspberry Pi Pico W: network.WLAN(AP_IF) starts the board’s own access point and prints its name and IP settings. The whole build, a Raspberry Pi Pico W, runs here in your browser on the firmware below; open it in the editor to change the wiring or the code and run it again.

Teaching? Assign it to your class in one click.

Beginner About 10 minutes to build and run. Runs in your browser. Free, and no account needed.

The parts retail for about $6. On Mokxi they're free.

The circuit runs here once the page has loaded.

What you'll learn

  • Access point mode versus station mode
  • Setting a WiFi name and password with ap.config
  • Waiting for a network interface to come up
  • Reading the network settings with ifconfig
  • Difficulty: Beginner
  • Time: About 10 minutes
  • Board: Raspberry Pi Pico W
  • Parts: 1

How it works

Access point mode means the Pico W makes a WiFi network of its own instead of joining one. The script sets the name Pico-W-AP and the password 12345678, then turns the access point on.

It waits until ap.active() is true, then prints the network name and its settings, including the IP address. Every 10 seconds it prints whether the access point is still up. In the simulator nothing joins it.

Parts list

1 part, plus the jumper wires. They retail for about $6; on Mokxi they're free.

Kits that can build it

These 2 starter kits have every part in the circuit. Each kit's page lists what else it can build.

The code

The MicroPython code exactly as the editor opens it. Change a line there and press Run: the board runs it on the official MicroPython firmware, with nothing to compile.

main.py · Raspberry Pi Pico W
# AP mode on a Pico W: the board starts a network of its own and prints
# its settings. A phone could join it on a real board; in the simulator
# nothing joins, so the list of stations stays empty.
import network
import time

ap = network.WLAN(network.AP_IF)
ap.config(ssid="Pico-W-AP", password="12345678")
ap.active(True)
while not ap.active():
    time.sleep_ms(100)
print("Access point up:", ap.config("ssid"))
print("Settings:", ap.ifconfig())

while True:
    time.sleep(10)
    print("access point up:", ap.active())

Troubleshooting

The usual mistakes with this circuit, and the fix for each.

  • A phone cannot find the network This project
    In the simulator nothing outside it can join. On a real Pico W, the password must be at least 8 characters.
  • Pins are powered from 5 V, or a 5 V signal goes into a GPIO. The RP2040 pins are 3.3 V only and are not 5 V tolerant. Raspberry Pi Pico W
    Power the board from VBUS or VSYS at 5 V, but keep GPIO signals at 3.3 V. Use a level shifter or a divider for 5 V parts.
  • WiFi code fails to connect, or the on-board LED code does nothing. The LED on the Pico W is not on GP25 like on the plain Pico. Raspberry Pi Pico W
    Use the board's LED_BUILTIN name so the library drives it through the WiFi chip. Join a 2.4 GHz network only, with the right SSID and password, and wait for the link before sending.

Change it and keep it

Open it in the editor, change the circuit or the code, and keep your version in a free account.