Comments on: Raspberry Pi Pico: Web Server (MicroPython) https://randomnerdtutorials.com/raspberry-pi-pico-web-server-micropython/ Learn ESP8266, ESP32, Arduino, and Raspberry Pi Thu, 14 Nov 2024 10:44:56 +0000 hourly 1 https://wordpress.org/?v=6.8.2 By: Sara Santos https://randomnerdtutorials.com/raspberry-pi-pico-web-server-micropython/#comment-983171 Thu, 14 Nov 2024 10:44:56 +0000 https://randomnerdtutorials.com/?p=144635#comment-983171 In reply to Luis.

Hi.
Your problem is probably one of the following:
– you don’t have a Raspberry Pi Pico W (you have the Pico version without the W—without network, so it doesn’t work). OR:
– you uploaded micropython firmware for the Pico (which doesn’t have Wi-Fi support), instead of the Pico W, with Wi-Fi support.
When uploading the firmware, make sure you select the right one.
Regards,
Sara

]]>
By: Luis https://randomnerdtutorials.com/raspberry-pi-pico-web-server-micropython/#comment-983159 Thu, 14 Nov 2024 10:09:35 +0000 https://randomnerdtutorials.com/?p=144635#comment-983159 Dear Sara:
Recently I have bought two Raspberry pi pico (original) not Chinese, well I have tried several times to install your RPIPIW Webserver in order to see how it works, well every try has been rejected with the “import network” instrucction, I have tried to solve installing the pluggin “network” in Thonny, and the the same result (f..y..!!), always network does not work( sh..!!). Solution the version of micropython in both microcontrollers is the latest micropython 1.24 and it does not work , I have read in https://forums.raspberrypi.com/viewtopic.php?t=359263 that version 1.20 works perfectly (https://github.com/micropython/micropython/releases/tag/v1.20.0). Well I will try to write the different steps of how to reinstall the software inside the Raspberry pi pico w, hope this lines will help ,also I have found something in order to run programs in the fake rpipw-esp8295 .
I am not going to surrender if I could make work an Esp01 this means nothing i only need the help of Madonna, Tears for fears, The cure, an U2 and will work.
Best regards
Visca Valencia
Luis

]]>
By: Michele https://randomnerdtutorials.com/raspberry-pi-pico-web-server-micropython/#comment-892183 Sat, 17 Feb 2024 06:24:34 +0000 https://randomnerdtutorials.com/?p=144635#comment-892183 In reply to Matt.

Here you are with a sample of thread in Raspberry Pico. It’s inspired by the one I took from the book issued by Raspberry Pi (free on line).
It’s the simulation of a traffic light where the lights on/off are controlled by the simple delay instruction and there is a button for the pedestrians to ask their right to cross the road. If we use one single core, it cannot capture the click on the button because the delay is “killing” the CPU for some seconds. If this task is transferred to the second core, it’s completely independent and the click can be seen immediately and stored to be managed after the light is switched off. Obviously this task is still a task of the first core which also switches a buzzer on to signal the pedestrian crossing. Good work!

from machine import Pin, PWM
import time
import _thread

ledRed = Pin(13, Pin.OUT)
ledYellow = Pin(14, Pin.OUT)
ledGreen = Pin(15, Pin.OUT)
button = Pin( 7, Pin.IN, Pin.PULL_DOWN)
buzzer = PWM(8)

global buttonClick
buttonClick = False

def thread_Readbutton():
global buttonClick
while True:
if button.value() == 1:
buttonClick = True
print(“Click”)

_thread.start_new_thread(thread_Readbutton, ())

while (True):
ledRed.value(1)
print(“Red”)
if buttonClick == True:
for i in range(20):
buzzer.freq(500)
buzzer.duty_u16(16000)
ledYellow.on()
time.sleep(0.25)
ledYellow.off()
buzzer.freq(100)
time.sleep(0.25)
buttonClick = False
buzzer.freq(20)
buzzer.duty_u16(20)
time.sleep(5)
ledRed.value(0)
print(“Green”)
ledGreen.value(1)
time.sleep(5)
print(“Yellow”)
ledYellow.value(1)
time.sleep(2)
ledGreen.value(0)
ledYellow.value(0)

]]>
By: Matt https://randomnerdtutorials.com/raspberry-pi-pico-web-server-micropython/#comment-889596 Fri, 09 Feb 2024 17:46:23 +0000 https://randomnerdtutorials.com/?p=144635#comment-889596 In reply to Sara Santos.

It would be great if you could put together a little tutorial on how to do multithreading. Perhaps you could redo this same project using two threads to show us how.

]]>
By: Emilio https://randomnerdtutorials.com/raspberry-pi-pico-web-server-micropython/#comment-889586 Fri, 09 Feb 2024 17:01:40 +0000 https://randomnerdtutorials.com/?p=144635#comment-889586 In reply to Jacques Vermaak.

You may want to take a peek here:
https://gist.github.com/aallan/3d45a062f26bc425b22a17ec9c81e3b6

]]>
By: Jacques Vermaak https://randomnerdtutorials.com/raspberry-pi-pico-web-server-micropython/#comment-889528 Fri, 09 Feb 2024 13:16:27 +0000 https://randomnerdtutorials.com/?p=144635#comment-889528 In reply to Michele.

I have tried that.
Using ‘import _thread’ and adding this line to my code ….

run main control loop on second processor

second_thread = _thread.start_new_thread(main_loop, ())
did work for just a few seconds and then things go south real fast.
According to the “_thread” documentation it seems like development is still in Beta phase.

I have managed to get the “uasyncio” going very well.
Need to import uasyncio

Have one function setup as follow
#############

Call web server handling

#############
async def phew_server():
server.run()
await uasyncio.sleep_ms(50)

Have a second function setup as follow
#############

Call Control section

#############
async def main_loop():
while True:

And right at the end of the python file the following
#############

MAIN

#############
event_loop = uasyncio.get_event_loop()
event_loop.create_task(phew_server())
event_loop.create_task(main_loop())
event_loop.run_forever()

Runs like a dream. No hangups or failures.

]]>
By: Sara Santos https://randomnerdtutorials.com/raspberry-pi-pico-web-server-micropython/#comment-889516 Fri, 09 Feb 2024 12:24:00 +0000 https://randomnerdtutorials.com/?p=144635#comment-889516 In reply to Michele.

Hi.
Alternatively, you can use asynchronous tasks using asyncio.
It works great. I’ve tried it already. Need to create a tutorial about that.
Regards,
Sara

]]>
By: Michele https://randomnerdtutorials.com/raspberry-pi-pico-web-server-micropython/#comment-888316 Mon, 05 Feb 2024 18:06:34 +0000 https://randomnerdtutorials.com/?p=144635#comment-888316 Raspberry Pico is a dual core processor. Use one for web server and the other for the logic

]]>
By: Sara Santos https://randomnerdtutorials.com/raspberry-pi-pico-web-server-micropython/#comment-888024 Sun, 04 Feb 2024 12:17:41 +0000 https://randomnerdtutorials.com/?p=144635#comment-888024 In reply to Michael B..

Hi.
Yes. You are right. You need a Pico W.
I added a note at the beginning of the tutorial mentioning that you need a Pico W, and that when we’re referring to the Raspberry Pi Pico, we mean a Raspberry Pi Pico W.

Thanks for pointing that out.

Regards,
Sara

]]>
By: Michael B. https://randomnerdtutorials.com/raspberry-pi-pico-web-server-micropython/#comment-887593 Fri, 02 Feb 2024 10:10:47 +0000 https://randomnerdtutorials.com/?p=144635#comment-887593 Hi Sara and Rui,
I have read several of your tutorials on the Raspberry Pi Pico and Raspberry Pi Pico W, but have no practical experience with either of these modules.
This tutorial constantly refers to the Raspberry Pi Pico, but my understanding is that none of this will work with the basic Pico. It will only work with a Pico W.
Perhaps you should update the tutorial to specify that a Pico W is essential and change all references from Pico to Pico W.

]]>