#149

  Переглядів 60,677

Ralph S Bacon

Ralph S Bacon

4 роки тому

An absolute beginners' introduction to dual-core processing using the keenly-priced ESP32 processor boards from Espressif.
Happy Birthday to PCBWay.com who are celebrating their 5th birthday all this month (June 2019)!
They want to share some goodies with you so visit
www.pcbway.com/anniversary5sa... and see what might take your fancy.
PCB Prototype the Easy Way - Full feature custom PCB prototype service.
$5 for 10 PCBs: www.pcbway.com/
All this and more on my GitHub:
github.com/RalphBacon/ESP32-D...
Boards entry: File -- Preferences
then click right down the bottom of the page to Additional Boards Manager URLs, to add this line:
dl.espressif.com/dl/package_e...
Wemos D1 Mini32 ESP32 as used in the demo.
Note, UK warehouse price same as China price but get it in two days!
bit.ly/2Wx5Cbd
An Arduino-sized ESP32 board (TTGO ESP32) with all the relevant pins marked up, I have one myself:
UK warehouse: bit.ly/2wKa5rI
CN warehouse: bit.ly/2K77Qrd
There are various TTGO ESP32 boards available, different formats, different prices, worth browsing before buying.
Other ESP32-related links:
Hardware design reference: public.robotical.io/Datasheet...
Getting started with the ESP32: docs.espressif.com/projects/e...
Nothing to do with this video, but I bought a dual solder reel holder, works like a charm and very solid. I'll show you this in a future video on SMD soldering:
bit.ly/2ZdlgFy
All this and more on my GitHub:
github.com/RalphBacon/ESP32-D...
If you like this video please give it a thumbs up, share it and if you're not already subscribed please consider doing so and joining me on my Arduinite journey
My channel and blog are here:
------------------------------------------------------------------
/ ralphbacon
ralphbacon.blog
------------------------------------------------------------------

КОМЕНТАРІ: 381
@peterheartfield8106
@peterheartfield8106 4 роки тому
Thanks Ralph. Great video, yes please do more.
@RalphBacon
@RalphBacon 4 роки тому
Thank you for your feedback, Peter Heartfield, noted and appreciated!
@GeekMustHave
@GeekMustHave 4 роки тому
Very nice video on running multiple threads on the two cores of the ESP32, I had no idea how but, now I do. Thanks. Keep broadcasting!!
@RalphBacon
@RalphBacon 4 роки тому
Thank you for your feedback, GeekMustHave, noted and appreciated!
@andymouse
@andymouse 4 роки тому
Hi, speaking of ESP32's an Australian UKpostsr who has a great channel called "The Unexpected Maker" has spent about a year designing a product called "TinyPico" Its as the name suggests a very small ESP32 development board, and I and many others have been watching the highs and lows of his design and thanks to crowd supply (and enormous effort on his part) is being shipped, I highly recommend that you have a look at his "TinyPico" as it really is feature packed, plenty of IO and he has a fully matched 3D antenna on there for outstanding WIFI performance. Take a look at his channel lots of interesting stuff....especially for ESP32's!
@RalphBacon
@RalphBacon 4 роки тому
And look I did, Andy, very interesting. I shall read (and watch) some of his videos when time permits. For others, here's the link: unexpectedmaker.com/tinypico
@george12121979
@george12121979 4 роки тому
very usable. in a very simple way how exactly the two-core system works in esp32. It is a very interesting field for applications of esp32 and would like if you can continue on this field.
@RalphBacon
@RalphBacon 4 роки тому
And continue I will, George! Stay tuned!
@libertywool
@libertywool 4 роки тому
Instead of doing delay(1) in your main Arduino loop, you can use taskYIELD() to let the scheduler know to go do other more important work (Ready tasks with a priority equal to or greater than your task). Because, as you mentioned, in Arduino the main loop is just called repeated from an outer method, the scheduler does not stop running that task unless we allow it (unless we are running the preemptive scheduler). So that will work for core 0, but not core 1. Now since the Arduino loop is running on core 1 with priority 1, calling yield will not work if your task is on core 1 with priority 0, as that is less than the current priority. So to make the task run on core 1, change the priority to 1 or greater. Then calling taksYIELD() will run the task on core 1. And this also takes me back to why delay(1) works. Delay is going to pause the current task (Arduino loop) and yield control to the scheduler. This will put the Arduino loop task into a blocked state (ie not Ready), so the scheduler will then run lower priority tasks (ie your core 1 priority 0 task). Hope that helps explain what you were seeing...
@vonries
@vonries 4 роки тому
I hate showing my stupidity so early in the game, but wtf? It sound very informative, but I have no idea what you're talking about.
@mikelopez9893
@mikelopez9893 4 роки тому
+vonries A real time operating system splits work into several tasks which share cpu time. Tasks can be in one of several states (blocked, ready to run, running). The system has a timer and the scheduler gets control each timer tick. It suspends the current task and switches to the highest priority task in ready state. The esp32 has two cores: protocol (#0) and application (#1). It runs a modified version of free RTOS. Each core has its own scheduler and the two cores are NOT synchronised. For example disabling interrupts on one will NOT disable interrupts on the other and does NOT protect data from corruption. Communicating across cores needs expert knowledge - lots of traps for young players! There is some good info on all this at docs.espressif.com Ps: the 8266 also has RTOS not just the esp32
@vonries
@vonries 4 роки тому
@@mikelopez9893 thanks, very cool.
@RalphBacon
@RalphBacon 4 роки тому
Since doing this video, Toby, I've been looking into this a bit. Yes, a typical British understatement if ever you heard one! *taskYIELD()* doesn't give the expected results, I'm afraid, as neither does *vPortYield()* which is what taskYIELD() expands to. Whilst we're on the subject, *yield()* doesn't do it either as that just calls vPortYield(). What I've discovered is that if we _really_ don't want to use the standard loop() then just execute a *vTaskDelete(NULL)* to get rid of it once and for all. Everything else just keeps running as expected. However, I've begun to use loop() as a "master" controller in some of my sketches that can control things (eg suspend/resume tasks, very useful) and keep a watching brief on what is happening. Task orchestration, if you will, which reminds me strongly of an event listener framework I developed for work using JavaScript. What goes round comes around... More of this and other stuff in a future video! Thanks for your input, Toby, you have a lot of experience in this area and your continued feedback is greatly appreciated. Nice to hear from you.
@mikelopez9893
@mikelopez9893 4 роки тому
Ralph S Bacon I think the issue is just priorities. TLDR - use priority 1. Here’s the espressif scheme: Priorities 10 to 14 are reserved for the system. For example, 14 is the watchdog timer, 10 is the TCP/IP stack. Priorities 1 to 9 are for general use. For example, WiFi events use priority 2. Priority 0 is the idle task. There are three ways a time slot can end. 1) it can voluntarily yield and the state goes to ready. 2) it can block waiting for something to happen - the state goes to blocked. 3) The time is used up - the state goes to ready. At the end of the time slot the scheduler takes the highest priority task in ready state and runs it. If several ready tasks have the same priority they are allocated “round robin” (but see caveat below) Caveat: the above is correct for the esp8266, but the esp32 does not have a complete multiprocessor implementation of free RTOS and can not guarantee equal round robin treatment across cores. I am concerned that you used priority zero which is reserved for idle. Essentially you are telling the system “nothing important to run here”. Hope this helps.
@anispinner
@anispinner 4 роки тому
So many details. Thank you, Ralph! Subbed, looking to more content on MC's and FPGA's.
@RalphBacon
@RalphBacon 4 роки тому
Thank you for your feedback, NLab, noted and appreciated!
@hmb2a
@hmb2a 3 роки тому
Thank you, Ralph. Not only the contents but also the effects of your video are excellent. Please continue.
@RalphBacon
@RalphBacon 3 роки тому
Thanks, will do! Well, once my house move has completed and I have a new workshop!
@TheZrpilot
@TheZrpilot 4 роки тому
Very much enjoy this and ALL your videos Ralph... would like to see more!! Thanks!!!!
@RalphBacon
@RalphBacon 4 роки тому
Thank you for your feedback, Max, noted and appreciated!
@OsoPolarClone
@OsoPolarClone 4 роки тому
Ralph another awesome video. I have seen other ESP32 videos but yours is the BEST! You did things I have never seen before. AWESOME!!!!!!
@RalphBacon
@RalphBacon 4 роки тому
Wow! I'm glad you enjoyed the video, Bruce. It's a subject that is interesting for quite a few people. I shall have to do at least one further video.
@neverendingrefit759
@neverendingrefit759 4 роки тому
Great stuff, and yes please, more like this! Lots blogs etc about esp blink but not so much dipping your toe deeper into the ESP32
@RalphBacon
@RalphBacon 4 роки тому
Thank you for your feedback, Boat data systems, noted and appreciated!
@bipolarchemist
@bipolarchemist 4 роки тому
I've never (knowingly) tried this for processes running on different cores, but you might be able to use a variable of portMUX_TYPE to handle synchronization between the cores. Any variables you plan to change between cores might need to be declared volatile and then you add some wrappers around the variables to you want to modify to keep them from being modified by various processes at the same time. // Declared globally portMUX_TYPE mux = portMUX_INITIALIZER_UNLOCKED; // In function to modify shared variables portENTER_CRITICAL(&mux); // modify/update variable here portEXIT_CRITICAL(&mux); This works great for interrupt handlers and might work with multiprocessor task as well.
@deangreenhough3479
@deangreenhough3479 4 роки тому
At work and yet to see. But boy, I’ve been waiting for this one. Well done Ralph😁🏴󠁧󠁢󠁥󠁮󠁧󠁿
@RalphBacon
@RalphBacon 4 роки тому
I hope your expectations were met, Dean, and stay tuned for further videos.
@BiggsWorld
@BiggsWorld 4 роки тому
I just found your channel, subscribed! Great video, I've been using esp32 for quite a while now and learned some new stuff. I like the teaching style too. I love these kinds of things that add to my knowledge! Bravo.
@RalphBacon
@RalphBacon 4 роки тому
Thanks for that, BiggsWorld, nice to hear from you. Thanks for subscribing too!
@davidharms3562
@davidharms3562 Рік тому
Still enjoying these videos Ralph! Keep up the great work, good sir! 👍🏻
@RalphBacon
@RalphBacon Рік тому
Glad you like them!
@paulyorke1437
@paulyorke1437 4 роки тому
I've been subscribing to your channel for a few weeks now Ralph. Excellent work and at a pace I can cope with. Brilliant. Just bought a couple of these ESP32s and started with your RTC sketch. Now can't wait for next episode re sharing variables between cores. Yes, more on the ESP32 please !!!
@RalphBacon
@RalphBacon 4 роки тому
Thank you for your feedback, Paul, noted and appreciated!
@Thomas72B
@Thomas72B 4 роки тому
Very interesting Video ! Please more videos about the ESP32 !
@RalphBacon
@RalphBacon 4 роки тому
Thank you for your feedback, Thomas, noted and appreciated!
@Trevor30926
@Trevor30926 4 роки тому
HI Ralph, very interesting video. I have just ordered a couple of boards. Please keep this type of video coming, The more the merrier.
@RalphBacon
@RalphBacon 4 роки тому
Thank you for your feedback, Trevor30926, noted and appreciated!
@heyok
@heyok 4 роки тому
Ralph, thank you for the time and effort you put into this as I really appreciate it. I always seem to learn something.
@RalphBacon
@RalphBacon 4 роки тому
Thanks for that, heyok, nice to hear from you.
@daviddoidge1252
@daviddoidge1252 4 роки тому
Excellent again, looking forward to more ESP32 videos
@RalphBacon
@RalphBacon 4 роки тому
Thank you for your feedback, David, noted and appreciated!
@la6mp
@la6mp 4 роки тому
Really good stuff, Ralph! It is nice to go a bit under the hood of devices we often use without knowing what they are really capable of.
@RalphBacon
@RalphBacon 4 роки тому
You are most welcome John, I'm glad you like the video. Nice to hear from you.
@michaelhyde9971
@michaelhyde9971 4 роки тому
Great video as usual. I was thinking about getting an esp32 now I will thanks :)
@RalphBacon
@RalphBacon 4 роки тому
Thank you for your feedback, Michael Hyde, noted and appreciated!
@stevehallam0850
@stevehallam0850 4 роки тому
Really good stuff, thanks Ralph 👍
@RalphBacon
@RalphBacon 4 роки тому
Thank you for your feedback, Steve Hallam, noted and appreciated!
@ytbone9430
@ytbone9430 4 роки тому
Thank you Ralph! o) I'm new to the microcontroller space and I really like your videos. The way you talk and present, it's very pleasant to watch and learn. I wouldn't mind more coding related videos. I am a software dev myself, but I have issues understanding on how to throw all the things together in loops/interrupts (say you want wifi, mqtt, config via webserver, read multiple sensors and drive a display with menu at the same time). Doing this on a microcontroller is quite different to desktop development, I surely have a lot to learn, thank you for getting me started. o)
@RalphBacon
@RalphBacon 4 роки тому
And I'm glad to have you along, ytbone! If you're a dev then programming the Arduino and similar µControllers is not going to be difficult. In fact, the ESP32, with its operating system, feels like home to me! Keep tuned for further videos...
@GRPZ66
@GRPZ66 4 роки тому
Excellent video. Keep them coming. Much appreciated.
@RalphBacon
@RalphBacon 4 роки тому
Thank you for your feedback, Guido Zijlstra, noted and appreciated!
@williammiller7543
@williammiller7543 4 роки тому
Another Great, Informative video. I'm starting to use the ESP32 and this background info is Very usefull.
@RalphBacon
@RalphBacon 4 роки тому
Thanks for your post, William, good to hear from you.
@timcallinan
@timcallinan Рік тому
Excellent Tutorial Ralph. Enjoying it
@RalphBacon
@RalphBacon Рік тому
Glad you enjoyed it!
@marinehm
@marinehm 4 роки тому
Ralph: Thank you so much for your videos! I bought my ESP32 when they 1st come out but at the time there was limited support. Now I feel confident I can load the board definitions into my IDE and press forward.
@RalphBacon
@RalphBacon 4 роки тому
Quite right, Nick, when I did my first video on the ESP32, I remember them being a bit temperamental. And support was hit and miss. Now though, 55 videos later, I too feel that they have come of age. Keep tuned for further videos...
@Ne555N
@Ne555N 3 роки тому
This tutorial is excelent!! Thank you very much for the effort you put into the video
@RalphBacon
@RalphBacon 3 роки тому
You're very welcome!
@willofirony
@willofirony 4 роки тому
Yeah, I like this sort of stuff. Brilliant vid, Ralph.
@RalphBacon
@RalphBacon 4 роки тому
Thank you for your feedback, Michael , noted and appreciated! Good to hear from you again!
@ianstubbington2334
@ianstubbington2334 3 роки тому
Great video for getting started with esp32. More please ;)
@RalphBacon
@RalphBacon 3 роки тому
Thanks, will do!
@noweare1
@noweare1 4 роки тому
Another worthwhile video. Count me in for more esp32 vids. As far as the speed difference ... that's just mind boggling.
@RalphBacon
@RalphBacon 4 роки тому
Yes, Joey, it took me by surprise, actually. I wondered what I had done wrong! I even include some debugging statements in the code and it whizzed through so quickly it was amazing. Amazing chip.
@magic.marmot
@magic.marmot 4 роки тому
Oh my, thank you so much! I work with FreeRTOS all the time on the professional side, and have some ESP-32 boards for experimenting and making new things at home. This gives me a whole 'nother level of being able to mix the two "under the hood", and has opened up a whole new bunch of ideas on how to meld the two.
@RalphBacon
@RalphBacon 4 роки тому
With your RTOS experience you should be quite at home with the ESP32 then, Rob. The Arduino-style implementation doesn't expose all RTOS functions but if you read the Espressif web pages they tell you what to edit in their implementation header files to add functions. You might even prefer the ESP-IDF development environment. docs.espressif.com/projects/esp-idf/en/latest/get-started/index.html Fun times ahead!
@robingiles399
@robingiles399 4 роки тому
What a great video, looking forward to more ESP32 videos, area of interest are around maximising power saving capabilities, this unit is great, Perhaps looking at the ESP-PICO-D4 as well..
@RalphBacon
@RalphBacon 4 роки тому
Thanks for that, ROBIN GILES, nice to hear from you.
@peut
@peut 4 роки тому
Very nicely done. Thank you. Please continue.
@RalphBacon
@RalphBacon 4 роки тому
Thank you for your feedback, Jose, noted and appreciated!
@jeffbluejets2626
@jeffbluejets2626 4 роки тому
As usual, great stuff. More thankyou.
@RalphBacon
@RalphBacon 4 роки тому
Thank you for your feedback, Jeff Bluejets, noted and appreciated!
@Ed19601
@Ed19601 4 роки тому
Just got myself a few esp32's so I will be revisiting this
@RalphBacon
@RalphBacon 4 роки тому
Yes, indeed, Ed, it's quite interesting what you can do with them.
@bhnienhuis
@bhnienhuis 4 роки тому
Very interesting, please continue
@RalphBacon
@RalphBacon 4 роки тому
Thank you for your feedback, Herman Nienhuis, noted and appreciated!
@tomwatzek3500
@tomwatzek3500 4 роки тому
Nice Video, thank you. I would be happy if you do another video an go more into detail. - like how to get variables from on core to the other.
@RalphBacon
@RalphBacon 4 роки тому
Thank you for your feedback, Tom Watzek, noted and appreciated! Variables from one _task_ to another (the core is irrelevant) is the subject of my next video, Tom. Oh, perhaps I should not have said that.. spoiler alert! Too late!
@John_Smith__
@John_Smith__ 4 роки тому
Oh yes, ESP32 is a great great platform ! We would all love to see inter-task communication ... passing arguments and data.
@RalphBacon
@RalphBacon 4 роки тому
Yes, that will be "interesting", John. Keep tuned. Thanks for posting.
@iHayri1
@iHayri1 3 роки тому
Hi Ralph, just wanted to thank you for your incredible videos, they are extremely informative, very easy to understand and to learn from with no nonsense whatsoever like annoying background music which always seems too loud and makes understanding difficult. Of course I subscribed and hit the bell, to not miss a single video. Btw, the ESP32 is my new found love and I intent to learn every bit if information about it. Already designed and have manufactured a CNC milled aluminum case that will go with my version of a 3.5" IPS display with capacitive touch and the required PCB of course. Anyway, sorry about the long comment. Happy Holidays and a great New Year, stay safe.
@RalphBacon
@RalphBacon 3 роки тому
Thanks so much for your kind words, Hayri. The ESP32 is indeed a wonderful device (not Revision 0 though!) and I am now reading up more on the freeRTOS and multitasking. Very powerful stuff which I will share in the New Year. Have a good one!
@iHayri1
@iHayri1 3 роки тому
@@RalphBacon That is the least I can do, wish I could do more to support you than just subscribing but I do have my own struggles :-) Nevertheless if you are interested in my new upcoming PCB with the ESP32 WROVER on it, or anything esle I work on for that matter, I will be glad to send you one as a gift to show my appreciation for your excellent work. Looking forward to see freeRTOS and multitasking examples. Be well.
@mav29
@mav29 3 роки тому
thanks mate, 2020 and still a great video
@RalphBacon
@RalphBacon 3 роки тому
Glad you enjoyed it! I want to do another on Timer Tasks, more efficient. It's on the list...
@mav29
@mav29 3 роки тому
@@RalphBacon we'll wait for it, And tonight I have decided to get me an esp32, thx haha BTW would it be possible to distribute load across 2 esp32 as processors while another is handling load distribution he he thx
@mav29
@mav29 3 роки тому
@@RalphBacon im back sir, i just recieved my ESP32 today and im going to test it using your examples yaaayyyyyyy! cheers!
@mksmurff
@mksmurff 3 роки тому
Just found this. Brilliant. Earned a sub
@RalphBacon
@RalphBacon 3 роки тому
Thanks, DannyK, welcome aboard.
@patrickmaartense7772
@patrickmaartense7772 4 роки тому
yes please more of this !
@RalphBacon
@RalphBacon 4 роки тому
Thank you for your feedback, patrick maartense, noted and appreciated!
@vincenttang9059
@vincenttang9059 3 роки тому
Very Useful for me, thank you for your sharing :)
@RalphBacon
@RalphBacon 3 роки тому
Glad it was helpful!
@ayganotomasyon1109
@ayganotomasyon1109 Рік тому
Thats what i m looking for. Thank you.
@RalphBacon
@RalphBacon Рік тому
Glad I could help!
@ElieWar
@ElieWar 4 роки тому
Thank you, yes more, plz
@RalphBacon
@RalphBacon 4 роки тому
Thank you for your feedback, Elie, noted and appreciated!
@originuk
@originuk Рік тому
Just quickly browsing through your tutorials - love what your're sharing! Multi-threaded stuff works fine when working with unique pins ... when using separate tasks to do stuff concurrently over the I2C or SPI bus, obviously needs resource locking... you may have mentioned this, already so apologies if you have. Great to see simple examples.
@RalphBacon
@RalphBacon Рік тому
Yes, semaphores and mutexes can lock resources but that's no use if the GPIO pin you want to share is already in use with a peripheral! Imagine some part of your program interrupting an SPI packet!
@maxpenfold8699
@maxpenfold8699 3 роки тому
What a great Video, thanks!
@RalphBacon
@RalphBacon 3 роки тому
Glad you liked it!
@abpccpba
@abpccpba 4 роки тому
Thanks yes more on ESP32 👍
@RalphBacon
@RalphBacon 4 роки тому
Thank you for your feedback, Paul C Johnson, noted and appreciated!
@sortofsmarter
@sortofsmarter 4 роки тому
This is soooooo cool....I have like 3 of these boards...late night aliexpress shopping..lol and needed lots of help to really understand what in the heck I got into and how to use them.....Andreas Spiess is good but a little to advanced for my newbie abilities....Thanks
@RalphBacon
@RalphBacon 4 роки тому
Thanks for your post, Gene, good to hear from you.
@bryanethier1910
@bryanethier1910 4 роки тому
Excellent vids
@RalphBacon
@RalphBacon 4 роки тому
Thanks Bryan, glad you liked this one!
@wires4auto
@wires4auto 4 роки тому
Fantastic! Ralph. I think this should be the second microcontroller board newbies get, the Delay fuction is so evil to beginners, and can hold them back. I would really like to see more of this board in the Arduino IDE, using Bluetooth fuction and passing information between the two cores. Thanks again.
@RalphBacon
@RalphBacon 4 роки тому
Thank you for your feedback, gordon, noted and appreciated!
@GabrielAlves-mf8vd
@GabrielAlves-mf8vd 4 роки тому
Amazing tutorial!
@RalphBacon
@RalphBacon 4 роки тому
You are most welcome Gabriel, I'm glad you like the video. Nice to hear from you.
@rzinindiana8029
@rzinindiana8029 3 роки тому
As usual... clear and important info... TX
@RalphBacon
@RalphBacon 3 роки тому
Glad it was helpful!
@EmbSysDev
@EmbSysDev 3 роки тому
Very , very nice into to ESP32 !
@RalphBacon
@RalphBacon 3 роки тому
Thanks!
@JohnTinic
@JohnTinic 4 роки тому
i love the esp. i avoided arduino wherever i could. just used it to flash my printer 😂 great video with onpoint informations thx👍
@RalphBacon
@RalphBacon 4 роки тому
You are most welcome John, I'm glad you like the video. Nice to hear from you.
@abboberg987
@abboberg987 4 роки тому
Today i learned a lot; ESP32 has 2 cores and we can use it! Thanks Ralph
@RalphBacon
@RalphBacon 4 роки тому
We can use two cores with care, André, as you will hear in my next video. Multitasking is a great liberator and at the same time a minefield. Keep watching!
@dekipet
@dekipet 4 роки тому
Neat one. Thank you.
@RalphBacon
@RalphBacon 4 роки тому
You are most welcome Dejan, I'm glad you like the video. Nice to hear from you.
@dekipet
@dekipet 4 роки тому
@@RalphBacon ESP32 has so much to unveil. Just to mention chips ID, touch sensor, temperature sensor, etc. It would be nice to someone take all of that, all of connectivity and make a nice video, or blog article. I am planning to put it on a magazine article i write for. Time is all i don't have. Damn...
@RalphBacon
@RalphBacon 4 роки тому
I'm starting a petition for the UK government to create a 30-hour day to give me more time to do the stuff I need to. Sounds like you will be the first signatory! Yes, I'll get round to the ESP32 features, I hope, in due course, if only I had more time. Oh, I have a feeling of deja vu...
@chetanyasaxena8082
@chetanyasaxena8082 4 роки тому
Great Video, very informative. Keep up the good work sir BTW new sub. Please make more ESP32 Videos.
@RalphBacon
@RalphBacon 4 роки тому
Thanks for your post, Chetanya Saxena, good to hear from you and thanks for the sub. You are most welcome.
@michaelbyron9688
@michaelbyron9688 4 роки тому
Ralph, AWESOME video. The ESP32 is the processor to use today. how about a video on the sharing of variables between the two processors, going both ways.
@RalphBacon
@RalphBacon 4 роки тому
Hmm, I wonder what could be the topic of my next-but-one video, Michael, I wonder... Nope, can't figure it out. We shall just have to wait and see.
@paulrichmond6903
@paulrichmond6903 4 роки тому
Great video.
@RalphBacon
@RalphBacon 4 роки тому
Thanks for your post, Paul Richmond, good to hear from you.
@georgestewart5879
@georgestewart5879 4 роки тому
Yes some more please.
@RalphBacon
@RalphBacon 4 роки тому
Thank you for your feedback, George, noted and appreciated!
@datho-cq1ez
@datho-cq1ez 3 місяці тому
I am a student come from Viet Nam, this is a excellent video, thank you because share this topic.
@RalphBacon
@RalphBacon 3 місяці тому
Glad you enjoyed it! Thanks for posting!
@JulianMakes
@JulianMakes 4 роки тому
lovely tutorial thanks :)
@RalphBacon
@RalphBacon 4 роки тому
You are most welcome Julian HG, I'm glad you like the video. Nice to hear from you.
@oncledan282
@oncledan282 2 роки тому
Hey! Ralph. I just looked at your video and I will try this tomorrow (it’s past 1AM for me, now). Thanks for this tutorial. 160 times faster ?? Really ?? It just might solve my flickering problem but I’ll try to get the TFT working first, then, the GPS. I’ll give you updates soon (via mail) Happy new year .. Talk to you soon !
@RalphBacon
@RalphBacon 2 роки тому
Talk soon! Don't be a stranger!
@kennmossman8701
@kennmossman8701 4 роки тому
MORE please sir!
@RalphBacon
@RalphBacon 4 роки тому
Ooh, that's enthusiastic, Kenn! I was just thinking (always dangerous) the other day about multitasking on this chip. We will have to see whether all that Deep Thought comes up with new videos.
@kennmossman8701
@kennmossman8701 4 роки тому
@@RalphBacon Use one core per task? Or virtual multi-tasking?
@robinvanleeuwen1911
@robinvanleeuwen1911 Рік тому
Yeah I like to see that sort of stuff (multicore programming on ESP32)
@RalphBacon
@RalphBacon Рік тому
Yes, multicore vs multitasking is quite different though, so keep tuned.
@henrikjensen3278
@henrikjensen3278 4 роки тому
Interesting video, I have played a bit with the ESP32, but have not studied it and did not know it had a RTOS. With a RTOS it means you could run both your task on the same processor, you do not need to distribute it on two processors to run them in parallel. One big advantage for ESP is 32 bit architecture, it means anything but byte variables will be faster on it by more than the clock speed. The speed increase in your test was insane, there must be many factors to get that much. One detail I did find out about the ESP32 is that programs are stored in a serial memory and it will use a serial protocol to read the program. This reading is fast, but much much slower than the processor, it uses a internal cache to prevent much delay while running the program.
@RalphBacon
@RalphBacon 4 роки тому
Shh, don't spoil my next video on parallel task, Henrik! Yes, of course you can run multiple tasks on a single core, and as RTOS is running WiFi and BT tasks (among others) on Core 0 it's probably wise to treat core 0 with serious respect (memories of watchdog resets come to mind when I was coding my ESP8266 deice). You are correct about busses of any kind slowing down the processor - caching helps of course, but there's a limit and my first video #95 of the ESP32 driving a MAX7219 display was _very_ slow (caused by the stupidly slow I2C - or was it SPI? - bus setting). Anyway, great to hear from you, more in a future video!
@henrikjensen3278
@henrikjensen3278 4 роки тому
I am looking forward to more videos about ESP32, a good youtube video is a fast way to learn stuff. It looks like the ESP32 has some limitations on real time response, due to the RTOS, what I mean is that you have to handle a lot of stuff with RTOS calls, not directly. This means lots of clock cycles slower. You can check my projects about "computer controlled ..." stuff to see what I mean: lygte-info.dk/project/indexProjects%20UK.html A RTOS calls will probably mean that the ESP32 will not be faster than a old style Arduino to setup the function (Bad description, what do you call programming multiple times simultaneous), but when running it will have better precision. When I get better acquainted with the ESP32 (or any ARM CPU) I may redo the above boxes, but for now they work very well.
@GilchristMcGill
@GilchristMcGill Рік тому
Thank you.
@RalphBacon
@RalphBacon Рік тому
Most welcome, Gil
@mikelopez9893
@mikelopez9893 4 роки тому
Nice video, but it might spread some misunderstanding about multi-core and RTOS. Note that RTOS can run multiple tasks on a SINGLE core. Pro tips: 1) Keep your tasks on core 1 and leave core 0 for Wifi etc 2) Use priority 1 or higher for tasks. Leave priority 0 for the “idle” task. 3) Use core affinity with caution! There is a good tutorial on free RTOS at www.freertos.org/tutorial. Keep up the good work. I always enjoy your videos.
@deangreenhough3479
@deangreenhough3479 4 роки тому
Mike Lopez thank you Mike, that’s great additional Information and appreciated. 👍🏴󠁧󠁢󠁥󠁮󠁧󠁿
@RalphBacon
@RalphBacon 4 роки тому
What you say, Mike, is of course 100% correct but I had to think of a way of presenting this clearly and using both cores was (I felt) a good way. I have other sketches that use the same core (or even switch cores) but that's for another day (if this video is received well). In general use, though, tasks should leave core 0 alone as much as possible to let WiFi and BT have their dedicated space to run. I'm a little disappointed that not all RTOS commands are available to the Arduino and the configuration files that control what is and isn't can be a veritable minefield. I'll keep it simple and in line with what my viewers will use most! It's an amazing device though, at an equally amazing price, and will probably convert me away from my current chip-of-choice, the ESP8266 but which doesn't have enough pins for me! I'll put your link in my GitHub if you don't mind, that's a good resource, thanks for the heads-up, appreciated.
@Graham1904
@Graham1904 4 роки тому
Well presented esp (pun) ially for a newbie like myself
@RalphBacon
@RalphBacon 4 роки тому
Groan. Almost a pun, anyway, Graham! Glad you liked the video!
@robertnovak1602
@robertnovak1602 4 роки тому
Hi Ralph, I really enjoy watching your videos, so thank you for sharing. The reason that putting nothing in loop() would result in your program doing nothing is because a "function" is just a location in memory which happens to contain instructions. Those instructions are generated by the compiler. If your function doesn't have any instructions, it would be effectively just a "jump" and "return", or possibly a "call" instruction (in fancier instruction sets). Basically, because the function doesn't have any content, when it generates the binary/executible, since it is optimizing for space, it most likely doesn't include that function, or won't provide an actual definition for it (different compilers and different optimization profiles will do different things, so I can't say precicely what it will do). Keep up the explorations, like I said, I really enjoy them.
@RalphBacon
@RalphBacon 4 роки тому
Yes, it's unclear whether the compiler would optimise an empty loop away (you would hope it would) and if so the task handler could not start the expected (default) loop task. That might crash the chip I suppose. I've just deleted the task in other sketches if I don't want the default loop(). Thanks for posting, Robert, good to hear from you.
@robertnovak1602
@robertnovak1602 4 роки тому
Depending on how obsessive you want to be, you can take a look at the ELF binary that gets generated, and see exactly what's getting created. It's not something I really enjoy doing, but it is usually enlightening. A very quick way to verify without looking at the binary itself would be to look at the size of the resulting binary with and without the delay added to loop(). If there's a massive size difference, you can be reasonably sure that the compiler is simply optimizing away most of the program. My thought would be that if loop() didn't contain any instructions, not only would the compiler remove the "call loop()" instruction, but it in theory should (being that it's C) optimize away most of even the basic wrapper program. Perhaps an example might illustrate: Suppose the "wrapper" program looks like: void main() { setup(); while(1) { loop(); } return; } if loop() is empty, that goes away, and the compiler is left with an additional empty while(1) loop. This also should get optimized away, and thus main() would become: void main() { setup() return; } resulting in the board not crashing per-se, it just essentially finishes the entirety of the task. anyway, I'm just some dude on the internet so feel absolutely free to take with a grain of salt.
@RalphBacon
@RalphBacon 4 роки тому
I'm thinking that the ESP32 (RTOS) would start the task handler for specific tasks (one of them being loop) but if the loop did not exist it may do weird and wonderful things. Eventually we will find out, I'm sure.
@michaelbishton9439
@michaelbishton9439 4 роки тому
I've programmed a bit in other languages pre-IoT and am transitioning to the world you reflect here. I really like your clear and thoughtful approach to explaining things. I know (perhaps) just enough to see that you are using functions with parameters that pass information. May I suggest that when you use a function (like xTaskCreatePinnedToCore), you include a link to it's library that lists all of the functions, parameters, and what they do? That way, advanced beginners like me can more quickly build on what you teach without trying to find the libraries you are already using. I've used Adafruit tutorials that show functions with links to (what looks to me to be) partial libraries or incomplete explanations, which limit their functionality. Many thanks!
@RalphBacon
@RalphBacon 4 роки тому
Point taken, Michael, although in this case it's not so much a library as an entire operating system Free RTOS. It's been modified, somehow, by Espressif for this chip (not sure of the differences) but RTOS is well documented and there's a downloadable Reference Manual pdf too: www.freertos.org/Documentation/RTOS_book.html I hope this helps!
@michaelbishton9439
@michaelbishton9439 4 роки тому
@@RalphBacon Thank you very much, it does. Please keep doing that so that people can look up the full list of functions.
@rodneytapit5636
@rodneytapit5636 Рік тому
Thanks for this tutorial Ralph, it works for me. I would be very interested to know more about semaphores and mutex for the ESP32 - perhaps you have already made another video on the subject? Also, if I'm using wifi, async. server and client libraries what core would they be running on by default?
@RalphBacon
@RalphBacon Рік тому
Wi-Fi runs on Core 0, along with BT and any other Espressif code. Your code should all run on Core 1. If you place any code on Core 0 you run the risk of it causing a PANIC on Core 0 as it is _very_ sensitive to any delays. I can't remember whether my video #151 (ukposts.info/have/v-deo/saeTpWeoiWOXumQ.html ) dealt with semaphores / mutexes - I'll leave it for you to check!
@rodneytapit5636
@rodneytapit5636 Рік тому
@@RalphBacon Video #151 explains a lot of the finer detail, very good thank you. I wonder how 'sensitive' the single core ESP8266 is when it comes to WiFi operation and the user code delaying WiFi operations.
@oncledan282
@oncledan282 4 роки тому
Hey, Ralph!I I thought, since that time I got my ESP32 from China, I might as well give it a go and see how to program this li'l wonder. 2 cores seems a nice things to have and I'm glad the use of these cores are very common to yours in my way of thinking .. and a bunch of GPIOs too, although not all of them ore broken out on my Board. I got the ESP32 Development board, from DOIT (or rather, a very nice clone, may I add). I downloaded the board specifics and driver from GitHub and I THINK it's working. I say « I THINK » because the IDE does not seem to see the board as far as the com port is concern. I'll seek other videos to see if I should connect this board via FTDI or if I can program it via the microUSB port, just like the Arduino boards. To be followed .. On that, a few days from the New Year, I wish you all the best for 2020. Talk to you soon, my Friend !
@RalphBacon
@RalphBacon 4 роки тому
Happy New Year Daniel! The question is, does your PC see the COM port of the ESP32? You can use the USB socket just as on an Arduino to upload sketches etc and get back serial messages. Make sure you have selected the correct board from the long list.
@billw2976
@billw2976 3 роки тому
Ralph, thank you very much for you videos and especially for the time you have dedicated to the world of Arduino. May I ask, of you, what program did you use for programing? You said the name during the first part of the video but I was not able to get the name clear enough to do a search for it. It looks like a very interesting system for programing Arduino type processors. Thanks again, Bill in Oklahoma, USA.
@RalphBacon
@RalphBacon 3 роки тому
I use the Eclipse (Sloeber) version but wait for the new Arduino IDE later this year, Bill. It's based on the same Eclipse setup so should be very good.
@jofie2302
@jofie2302 3 роки тому
You should also consider using the "Visual Studio Code" IDE in combination with PlatformIO. It provides Intellisense/command completion, a nice outline, a header file per project remembering things like board type and details, etc.
@foxabilo
@foxabilo 4 роки тому
Yea, I like this sort of stuff
@RalphBacon
@RalphBacon 4 роки тому
Thank you for your feedback, foxabilo, noted and appreciated!
@foxabilo
@foxabilo 4 роки тому
@@RalphBacon Just been chatting with Andreas Spiess on the platform.io JTAG debug feature western digital has just given everyone for free, about to test the ST-Link V2 with the ESP32 and the Atom editor to see if the maker space can get dirt cheap jtag debugging. Seems the ESP32 is making a resurgence in popularity for all things IOT and a whole bunch of new cool things and toys, really exciting time to be getting to know this cheap abundant powerful hardware. Hope you have a great time with it all and I hope the channel grows well, solid walkthrows of interesting stuff are always a great resource to link to when explaining something to someone just starting out.
@RalphBacon
@RalphBacon 4 роки тому
So, just to clarify, will JTAG debugging allow single stepping of code, or how does it work? I've used MS Visual Studio for years and was spoiled by this feature (impossible to debug enterprise level code otherwise). If the ESP32 allows it... well, I'll await your response first.
@foxabilo
@foxabilo 4 роки тому
@@RalphBacon I am in the breadboard and rats nest phase of finding out, platformio says it supports multi threaded debugging, I'll let you know how that works once i put all this magic smoke back in ;)
@foxabilo
@foxabilo 4 роки тому
So first update, this is specifically regarding the STLink32 V2 and clones, if you set the debug_tool = stlink then you get a compile time error of "DebugInvalidOptions: Unknown debug tool `stlink`. Please use one of `esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa` or `custom`:" I am going to have a scout round the net to see if it is possible to use the "custom" option to set up for use with the STLink if not I will have to order one of the ESP-Prog boards or look at the JLINK clone project as I doubt anyone has £600 floating about to debug a blink led project ;)
@binhphuoc2971
@binhphuoc2971 2 роки тому
Hello Ralph, thanks for your video. I learned quite few new things by watching it. I bet other videos of yours are no less excited. BTW: What is the IDE you're using at 16:29?
@RalphBacon
@RalphBacon 2 роки тому
Glad it was helpful! I was using the Eclipse Sloeber IDE but as support for it has ceased I now use PlatformIO on Visual Studio.
@binhphuoc2971
@binhphuoc2971 2 роки тому
@@RalphBacon Thanks. I'm using PlatformIO as well.
@magic.marmot
@magic.marmot 4 роки тому
I've watched this again tonight, and have gained even more from it. I have to ask: does the Arduino IDE/library allow you to create multiple tasks on a single core?
@micultimy91
@micultimy91 4 роки тому
It's called multi-threading. it's actually pseudo-multitasking because the mcu is a serial processor is going to perform a little bit of each task you gave it to, in order to give you the appearance of multi-tasking
@RalphBacon
@RalphBacon 4 роки тому
My next video on the ESP32 shows this but you can try just by changing the core parameter on those tasks in this demo. Works as you would expect. If you don't specify a core to run on, then the task scheduler will allocate work to a core as it sees fit. there's much more detail here: www.freertos.org/implementation/a00005.html
@therealblujuice
@therealblujuice 4 роки тому
Yes!!! Please!!! Esp32
@RalphBacon
@RalphBacon 4 роки тому
Thank you for your feedback, Justin, noted and appreciated!
@gazzacroy
@gazzacroy 2 роки тому
wow i mite get a few of these to try :) cool :)
@RalphBacon
@RalphBacon 2 роки тому
Yes, go for it, cheap and will keep you amused for months.
@JerryEricsson
@JerryEricsson 4 роки тому
Believe it or not, I actually have a wonderful use for your initial duel blink program, it will solve a problem I have been tinkering with for over a year now! You see I am a retired police officer, a few years back, my good wife of 50 years gave me one of those old model's of a 57 Chevy. Now back in 69, we drove a 57 Chevy out to Minnesota for our first year of married life, so it was that, I believe that she homed in on. That said, the model was painted the black and white of a police vehicle of that era, so I wanted to build and mount a small light bar that I could turn on to have the model be in pursuit whilst sitting atop my TV Stand. I have it working, but not right, I do have the wig-wag of the blue and red lights working right but the amber caution light in the rear window has to flash in conjunction with one of the overhead lights. This is not the way they really worked, in the old days when I began police work, the overhead lights ran by chain drive, the bulbs were aircraft landing lights, and the rear flasher ran off a simple flasher like a turn signal and the bulb was a simple stop light bulb from a car, I believe it was an 1157 if memory serves. So, you see, I can now have one core run the wig-wag overhead and the second do the caution amber, should work great once I replace the Nano with an ESP32! Sure in the future, I may try and program it so I can turn on the lights remotely from my laptop, that would really be cool, yes I think I will try and program it to do just that!
@RalphBacon
@RalphBacon 4 роки тому
You can certainly do it like this, Jerry, but I would caution you against using Core 0 (too much). Just put all your tasks on Core 1 and it will work wonderfully well without upsetting WiFi and BT that runs (behind the scenes) on Core 0. I'll explain all this in a couple of weeks in a new video but given what you are describing is probably 2 or three "blink" programs this will do for now!
@michaelbyron9688
@michaelbyron9688 4 роки тому
Consider using the Parallax 8 core "Prop" microcontroller. it is easy to use and ideal for concurrent programming. it can be programmed in C or in SPIN a very very easy to learn language.
@majidabdaly7993
@majidabdaly7993 2 роки тому
Nice
@RalphBacon
@RalphBacon 2 роки тому
Thanks, Majid!
@inferno6012
@inferno6012 4 роки тому
nice
@RalphBacon
@RalphBacon 4 роки тому
You are most welcome inferno 601, I'm glad you like the video. Nice to hear from you.
@tedmoga4797
@tedmoga4797 3 місяці тому
I plan to use both cores in the ESP for a project I am working on. I want to use core 0 to read wav file data from an SD card and play it using I2S, and provide the audio frame that is being played to core 1. To keep a program running some code from the SD card to move some servos in syvn with the audio. So I have been looking on information how to get this all working. When I read your comments “To be honest, I would not use two cores to do this. Use two tasks instead, of equal priority (ie keep them at 1) on core 1. That way you won't upset either the BT, Wi-Fi or other system function running on Core 0. “ and “It is true - to an extent. Putting some simple tasks on Core 0 won't make it unstable as long as you "yield()" control back to the other tasks fairly frequently. That said, putting an intensive task on Core 0 is not a good idea - keep those for Core 1 (which is where your "loop()" runs) “ After reading some of your comments, I thought the ESP32 will not work for my project so I looked around and I found information that said if you do not enable the WIFI or the Bluetooth the code will not be running? esp32.com/viewtopic.php?t=31169 Some comments said if you do not include it in your code it will not run, “This is nuts. Don't initialise it. There's nothing to stop. “ I think this might be right, but I will have to look into it more. But it makes sense If you do not include WIFI in your sketch why would the code run?
@RalphBacon
@RalphBacon 3 місяці тому
If you don't invoke Wi-Fi (on Core 0, as you say) then no Wi-Fi code will run. So your Core 0 can be used more like an App core (but there may be other stuff running on Core 0 that is sensitive to delays). If you get a PANIC on Core 0 you know you have crossed the line. Good practice would state that, usually, we should leave Core 0 to do all the Espressif things (including Wi-Fi, BT et al) and use Core 1 for our app. But, like all good rules, they are made to be broken now and again!
@vonries
@vonries 4 роки тому
Great video as always Ralph! I see a lot of yes please do more esp32 videos and not a single one that says no thank you go back to only doing the arduino. I'll add my vote for doing more esp32 videos please. I wonder if you turned off the bluetooth and wifi if it would run your test program even faster. If they were needed, I would think they could be turned back on to publish the results. Like publishing the numbers to a webpage etc.
@RalphBacon
@RalphBacon 4 роки тому
I don't think you would see a speed increase if WiFi and BT were switched off, Steven, because they run on Core 0 (behind the scenes) and we were running that Prime Number nonsense purely on Core 1 - and the two are completely independent. In fact, running a duplicate task on Core 0 could have caused a processor reset if the WiFi or BT tasks were starved of CPU cycles - you have to tread very carefully when using Core 0. OK, more videos on ESP32 is what I hear. Keep tuned!
@vonries
@vonries 4 роки тому
@@RalphBacon oh I thought you had it doing multicore processing.
@jenniferw8963
@jenniferw8963 Рік тому
Hah, I hadn't yet finished the video yet and was going to ask if this supported "semaphores".. which I learned about in Operating Systems class back in 1995. Anyways, cool to see they use the same terminology and that this processor can do this :) Semaphores are great for whben accessing shared global variables.
@RalphBacon
@RalphBacon Рік тому
Indeed. Trying to "share" global variables without using them is a recipe for disaster! Glad you like the video 👍
@emmanuelsheshi1553
@emmanuelsheshi1553 2 роки тому
i think the main loop has the highest priority, you need the delay(1) so put a hold on it so the other loops can run
@RalphBacon
@RalphBacon 2 роки тому
The main loop runs at a priority of 1, the same as others unless you put them higher or lower. Ideally, all tasks should run at priority 1 so the scheduler can do its time-slicing work, unless you're doing some advanced stuff.
@pepethefrog7193
@pepethefrog7193 4 роки тому
Running the primenumber code bound to a core gives 135ms. Seems rtos uses both cores for the "unbound" state. Why is one esp32 core 7 times faster than a 8266? Love your way of explaining things plus the examples on git. How is that with passing variables between cores?
@RalphBacon
@RalphBacon 4 роки тому
I don't think it's anything to do which core it's bound to (or allowed to 'float') it's down to the task _priority_ and if you increase yours from 0 to 2 (with 24 the maximum allowed) it will indeed run again in about 64mS. See examples: xTaskCreatePinnedToCore( loop0, /* Function to implement the task */ "Task0", /* Name of the task */ 1000, /* Stack size in words */ NULL, /* Task input parameter */ 2, /* Priority of the task */ &Task0, /* Task handle. */ 1); /* Core where the task should run */ OR: xTaskCreate( loop0, /* Function to implement the task */ "Task0", /* Name of the task */ 1000, /* Stack size in words */ NULL, /* Task input parameter */ 24, /* Priority of the task */ &Task0 /* Task handle. */ );
@lmamakos
@lmamakos 4 роки тому
Is the Arduino runtime environment for the ESP32 thread-safe and reentrant? In the past, casual inspection of some Arduino libraries show that some/many are not thread-safe because they use statically allocated memory without any locking or protection. This is the tricky part of multi-threaded programming and usually results in intermittent and hard to diagnose bugs because the cause is so timing dependent. Like is the Serial.print method not using any static buffers while its formatting, e.g., Integer values into text? What happens if both threads are simultaneously running the same method? In other examples of adapting the Arduino environment into an RTOS with multiple threads, the practice usually is to only have one execution thread be allowed to use the Arduino environment because its unsafe, and the other threads do "other" processing in known-to-be-thread-safe ways.
@RalphBacon
@RalphBacon 4 роки тому
Excellent point you make, Louis. I shall investigate. Given that most libraries were never written to be thread safe I suspect the safest way to use them is to ensure that only one task ever uses them at a time - which, given the logic of a program could be quite straightforward. For example, if you are writing to a TFT display ensure that only one task (at a time) can access it. I'll investigate what Espressif say, too, on this subject. Thanks for posting, good to hear from you.
@ahmd-salh
@ahmd-salh 2 роки тому
Hi, Thanks for the video I have a task that is resposible for posting data to firebase but I'm not sure how much memory should I assign to it. Thanks
@RalphBacon
@RalphBacon 2 роки тому
Start at a reasonable amount (eg 3,000b, or higher if it crashes!) and print the remaining stack memory every 60 seconds in the task. Then reduce it so that it has headroom of about 500 bytes. Like this: static unsigned long prevMillis = 0; if (millis() - prevMillis > (60000)) { unsigned long remainingStack = uxTaskGetStackHighWaterMark(NULL); log_v("Free stack:%lu", remainingStack); prevMillis = millis(); }
@jonathanr4242
@jonathanr4242 2 роки тому
Thanks for another excellent video. I don't mean to be pedantic, but shouldn't we write assembler to do a proper speed comparison because the compiler might be more optimal for one processor or the other?
@RalphBacon
@RalphBacon 2 роки тому
Well, my understanding and belief, Jonathan, is that the compiler writes far better assembler than we can; taking into account the optimisation levels we can invoke too. Anyway, what's a few nanoseconds amongst μControllers? In this case. the difference in clock speed between the Arduino and the ESP32 makes this such a one-horse race anyway... 🤷‍♂️
@jonathanr4242
@jonathanr4242 2 роки тому
@@RalphBacon Hi Ralph, yes 62ms is quite an amazing speed. It's really a cool how this technology filters down to us hobbyists.
@charesealbow5357
@charesealbow5357 7 місяців тому
Ralph, what happens if you add a xSemaphoreGive statement after the xSemaphoreTake statement in loop2?
@RalphBacon
@RalphBacon 7 місяців тому
You've released the semaphore immediately it's been taken.
@AbdullahMohsin
@AbdullahMohsin 4 роки тому
please do more esp32 vids!!
@RalphBacon
@RalphBacon 4 роки тому
I might do more in the future, it's a very good chip that ESP32.
@AbdullahMohsin
@AbdullahMohsin 4 роки тому
@@RalphBacon I'll definitely be waiting to watch!!
@JohnnyG1956
@JohnnyG1956 4 роки тому
I tried the code in the video and I didn't get the same results as you did. I copied the code from your GitHub, after changing the pins to the pins I am using (18 & 21), it worked perfectly. The difference is the semaphore = xSemaphoreCreateBinary(); line that was in your GitHub code. I didn't see that in the video. I have SOOOO much to learn.
@RalphBacon
@RalphBacon 4 роки тому
We're all learning, John! Missing a line of code is no biggie. Glad you got it working in the end. ESP32 is such a powerful chip, don't you think?
@JohnnyG1956
@JohnnyG1956 4 роки тому
@@RalphBacon Yes, it is an amazing chip. I probably need to focus a bit more. I started with the Arduino, then got the ESP32, Analog Discovery 2, and a few days ago, my NVidia Jeston Nano arrived. I know a little about all of them... I think it is time to stop buying toys and to start learning some stuff. If you want a suggestion for a video, I have one. My next project is to get an ESP32 to turn on/off and speed control a 4 pin cooling fan (I have an NF-A4X20 5V PWM). The speed would be based on the temperature that the temp sensor is sensing, in my case, between 26 and 37 degrees. The manufacturer told me that it will work with 3.2V so the ESP32 should drive it. Keep up the great content.
@patrickmaartense7772
@patrickmaartense7772 4 роки тому
ralf can you share some info on using eclipse with the esp and arduinos tnx !
@RalphBacon
@RalphBacon 4 роки тому
Tricky, Patrick. I get so many queries from relatively simple sketches, can you imagine the avalanche of questions if I did this? I shall consider how I might do this.
@patrickmaartense7772
@patrickmaartense7772 4 роки тому
@@RalphBacon no worries ralf :) thought i might be a good one for some extra depth, I use eclipse for more or less everything coding.. not gotten into it yet for electronics..
@andrewbarnard3229
@andrewbarnard3229 Рік тому
Just a couple questions please if you have the time to answer.. Can we still use the primary loop() and just append whatever function i want specifically running on core 2 to core 2? Or does adressing the cores in this way require us to now have everything running on a specific core? 2nd question. If i drop the for(;;) loop, can i call that as a function from my other loop but still maintain that the called function runs specifically on the given core. Like.. Can i have a program running on main loop. Then call a function attached to core2 and have that do some math while my main program still cycles?
@RalphBacon
@RalphBacon Рік тому
First things first: on a two-core ESP32 be careful what you run on Core 0. That is used by Wi-Fi and Bluetooth and a few other system-related functions. If they get delayed or interrupted in any significant way then the core will PANIC and crash the processor. Given your other queries I would suggest running multiple tasks on Core 1. I've done a few videos on tasks and this is the way I tend to use the ESP32. Only when there is no other option do I use Core 0 for anything other than what the system puts there. FreeRTOS does a great job scheduling the tasks (tip: keep them all at the same priority). If you do use both cores, you can call any function in your sketch. Functions are not bound to any particular core. But don't use global variables in those sketches as each time it is called it will use the most recent value(s)! Last question: when your main loop is running yes, you can have other tasks on either core running to do some maths. The question is how will you know when it has finished and has an answer (hint: it's usually 42).
@andrewbarnard3229
@andrewbarnard3229 Рік тому
@Ralph S Bacon i wanna start with thank you for the reply, and not just that but the clear and meaningful answers as well. I have no use for the wifi or bluetooth in my project, but i do need simple things to run in the background, like updating displays, etc. it sounds like from your answers and what i have watched from your videos that i may be able to work some things out, your help and insight has been appreciated, feel free to check my channel to see the robotic project i have been working on 😉
@yogeshitaliya473
@yogeshitaliya473 4 роки тому
😍😍😍😍
@RalphBacon
@RalphBacon 4 роки тому
You are most welcome Yogesh, I'm glad you like the video. Nice to hear from you.
@haseebkhalid9821
@haseebkhalid9821 9 місяців тому
❤️❤️❤️❤️❤️
@RalphBacon
@RalphBacon 9 місяців тому
thanks!
@TheYephers
@TheYephers 4 роки тому
I'm late to the party here but I read through a bunch of the comments below and did not see an answer to your question. So, I thought I would share why I believe you need the delay in the loop() function to make it work: It is as you say because the ESP-32 implementation is sitting on top of FreeRTOS, the RTOS is checking for tight loops and can result in the watchdog timeouts. Hence we need to have the vTaskDelay() calls if we are not writing code that makes use of the loop() method. The "delay" command internally tickle the watchdog to keep things happy. There was an issue created for this a couple of years ago that discusses it and it can be enlightening: github.com/espressif/arduino-esp32/issues/595
@RalphBacon
@RalphBacon 4 роки тому
Yes, I'd come the same conclusion, Chris, that the sketch's loop was being called in a for(;;) loop - so if nothing was added to the loop() function then it would be considered a tight loop and starve other processes of CPU cycles. The solution I show in my next video (gosh! I'm ahead of the game this week) is to simply delete the task if it is not required. If we _are_ going to use the loop() as a sort of task supervisor then we don't delete it, obviously, nor does it need that delay(1) which worked so well but was just consuming CPU cycles for no benefit - hence the vTaskDelete. More in my next video, thanks for the confirmation!
@berkanab4260
@berkanab4260 Рік тому
Hello, quick question, do you meanwhile know why you have to include the delay from (1)?
@RalphBacon
@RalphBacon Рік тому
If you are talking about the one in the loop( ) it is to stop it being optimised away by the compiler. You can remove it, and the loop ( ) function disappears too which _might_ give you an error because the outer shell is calling it.
#148 TCA9548A I2C MULTIPLEXER (& Voltage Shifter)
38:00
Ralph S Bacon
Переглядів 25 тис.
#151 - ESP32 Passing Values 💾 Between Tasks - Deep Dive (2 Easy Ways)
38:38
Surprise Gifts #couplegoals
00:21
Jay & Sharon
Переглядів 13 млн
451 Which Processor can kill the ESP32?
11:24
Andreas Spiess
Переглядів 331 тис.
PlatformIO: All you need to know in 10 Minutes!
10:56
J's e-shack
Переглядів 278 тис.
#253 Accurate Task Scheduler for the Arduino (and STM32, ESP32...)
21:37
Ralph S Bacon
Переглядів 19 тис.
#372 How to use the two Cores of the Pi Pico? And how fast are Interrupts?
14:25
#152 STM32 Blue Pill - Is this a modern NANO replacement (✅)
28:14
Ralph S Bacon
Переглядів 50 тис.
2 Parallel Loops on ESP32 No Delay using Arduino IDE
6:51
Electronic Junkies
Переглядів 19 тис.
#BB12 Pointer vs References - and why you don't need 👉pointers in C++
31:46
15 Brilliant ESP32 Projects that are Worth-trying!!!
11:12
ToP Projects Compilation
Переглядів 162 тис.
Which ESP32 is Best for Your Project?
11:12
Predictable Designs
Переглядів 15 тис.
iPhone - телефон для нищебродов?!
0:53
ÉЖИ АКСЁНОВ
Переглядів 3,6 млн
Result of the portable iPhone electrical machine #hacks
1:01
KevKevKiwi
Переглядів 7 млн
Опасная флешка 🤯
0:22
FATA MORGANA
Переглядів 622 тис.