The Raspberry Pi Pico is a cheap microcontroller that many makers enjoy. You might ask, “Does the Pico have WiFi?” This guide helps you find out. We cover which models come with built-in wireless and how to set them up. You’ll learn to test your board for WiFi and get your device online.
What You’ll Learn
- Which Pico models come with wireless features.
- How to check your board for WiFi capabilities.
- Steps to connect your Pico W to a network.
- Code examples for wireless setup.
- Ways to troubleshoot common issues.
Pico Models and WiFi Features
The standard Pico does not have wireless features. It has a dual-core processor and many pins but no WiFi chip. In contrast, the Pico W includes a built-in low-power wireless chip. It uses a 2.4 GHz radio connection and has an extra antenna. The Pico W also has a slightly different LED placement, which ties into its wireless system.
Here’s a tip: A look at the label and antenna can help you tell the difference.
How to Check If Your Pico Has WiFi
You can tell if your board has wireless by using code. This is handy if you are building projects that work on both boards.
Using MicroPython
Try this MicroPython code to check your board:
import machine
from machine import Pin, ADC
def is_pico_w():
adc = ADC(3)
initial = adc.read_u16()
gpio25 = Pin(25, Pin.OUT)
gpio25.value(0)
low_val = adc.read_u16()
gpio25 = Pin(25, Pin.IN)
return low_val < 6553
if is_pico_w():
print("This is a Pico W with WiFi.")
else:
print("This is a standard Pico without WiFi.")
This code sets a pin low and reads the voltage. A low voltage reading shows your board is a Pico W.
Using Arduino
If you use Arduino, you can check like this:
include "hardware/gpio.h"
include "hardware/adc.h"
bool isPicoW() {
adc_init();
adc_gpio_init(29);
adc_select_input(3);
bool prev_dir = gpio_get_dir(25);
gpio_init(25);
gpio_set_dir(25, GPIO_OUT);
gpio_put(25, 0);
uint16_t val = adc_read();
gpio_set_dir(25, prev_dir);
return val < 500;
}
Example usage:
connect_to_wifi("Your_SSID", "Your_Password")
Connecting Your Pico W to WiFi
Once you confirm you have a Pico W, you can use MicroPython to connect to a network. The code below walks you through the process.
Setting Up WiFi in MicroPython
Paste this code into your script to join your WiFi network:
import network
import time
from machine import Pin
led = Pin("LED", Pin.OUT)
def connect_to_wifi(ssid, password):
wlan = network.WLAN(network.STA_IF)
wlan.active(True)
wlan.config(pm=0xa11140)
print("Connecting to " + ssid + "...")
wlan.connect(ssid, password)
wait = 10
while wait > 0:
if wlan.status() >= 3:
break
wait -= 1
print("Waiting for connection...")
led.value(not led.value())
time.sleep(1)
if wlan.status() == 3:
led.value(1)
print("Connected! IP: " + wlan.ifconfig()[0])
return wlan
else:
led.value(0)
print("Failed to connect!")
return None
Example usage:
connect_to_wifi("Your_SSID", "Your_Password")
In this snippet, the LED blinks while the board waits for a network handshake. A steady LED means the connection is made.
Operating Modes: Station and Access Point
The Pico W works in two modes.
Station Mode:
The board joins an existing network. It gets an IP from your router. This is perfect for projects that need online data.
Access Point Mode:
The board creates its own network. Other devices can join it directly. This mode is handy if you lack a router.
Here’s how to create an access point:
def create_ap(ssid, password=None):
ap = network.WLAN(network.AP_IF)
ap.active(True)
if password:
ap.config(essid=ssid, password=password, security=network.AUTH_WPA_WPA2_PSK)
else:
ap.config(essid=ssid)
print("Access Point active")
print("AP IP: " + ap.ifconfig()[0])
return ap
Activate an access point:
create_ap("PicoW-AP", "password123")
Setting a Static IP
Some projects need a fixed IP. Try this code to set one:
def connect_static(ssid, password, ip_config):
wlan = network.WLAN(network.STA_IF)
wlan.active(True)
wlan.connect(ssid, password)
while not wlan.isconnected():
print("Waiting for network...")
time.sleep(1)
wlan.ifconfig(ip_config)
print("Static IP: " + wlan.ifconfig()[0])
return wlan
Use these settings:
config = ("192.168.1.100", "255.255.255.0", "192.168.1.1", "8.8.8.8")
connect_static("Your_SSID", "Your_Password", config)
This example assigns a fixed IP so your project always uses the same address.
Frequently Asked Questions
Does the standard Pico have WiFi?
No, only the Pico W includes built-in WiFi.
How can I tell my board's type using code?
You can use the provided MicroPython or Arduino snippets to test your board.
What are the two WiFi modes?
In Station mode, the Pico joins a router network. In Access Point mode, it creates its own network.
Can I assign a static IP?
Yes, the static IP example shows how to set fixed network parameters.
What does the LED do during setup?
The blinking LED shows the board is trying to connect. It stays lit once the connection is complete.
Conclusion
This guide gave you clear steps to check and set up WiFi on your Pico boards. You now know the differences between models. You can use the example code to get your device online. Happy building, and share your success with us!
Try these steps and let us know how your project goes!