#149

แชร์
ฝัง
  • เผยแพร่เมื่อ 13 มิ.ย. 2019
  • 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 5 ปีที่แล้ว +3

    Thanks Ralph. Great video, yes please do more.

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว

      Thank you for your feedback, Peter Heartfield, noted and appreciated!

  • @GeekMustHave
    @GeekMustHave 5 ปีที่แล้ว +3

    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  5 ปีที่แล้ว

      Thank you for your feedback, GeekMustHave, noted and appreciated!

  • @george12121979
    @george12121979 5 ปีที่แล้ว +3

    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  5 ปีที่แล้ว

      And continue I will, George! Stay tuned!

  • @Thomas72B
    @Thomas72B 5 ปีที่แล้ว +2

    Very interesting Video ! Please more videos about the ESP32 !

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว

      Thank you for your feedback, Thomas, noted and appreciated!

  • @neverendingrefit759
    @neverendingrefit759 5 ปีที่แล้ว +2

    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  5 ปีที่แล้ว

      Thank you for your feedback, Boat data systems, noted and appreciated!

    • @bipolarchemist
      @bipolarchemist 5 ปีที่แล้ว

      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.

  • @andymouse
    @andymouse 5 ปีที่แล้ว +2

    Hi, speaking of ESP32's an Australian TH-camr 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  5 ปีที่แล้ว

      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

  • @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!

  • @OsoPolarClone
    @OsoPolarClone 5 ปีที่แล้ว

    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  5 ปีที่แล้ว +1

      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.

  • @heyok
    @heyok 5 ปีที่แล้ว +2

    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  5 ปีที่แล้ว +1

      Thanks for that, heyok, nice to hear from you.

  • @paulyorke1437
    @paulyorke1437 5 ปีที่แล้ว

    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  5 ปีที่แล้ว

      Thank you for your feedback, Paul, noted and appreciated!

  • @deangreenhough3479
    @deangreenhough3479 5 ปีที่แล้ว

    At work and yet to see. But boy, I’ve been waiting for this one. Well done Ralph😁🏴󠁧󠁢󠁥󠁮󠁧󠁿

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว

      I hope your expectations were met, Dean, and stay tuned for further videos.

  • @magic.marmot
    @magic.marmot 5 ปีที่แล้ว

    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  5 ปีที่แล้ว +1

      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!

  • @libertywool
    @libertywool 5 ปีที่แล้ว +5

    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 5 ปีที่แล้ว

      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 5 ปีที่แล้ว +2

      +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 5 ปีที่แล้ว

      @@mikelopez9893 thanks, very cool.

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว +2

      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 5 ปีที่แล้ว +1

      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.

  • @ytbone9430
    @ytbone9430 5 ปีที่แล้ว +2

    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  5 ปีที่แล้ว +1

      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...

  • @timcallinan
    @timcallinan 2 ปีที่แล้ว

    Excellent Tutorial Ralph. Enjoying it

    • @RalphBacon
      @RalphBacon  2 ปีที่แล้ว

      Glad you enjoyed it!

  • @TheZrpilot
    @TheZrpilot 5 ปีที่แล้ว +1

    Very much enjoy this and ALL your videos Ralph... would like to see more!! Thanks!!!!

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว +1

      Thank you for your feedback, Max, noted and appreciated!

  • @daviddoidge1252
    @daviddoidge1252 5 ปีที่แล้ว +1

    Excellent again, looking forward to more ESP32 videos

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว

      Thank you for your feedback, David, noted and appreciated!

  • @marinehm
    @marinehm 5 ปีที่แล้ว

    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  5 ปีที่แล้ว +1

      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...

  • @anispinner
    @anispinner 5 ปีที่แล้ว

    So many details. Thank you, Ralph! Subbed, looking to more content on MC's and FPGA's.

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว +1

      Thank you for your feedback, NLab, noted and appreciated!

  • @davidharms3562
    @davidharms3562 ปีที่แล้ว

    Still enjoying these videos Ralph! Keep up the great work, good sir! 👍🏻

    • @RalphBacon
      @RalphBacon  ปีที่แล้ว

      Glad you like them!

  • @la6mp
    @la6mp 5 ปีที่แล้ว

    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  5 ปีที่แล้ว

      You are most welcome John, I'm glad you like the video. Nice to hear from you.

  • @ianstubbington2334
    @ianstubbington2334 3 ปีที่แล้ว +3

    Great video for getting started with esp32. More please ;)

    • @RalphBacon
      @RalphBacon  3 ปีที่แล้ว +1

      Thanks, will do!

  • @Trevor30926
    @Trevor30926 5 ปีที่แล้ว

    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  5 ปีที่แล้ว

      Thank you for your feedback, Trevor30926, noted and appreciated!

  • @GRPZ66
    @GRPZ66 5 ปีที่แล้ว

    Excellent video. Keep them coming. Much appreciated.

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว

      Thank you for your feedback, Guido Zijlstra, noted and appreciated!

  • @BiggsWorld
    @BiggsWorld 5 ปีที่แล้ว

    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  5 ปีที่แล้ว

      Thanks for that, BiggsWorld, nice to hear from you. Thanks for subscribing too!

  • @noweare1
    @noweare1 5 ปีที่แล้ว

    Another worthwhile video. Count me in for more esp32 vids. As far as the speed difference ... that's just mind boggling.

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว

      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.

  • @willofirony
    @willofirony 5 ปีที่แล้ว

    Yeah, I like this sort of stuff. Brilliant vid, Ralph.

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว

      Thank you for your feedback, Michael , noted and appreciated! Good to hear from you again!

  • @michaelhyde9971
    @michaelhyde9971 5 ปีที่แล้ว +1

    Great video as usual. I was thinking about getting an esp32 now I will thanks :)

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว

      Thank you for your feedback, Michael Hyde, noted and appreciated!

  • @stevehallam0850
    @stevehallam0850 5 ปีที่แล้ว

    Really good stuff, thanks Ralph 👍

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว

      Thank you for your feedback, Steve Hallam, noted and appreciated!

  • @Ne555N
    @Ne555N 3 ปีที่แล้ว +1

    This tutorial is excelent!! Thank you very much for the effort you put into the video

    • @RalphBacon
      @RalphBacon  3 ปีที่แล้ว +1

      You're very welcome!

  • @John_Smith__
    @John_Smith__ 5 ปีที่แล้ว +1

    Oh yes, ESP32 is a great great platform ! We would all love to see inter-task communication ... passing arguments and data.

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว +1

      Yes, that will be "interesting", John. Keep tuned. Thanks for posting.

  • @peut
    @peut 5 ปีที่แล้ว

    Very nicely done. Thank you. Please continue.

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว

      Thank you for your feedback, Jose, noted and appreciated!

  • @williammiller7543
    @williammiller7543 5 ปีที่แล้ว

    Another Great, Informative video. I'm starting to use the ESP32 and this background info is Very usefull.

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว

      Thanks for your post, William, good to hear from you.

  • @bhnienhuis
    @bhnienhuis 5 ปีที่แล้ว +1

    Very interesting, please continue

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว

      Thank you for your feedback, Herman Nienhuis, noted and appreciated!

  • @robingiles399
    @robingiles399 5 ปีที่แล้ว +1

    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  5 ปีที่แล้ว

      Thanks for that, ROBIN GILES, nice to hear from you.

  • @jeffbluejets2626
    @jeffbluejets2626 5 ปีที่แล้ว

    As usual, great stuff. More thankyou.

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว

      Thank you for your feedback, Jeff Bluejets, noted and appreciated!

  • @Ed19601
    @Ed19601 5 ปีที่แล้ว +1

    Just got myself a few esp32's so I will be revisiting this

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว +1

      Yes, indeed, Ed, it's quite interesting what you can do with them.

  • @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 ปีที่แล้ว +1

      @@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.

  • @mksmurff
    @mksmurff 3 ปีที่แล้ว

    Just found this. Brilliant. Earned a sub

    • @RalphBacon
      @RalphBacon  3 ปีที่แล้ว +1

      Thanks, DannyK, welcome aboard.

  • @mav29
    @mav29 4 ปีที่แล้ว +1

    thanks mate, 2020 and still a great video

    • @RalphBacon
      @RalphBacon  4 ปีที่แล้ว +2

      Glad you enjoyed it! I want to do another on Timer Tasks, more efficient. It's on the list...

    • @mav29
      @mav29 4 ปีที่แล้ว

      @@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 4 ปีที่แล้ว

      @@RalphBacon im back sir, i just recieved my ESP32 today and im going to test it using your examples yaaayyyyyyy! cheers!

  • @rzinindiana8029
    @rzinindiana8029 3 ปีที่แล้ว

    As usual... clear and important info... TX

    • @RalphBacon
      @RalphBacon  3 ปีที่แล้ว

      Glad it was helpful!

  • @vincenttang9059
    @vincenttang9059 4 ปีที่แล้ว

    Very Useful for me, thank you for your sharing :)

    • @RalphBacon
      @RalphBacon  4 ปีที่แล้ว

      Glad it was helpful!

  • @ElieWar
    @ElieWar 5 ปีที่แล้ว +1

    Thank you, yes more, plz

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว

      Thank you for your feedback, Elie, noted and appreciated!

  • @ayganotomasyon1109
    @ayganotomasyon1109 ปีที่แล้ว +1

    Thats what i m looking for. Thank you.

    • @RalphBacon
      @RalphBacon  ปีที่แล้ว

      Glad I could help!

  • @tomwatzek3500
    @tomwatzek3500 5 ปีที่แล้ว +3

    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  5 ปีที่แล้ว +1

      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!

  • @patrickmaartense7772
    @patrickmaartense7772 5 ปีที่แล้ว

    yes please more of this !

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว

      Thank you for your feedback, patrick maartense, noted and appreciated!

  • @wires4auto
    @wires4auto 5 ปีที่แล้ว +1

    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  5 ปีที่แล้ว +1

      Thank you for your feedback, gordon, noted and appreciated!

  • @EmbSysDev
    @EmbSysDev 3 ปีที่แล้ว

    Very , very nice into to ESP32 !

  • @sortofsmarter
    @sortofsmarter 5 ปีที่แล้ว

    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  5 ปีที่แล้ว +1

      Thanks for your post, Gene, good to hear from you.

  • @bryanethier1910
    @bryanethier1910 4 ปีที่แล้ว +1

    Excellent vids

    • @RalphBacon
      @RalphBacon  4 ปีที่แล้ว

      Thanks Bryan, glad you liked this one!

  • @abboberg987
    @abboberg987 5 ปีที่แล้ว

    Today i learned a lot; ESP32 has 2 cores and we can use it! Thanks Ralph

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว +1

      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!

  • @maxpenfold8699
    @maxpenfold8699 3 ปีที่แล้ว

    What a great Video, thanks!

    • @RalphBacon
      @RalphBacon  3 ปีที่แล้ว

      Glad you liked it!

  • @abpccpba
    @abpccpba 5 ปีที่แล้ว

    Thanks yes more on ESP32 👍

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว

      Thank you for your feedback, Paul C Johnson, noted and appreciated!

  • @GabrielAlves-mf8vd
    @GabrielAlves-mf8vd 5 ปีที่แล้ว

    Amazing tutorial!

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว

      You are most welcome Gabriel, I'm glad you like the video. Nice to hear from you.

  • @JohnTinic
    @JohnTinic 5 ปีที่แล้ว

    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  5 ปีที่แล้ว

      You are most welcome John, I'm glad you like the video. Nice to hear from you.

  • @chetanyasaxena8082
    @chetanyasaxena8082 5 ปีที่แล้ว +1

    Great Video, very informative. Keep up the good work sir BTW new sub. Please make more ESP32 Videos.

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว +1

      Thanks for your post, Chetanya Saxena, good to hear from you and thanks for the sub. You are most welcome.

  • @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  ปีที่แล้ว +1

      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!

  • @robertnovak1602
    @robertnovak1602 5 ปีที่แล้ว +1

    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  5 ปีที่แล้ว

      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 5 ปีที่แล้ว

      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  5 ปีที่แล้ว

      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.

  • @dekipet
    @dekipet 5 ปีที่แล้ว +1

    Neat one. Thank you.

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว

      You are most welcome Dejan, I'm glad you like the video. Nice to hear from you.

    • @dekipet
      @dekipet 5 ปีที่แล้ว +1

      @@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  5 ปีที่แล้ว +1

      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...

  • @paulrichmond6903
    @paulrichmond6903 5 ปีที่แล้ว

    Great video.

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว

      Thanks for your post, Paul Richmond, good to hear from you.

  • @michaelbyron9688
    @michaelbyron9688 5 ปีที่แล้ว +1

    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  5 ปีที่แล้ว +1

      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.

  • @kennmossman8701
    @kennmossman8701 4 ปีที่แล้ว +2

    MORE please sir!

    • @RalphBacon
      @RalphBacon  4 ปีที่แล้ว +1

      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?

  • @JulianMakes
    @JulianMakes 5 ปีที่แล้ว

    lovely tutorial thanks :)

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว

      You are most welcome Julian HG, I'm glad you like the video. Nice to hear from you.

  • @datho-cq1ez
    @datho-cq1ez 5 หลายเดือนก่อน

    I am a student come from Viet Nam, this is a excellent video, thank you because share this topic.

    • @RalphBacon
      @RalphBacon  4 หลายเดือนก่อน

      Glad you enjoyed it! Thanks for posting!

  • @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 ปีที่แล้ว +1

      Talk soon! Don't be a stranger!

  • @georgestewart5879
    @georgestewart5879 5 ปีที่แล้ว

    Yes some more please.

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว

      Thank you for your feedback, George, noted and appreciated!

  • @mikelopez9893
    @mikelopez9893 5 ปีที่แล้ว +3

    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 5 ปีที่แล้ว

      Mike Lopez thank you Mike, that’s great additional Information and appreciated. 👍🏴󠁧󠁢󠁥󠁮󠁧󠁿

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว

      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.

  • @michaelbishton9439
    @michaelbishton9439 5 ปีที่แล้ว +1

    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  5 ปีที่แล้ว +1

      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 5 ปีที่แล้ว

      @@RalphBacon Thank you very much, it does. Please keep doing that so that people can look up the full list of functions.

  • @henrikjensen3278
    @henrikjensen3278 5 ปีที่แล้ว

    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  5 ปีที่แล้ว

      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 5 ปีที่แล้ว

      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.

  • @Graham1904
    @Graham1904 5 ปีที่แล้ว

    Well presented esp (pun) ially for a newbie like myself

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว

      Groan. Almost a pun, anyway, Graham! Glad you liked the video!

  • @GilchristMcGill
    @GilchristMcGill ปีที่แล้ว +1

    Thank you.

  • @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 5 ปีที่แล้ว

    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 5 ปีที่แล้ว

      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  5 ปีที่แล้ว +1

      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 5 ปีที่แล้ว +1

    Yes!!! Please!!! Esp32

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว

      Thank you for your feedback, Justin, noted and appreciated!

  • @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.

  • @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 ปีที่แล้ว +2

      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.

  • @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 (th-cam.com/video/ywbq1qR-fY0/w-d-xo.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.

  • @gazzacroy
    @gazzacroy 3 ปีที่แล้ว

    wow i mite get a few of these to try :) cool :)

    • @RalphBacon
      @RalphBacon  3 ปีที่แล้ว

      Yes, go for it, cheap and will keep you amused for months.

  • @foxabilo
    @foxabilo 5 ปีที่แล้ว +1

    Yea, I like this sort of stuff

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว +1

      Thank you for your feedback, foxabilo, noted and appreciated!

    • @foxabilo
      @foxabilo 5 ปีที่แล้ว

      @@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  5 ปีที่แล้ว +1

      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 5 ปีที่แล้ว

      @@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 5 ปีที่แล้ว

      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 ;)

  • @JerryEricsson
    @JerryEricsson 5 ปีที่แล้ว

    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  5 ปีที่แล้ว

      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 5 ปีที่แล้ว

      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.

  • @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.

  • @inferno6012
    @inferno6012 5 ปีที่แล้ว +1

    nice

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว

      You are most welcome inferno 601, I'm glad you like the video. Nice to hear from you.

  • @tedmoga4797
    @tedmoga4797 4 หลายเดือนก่อน

    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  4 หลายเดือนก่อน

      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!

  • @flemmingchristiansen2462
    @flemmingchristiansen2462 5 ปีที่แล้ว

    Seems the speed will make you pale, What happened to your colors?
    Great video, like to see more ESP32 stuff

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว

      Certainly the speed test did make me pale with wonder! But in reality, it's all down to the green screen (ChromaKey) that sometimes just doesn't want to play ball and this is how I fix it!

  • @majidabdaly7993
    @majidabdaly7993 2 ปีที่แล้ว

    Nice

  • @yogeshitaliya473
    @yogeshitaliya473 5 ปีที่แล้ว

    😍😍😍😍

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว +1

      You are most welcome Yogesh, I'm glad you like the video. Nice to hear from you.

  • @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.

  • @lmamakos
    @lmamakos 5 ปีที่แล้ว +1

    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  5 ปีที่แล้ว +1

      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.

  • @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 ปีที่แล้ว +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 ปีที่แล้ว +1

      @@RalphBacon Hi Ralph, yes 62ms is quite an amazing speed. It's really a cool how this technology filters down to us hobbyists.

  • @pepethefrog7193
    @pepethefrog7193 5 ปีที่แล้ว

    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  5 ปีที่แล้ว +1

      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. */
      );

  • @haseebkhalid9821
    @haseebkhalid9821 11 หลายเดือนก่อน

    ❤️❤️❤️❤️❤️

    • @RalphBacon
      @RalphBacon  11 หลายเดือนก่อน

      thanks!

  • @jenniferw8963
    @jenniferw8963 ปีที่แล้ว

    Does it make sense to create a task each time you want to update the OLED display? I notice it atakes like 20ms to refresh an OLED with I2C ... pretty slow. Say I have some other process I want to run continuously without a 20ms interruption.. just wondering if the dual core processor would help in this situation.

    • @RalphBacon
      @RalphBacon  ปีที่แล้ว +1

      I would have a task that runs continuously to update the OLED display but which sits there idle until a resource is made available (a flag, if you will).
      Because it is waiting on a resource (a binary semaphore, maybe, or mutex) it uses no resources itself because it will not be scheduled until the resource becomes available.
      This leaves other tasks to do their business without hinderance.

  • @GoodAllDay
    @GoodAllDay 5 ปีที่แล้ว +1

    Can i use hardware interrupts and dual core mode at the same time? When i tried it, i got a lot of errors in runtime.
    For example, structure in my project:
    0 core for attach Interrupts, and some of algorithms.
    1 core for Wi-fi communication and updates tft display using i2c.
    Is it possible?

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว +1

      You must be careful in using Core 0. Try and keep all your tasks on Core 1 initially. Passing semaphores between tasks is fine, but *not* from an ISR, you need a different function. Core 0 is used by RTOS for the WiFi and BlueTooth; if you starve them of CPU cycles they will crash.

  • @berkanab4260
    @berkanab4260 ปีที่แล้ว

    Hello, quick question, do you meanwhile know why you have to include the delay from (1)?

    • @RalphBacon
      @RalphBacon  ปีที่แล้ว +1

      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.

  • @charesealbow5357
    @charesealbow5357 9 หลายเดือนก่อน

    Ralph, what happens if you add a xSemaphoreGive statement after the xSemaphoreTake statement in loop2?

    • @RalphBacon
      @RalphBacon  9 หลายเดือนก่อน

      You've released the semaphore immediately it's been taken.

  • @robertmurton7373
    @robertmurton7373 2 ปีที่แล้ว

    Hello Ralph I down loaded your programme okay but it had a stack over flow error when I tried to run it, did you have this error when developing the programme? I have a lot more to learn about the ESP32.

    • @RalphBacon
      @RalphBacon  2 ปีที่แล้ว

      No stack overflow here, Robert. Are you allocating too much/little memory to each task?
      Try putting in your task(s):
      static unsigned oldMillis = 0;
      if (millis( ) - oldMillis > 1000) {
      Serial.print(ESP.getFreeHeap( ));
      oldmillis = millis( );
      }
      That will show you if you're running out of memory (or have a leak). Adjust the amount of stack you allocate to each task accordingly.

  • @vonries
    @vonries 5 ปีที่แล้ว

    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  5 ปีที่แล้ว +1

      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 5 ปีที่แล้ว

      @@RalphBacon oh I thought you had it doing multicore processing.

  • @tenlittleindians
    @tenlittleindians 5 ปีที่แล้ว

    Is code written in sloeber-workspace for an ESP32 governed by the same open source license requirements? Am I able to keep my code private for commercial hardware I develop that uses ESP32 devices?

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว +1

      However you write your code, it's not the IDE tool that decides whether or not the final product can be closed source.
      If you use open-source libraries that have to be made available in the same manner as you found them (ie open source) then your final code cannot be closed source.
      You must check the licence in each of the libraries. Absence of a licence does *not* mean that it is free - quite the reverse.
      If, however, the software you include in your project is licenced under the MIT licence then you can do anything you want, including making closed-source software from it.
      It's a legal minefield. For the ESP32 you also need to check whether the version of RTOS they use is OK for closed source software projects.
      It may be possible to create some of your software as closed source but release the parts that must be open source.
      See choosealicense.com/

  • @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 👍

  • @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 ปีที่แล้ว +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();
      }