009 - ESP32 MicroPython: Non-blocking Delays and Multi--threading

preview_player
Показать описание
In this video, we will learn to create a non-blocking delays in MicroPython which is very similar to millis funtion of Arduino. We will also expand the example creating a multi-threaded task demonstrating a multitasking routine.

For more details, visit my blog post at:

If you have any question regarding this tutorial, please write your concern in the comment box provided. Suggestions is also highly appreciated.

Please do Like, Share, and Subscribe.

Thank you,
George Bantique,
#TechToTinker
#MicroPython
#ESP32
#ESP32MicroPython
Рекомендации по теме
Комментарии
Автор

I was searching for this same solution. But I didn't know what to search for. Thanks for this great info.

I believe this method applies to Pi Pico too.

the_truth_seeker
Автор

These are honestly the best MicroPython tutorials on the internet thus far. These are comprehensive and really help me as I also teach MP. You really take the time to break down a subject and help me with ways to approach new students with your explanations.

mytechnotalent
Автор

This is clearly not multi-threading, per other comments. But worse, it's a busy-wait loop, meaning it'll consume far more power (as the CPU is running at 100% all the time). If you put a sleep(200ms) (your lowest interval) at the end if the loop you can get almost identical behavior w/ maybe 1/100th the power usage.

derekanderson
Автор

Hello from India .... Thank you very much for this easy to understand and very helpful tutorials about MicroPython... Best tutorials ever... Requesting you to make more MicroPython tutorials... Its very interesting language in the world of MicroControllers.... Subscribed to your channel.. Looking forward for more.

sameerk
Автор

Thank you so much brother its too much help me

abhishekkharge
Автор

I realy enjoy your tutorial, it is the best which i found until now. :-D

HektorDerHund
Автор

This concept is really great for single-core MCU to act like multi-threading, thanks

samirdjelal
Автор

It's just so GOOD! Very patient teaching!

bickyou
Автор

I totally agree with others, wonderfully explained. Could I make a suggestion. Why not use the enormously underutilized logical operator 'not'. You would replace 4 lines of code with just Simply replace your While block with below.
while True:
if time.ticks_ms() - start_time >= interval:
start_time = time.ticks_ms()
led_state = not led_state # not operator acts as a toggle on your variable
led.value(led_state)

much appreciated, Peter.

hermanish
Автор

The LED state IF construct can be entirely replaced with the more elegant "led_state = 1 - led_state" to toggle its value.

SpeccyMan
Автор

It looks like buttons do not ground the pin when pressed. They are pulled high, but pressing button does not ground pin or I can't see the wire in diagrams. I went ahead and put the ground wires to the buttons and it works but I have switch bounce. Otherwise I understand your steps, enjoyed and learned. Thanks

neilcampbell
Автор

Nice tutorial, pero this is not a real "Non blocking" nor "Multi-threading", pseudo lang yung nangyayari. The concept is just looping all throughout the code block but by storing the state of each led's time delay to blink and calculating the current timing, this will perform the specified code block if it matches the timing condition.
I doubt if this can be applied to a socket which constantly listens to a request. I'm still researching on that tho...

dummypg
Автор

Could you show how to use the multitherding?

HektorDerHund
Автор

This has notting to do with multi threathing.

jvdheyde
Автор

I am enjoying your videos about programming the ESP32 in MicroPython. I study your code in order to understand what it does, and I build some of the circuits to watch the code in action. I built the circuit in this lesson, and it works just as you designed. My question is regarding k_start and k_interval; what is their purpose? Thank you.

ImnotChuck.
Автор

You don’t know the concept of a “non blocking” delay. This example is a busy waiting example. NOT GOOD.

jvdheyde
Автор

You complete lost me in the last video #008. I followed #1-7. Here in #9 I'm doing better than #8. PLEASE remember you're dealing with beginners and explain each line of the code....even the obvious. Overall, you're doing a great job. Thank you for the videos.

gordonfrank
Автор

Just sent you an email with a quick question...

mytechnotalent
Автор

The use of global variables is a very bad programming practice NOT GOOD.

jvdheyde
join shbcf.ru