Raspberry Pi Pico W - Super simple webserver

A super simple webserver written in MicroPython that serves up simple webpages and files from a pico w

Similar projects worth following
I wanted to share the code for a simple webserver using a raspberry pi pico W. I found it a little hard to find this example on the web, so here it is! I know CircuitPython has this feature, but I wanted to use MicroPython because I think the environment is a little leaner. Yes, you can serve up HTML and images using Micropython on your raspberry pi pico w. It was easier than I thought!

Please check out the instructions below and the Github files.

I made this with one main .py file, and included a simple html page and image that you can store on your raspberry pi pico w.

  • Small code update, and added a website example for XMLHttpRequest

    sciencedude199001/20/2024 at 17:42 0 comments

    I updated the code on github so that it will give separate error messages.  Now, it will give an error if the filename is bad, and it will give a separate error if the pico can't open and send the file (usually caused when the file is too large).

    I also added "led_website.html".  This demonstrates how to use XMLHttpRequest to set the LED on the raspberry pi pico, and has a timer that automatically queries the status of the LED to display on the website without having to refresh the page.

View project log

  • 1
    Setup the board and environment

    There are lots of good tutorials on the web, but here are the concise steps.

    Download the latest "uf2" file from MicroPython for raspberry pi pico w

    Download the "nuke" uf2 file from Adafruit, because if something goes wrong, you load this uf2 to restore the pico w and wipe any weird state (I'm looking at you, watchdog timer...).

    Connect your raspberry pi pico w to your computer while pressing the reset button.

    Drag and drop this file on the drive on the pico, and wait for it to reset.

    Install Thonny so you have an environment.

    Run Thonny, then use Run->Configure Interpreter, select MicroPython (Raspberry Pi Pico), and then select the correct Port for your pico w.

    Make sure you can see the local computer files, and the pico w files by going to View->Files.

    Now, you can place your HTML, images files, etc., in the "/" directory of the pico w.

  • 2
    Get the code from Github

    Head on over to github and download

    You can run this, or if you want it to run all the time, rename it so it can run without Thonny.

    You will need to create your own which has two variables, ssid - a string for the ssid name, and wifi_password, your password.

View all instructions

Enjoy this project?



Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates