Micropython Threads - Use Both Cores, on Raspberry Pi Pico and ESP32

preview_player
Показать описание
Did you know you're probably only using just half the power of your Raspberry Pi Pico or ESP32? Lets look at how to use Threads in Micropython; it's easier than you'd think.

🎖To join the membership at 🥉bronze, 🥈silver or 🥇gold levels, head over to

#Pico​ #MicroPython​ #Threads
Рекомендации по теме
Комментарии
Автор

sincerely thank you for making this video. your whole channel has taught me so much i needed to know

christianjensen
Автор

Love the analogy, sets things in order. Late to the dinner party, what a crowd!

paula.jackson
Автор

Oh boy! So glad I found this. I’ve just written my first threaded program. I needed to get input from a web form and use the entries to drive some peristaltic pumps (through a relay) for a set period of time. This FORTRAN 77 programmer is slowly getting his head round micro processors and Python. Fun stuff! I’ve subscribed and looking forward to learning a ton more from you.

martincregg
Автор

Hi Kevin. You seem to be talking about only a single thread running per core. That's a very simple implementation. In general we would be running multiple threads per core. And yes, there is no Realtime Operating System (RTOS) in place on the ESP32 & Pico, so there has to be thread handling code within the micropython interpreter and associated libraries. I believe this is implemented using the Asyncio library. Have you thought about doing a video covering Asyncio in micropython? That would be helpful.

christopherlyons
Автор

Best video for modern time processors/ controllers. was looking for using the triac firing which is in milliseconds and another loop for firebase databse. The asyncio was a bit complicated as the database request took some seconds and the triac waa in milliseconds turning on and off so the triac task(asyncio) was not giving up the control back to database loop time to time. Threading made it fun for me. Thanks from India.

KaushikYogesh
Автор

Really good presentation and explanation of threads. Thanks

himdimzma
Автор

You really are the best explaining this topic, thank you very much for sharing the knowledge.
Greetings from Argentina.

aldoercigoj
Автор

Thank you again, very clear and understandable video. I am working on IR receiver code where one core reads the TV remote control data and second core runs engines on my small robot. Thank you for your input ;)

Kris-cdqs
Автор

Thank you for sharing your knowledge with us. It gives me a great place to start with multi-threading.

stephencallaghan
Автор

Micropython on the esp32 supports multiple threads, but not multiple cores. All threads are run on the same core. The other core is dedicated to FreeRTOS.

derekanderson
Автор

Thank you very much for this video, it really helped me on my proyects, it was one of the missing parts I needed. Great tutorial :)

MrToy
Автор

an additional question: we can also use 'with mutex' at the beginning, which would do the acquire at the beginning and release at the end? It would be simpler in case we forget the 'release'? Many thanks

hanshaerdtle
Автор

Hey Kelvin, this video is superb, actually I didn't know esp32 can process close to 17 threads (due to being used to two threads in Pico). Am a big fan of your tutorials.

gathuaalex
Автор

Thank you man, is what I was looking for Excelente !!!!

aporfirio
Автор

Thanks for the great introduction. Just to understand correctly which part of the program is running on core 0 and which part on core 1? You could run the LED off with a second thread and have nothing in the main loop? Is the code in the main loop always running on a distinct core? Many thanks.

hanshaerdtle
Автор

ESP32 uses FreeRTOS natively, as an element of SDK. So you can can create as many threads you like, at least until you run out of resources.
Code executed on Raspberry Pi pico runs on bare metal. But nothing stops you from running FreeRTOS on one of the cores.

Atlantis
Автор

how about Raspberry Pi zero 2w ? Can it runs more threads??

m.preacher
Автор

Hey Kevin!

I really liked this informative video as well as your friendly demeanor and inspiring enthusiasm. Keep up the good work, and have a new subscriber - on me! ;-)

terjidjurhuus
Автор

Hi, great video!

If you connect to a WiFi outside a thread (RPi Pico W) will the thread be able to access the internet connection? I'm having trouble on this.

jorgee
Автор

Q What is the current status of thread support in MicroPython & the Pico? Do we still onky have the ability to create 2 tasks? And how does thread support contrast with using the asyncio library? Appreciate any answers you can provide.

christopherlyons