The GurgleApps staff is again with one other cool Raspberry Pi Pico W challenge: a Pico W-based net server. However this challenge does greater than serve net pages — it will possibly additionally run your Python code on the Pico W by way of an internet interface.
The net server is accessible by any machine with an internet browser, on a neighborhood or exterior community. The challenge is coded in MicroPython and at a primary degree it really works with two information. Wi-Fi configuration particulars are saved in config.py, and the challenge code is saved in essential.py (which MicroPython will autorun when powered on).
The intelligent a part of this challenge is the abstraction. Somewhat than lavatory the consumer down with complexities, the staff has created its personal webserver module (gurgleapps_webserver.py) which the challenge code imports and makes use of.
Abstracting code is an effective manner of getting customers comfy with a challenge / language earlier than pulling again the curtain to disclose the complexities of a strong language.
Picture 1 of 2
GurgleApps demonstrates the net server by bundling a challenge to regulate the Pico’s onboard LED utilizing a somewhat responsive net interface. Crafting a customized URL, superior customers can instantly entry the operate and management the LED. This superior method additionally returns a JSON object to the consumer, which, on this case, tells us the present delay (blinking on / off) of the LED and the LED’s present state. Different instance tasks embrace a frequency generator which was utilized in a Physics experiment to visualise vibrations in sand (or polenta). The frequency information can be displayed on a tiny OLED display screen.
The staff then goes into nice element on easy methods to create your individual capabilities which could be known as by way of the net interface. This element is what sells the challenge — utilizing not very a lot code we are able to create an internet interface for a robotic or see real-time sensor information in an internet web page.
The consumer interface is created utilizing HTML and CSS. These information are saved within the www listing of the challenge’s Pico obtain. Altering the graphics and format of the consumer interface can be a fast and straightforward job for many learners.
It’s nice to see the GurgleApps staff constructing one other simple-yet-powerful challenge primarily based round our favourite microcontroller. You may be taught extra in regards to the challenge by way of the GurgleApps weblog and discover the entire uncooked code this GitHub repository.