GurgleApps Raspberry Pi Pico Web Server Gives You Control From Any Device
GurgleApps Raspberry Pi Pico Web Server Gives You Control From Any Device
The GurgleApps team is back with another cool Raspberry Pi Pico W project: a Pico W-based web server. But this project does more than serve web pages — it can also run your Python code on the Pico W via a web interface.
The web server is accessible by any device with a web browser, on a local or external network. The project is coded in MicroPython and at a basic level it works with two files. Wi-Fi configuration details are stored in config.py, and the project code is stored in main.py (which MicroPython will autorun when powered on).
The clever part of this project is the abstraction. Rather than bog the user down with complexities, the team has created its own webserver module (gurgleapps_webserver.py) which the project code imports and uses.
Abstracting code is a good way of getting users comfortable with a project / language before pulling back the curtain to reveal the complexities of a powerful language.
GurgleApps demonstrates the web server by bundling a project to control the Pico’s onboard LED using a rather responsive web interface. Crafting a custom URL, advanced users can directly access the function and control the LED. This advanced approach also returns a JSON object to the user, which, in this case, tells us the current delay (blinking on / off) of the LED and the LED’s current state. Other example projects include a frequency generator which was used in a Physics experiment to visualize vibrations in sand (or polenta). The frequency data is also displayed on a tiny OLED screen.
The team then goes into great detail on how to create your own functions which can be called via the web interface. This detail is what sells the project — using not very much code we can create a web interface for a robot or see real-time sensor data in a web page.
The user interface is created using HTML and CSS. These files are stored in the www directory of the project’s Pico download. Changing the graphics and layout of the user interface would be a quick and easy task for most learners.
It is great to see the GurgleApps team building another simple-yet-powerful project based around our favorite microcontroller. You can learn more about the project via the GurgleApps blog and find all of the raw code this GitHub repository.