Connect to WIFI with Raspberry Pi Pico W

Table of Contents

Sample Code #

import time
import network

def connect_to_internet(ssid, password):
    # Pass in string arguments for ssid and password
    # Just making our internet connection
    wlan = network.WLAN(network.STA_IF)
    wlan.connect(ssid, password)
    # Wait for connect or fail
    max_wait = 10
    while max_wait > 0:
      if wlan.status() < 0 or wlan.status() >= 3:
      max_wait -= 1
      print('waiting for connection...')
    # Handle connection error
    if wlan.status() != 3:
       raise RuntimeError('network connection failed')
      status = wlan.ifconfig()
connect_to_internet('<your internet name>', '<your internet password>')

Powered by BetterDocs

Leave a Reply

Your email address will not be published. Required fields are marked *

Select the fields to be shown. Others will be hidden. Drag and drop to rearrange the order.
  • Image
  • SKU
  • Rating
  • Price
  • Stock
  • Availability
  • Add to cart
  • Description
  • Content
  • Weight
  • Dimensions
  • Additional information
Click outside to hide the comparison bar
What are you looking for in Partdo?
× How can I help you?