Connect with Wifi
To connect a Raspberry Pi Pico W to Thonny using WebREPL, you need to go through a few setup steps. WebREPL is an interface that allows you to access and interact with your MicroPython device over Wi-Fi. Here’s a step-by-step guide to set this up:
Prerequisites
MicroPython Firmware: Make sure MicroPython is installed on your Raspberry Pi Pico W.
Download the MicroPython firmware for the Pico W from the official site and follow installation instructions if needed.
Thonny IDE: Ensure you have the latest version of Thonny installed (Thonny version 3.3.3 or later supports Pico).
Steps to Connect Pico W with WebREPL in Thonny
Set Up Wi-Fi on the Pico W:
Connect your Pico W to your computer via USB.
Open Thonny and select the Pico W as your MicroPython device in Thonny:
Go to Tools > Options > Interpreter.
Set the interpreter to MicroPython (Raspberry Pi Pico).
Select the correct USB port where the Pico W is connected.
Write and run the following code in Thonny to connect the Pico W to Wi-Fi:
Run this code to confirm your Pico W can connect to Wi-Fi. The output should show the IP address once connected.
Enable WebREPL on Pico W:
Write the following code in Thonny to enable WebREPL:
You’ll be prompted to set a password. This is for securing your WebREPL connection, so choose a strong password.
Download and Install WebREPL Client on Your Computer:
Download the WebREPL client provided by MicroPython.
Open the
webrepl.html
file in a web browser.
Connect to Pico W Using WebREPL:
In the WebREPL client in your browser, enter the IP address of the Pico W (as displayed in step 1) and the password set in step 2.
Click Connect. You should see a REPL prompt if the connection is successful.
Connect Thonny to WebREPL:
Open Thonny and go to Tools > Options > Interpreter.
Set the interpreter to MicroPython (WebREPL).
In the WebREPL address field, enter
ws://<Pico_W_IP_address>:8266
(replace<Pico_W_IP_address>
with the IP address displayed in step 1).Enter the WebREPL password, then press OK.
Test the Connection:
You should now be able to run code on the Pico W via Thonny over Wi-Fi.
Try running a simple script like
print("Hello from WebREPL!")
to confirm the connection.
Troubleshooting Tips
Check IP Address: Make sure the IP address of the Pico W hasn’t changed after each reboot.
WebREPL Not Starting: If WebREPL doesn’t start, try restarting the Pico W and re-running the
webrepl.start()
command.Connection Issues: Ensure both the computer and the Pico W are on the same network.
This setup lets you interact with your Pico W over Wi-Fi, providing flexibility in working with wireless devices in MicroPython.
Last updated