In this hands-on lesson, students will learn how to set up a basic web server using the Raspberry Pi PICO W with CircuitPython. The server will serve a webpage that can be accessed from any device on the same network.
Imagine you're at a library, and you request a specific book. The librarian goes and fetches the book for you from the shelves. In the world of the internet, a web server acts like the librarian. When you type a website address into your browser, you're essentially asking the web server (our digital librarian) for a specific "book" or webpage. The server then "fetches" this page and sends it to your browser for you to view.
In this lesson, you will transform your Raspberry Pi PICO W into such a librarian! It will hold a webpage and deliver it to anyone who asks (or any device that connects to it). Just like a big server serving websites like Google or this website, but on a much smaller and simpler scale.
The Raspberry Pi PICO W is a tiny computer, not much larger than a coin, but powerful enough for our task. This version of the Pico comes with wireless capabilities, which means it can connect to WiFi. By the end of this lesson, your PICO W will be part of your WiFi network, and any device connected to the same network, like your phone or laptop, can ask it for the webpage and view it in their browser.
Let's dive in and set up our own mini-librarian!
First connect your Raspberry Pi Pico W to either:
To connect your Raspberry Pi Pico W to your computer, follow these steps:
Note: If you want to connect your Pico in USB mass storage device mode (so you can copy files to it), hold down the BOOTSEL button as you are connecting the USB to your computer.
To connect your Raspberry Pi Pico W to your iPad, follow these steps:
Depending on the device you are using, you will need to use a different editor:
Depending on the device you are using, you will need to use a different editor:
If you are using a PC or laptop, open your web browser and go to code.circuitpython.org
If you are using an iPad, download and install the Koder app from the App Store.
If you are using the CircuitPython editor (code.circuitpython.org) then we need to connect the editor to your PICO W so that we can transfer code to it.
You can skip this step if you're using an iPad.
To connect your editor (at code.circuitpython.org) to your PICO W follow these steps:
Your editor should now be connected to your PICO W and ready to code.
Create a new file in your chosen editor and with the name 'code.py'.
In your CircuitPython editor (code.circuitpython.org):
Note: the CircuitPython editor starts with a new file open and ready to go, so you might not need to do this.
On your Koder app: