2

Adding yield() will reduce random resets in ESP8266. What if the code has too many yield()? What is the side effect?

  • 1
    Possible duplicate of [What is the secret of the arduino \`yield()\`function?](http://stackoverflow.com/questions/34497758/what-is-the-secret-of-the-arduino-yieldfunction) – Marcel Stör Aug 19 '16 at 12:03
  • Calling `yield()` is a code smell IMO that simply makes up for lack of proper event handling. – Marcel Stör Aug 19 '16 at 12:05
  • I have a callback function which is processor-intensive. I have no choice but to use yield(). yield() can be a life-saver. –  Aug 19 '16 at 12:06
  • 1
    Yes, it _can_ be but since it's so readily available it doesn't really force you to think twice about running processor-intensive operations and thereby not feeding the watch dog. – Marcel Stör Aug 19 '16 at 12:08
  • will using yield() cause a slowdown in the performance? –  Aug 19 '16 at 12:09
  • Yes, but it may not be noticeable, depends on your code. Whenever you `yield` you give the processor a chance to execute background tasks rather than your own code. – Marcel Stör Aug 19 '16 at 20:01

1 Answers1

1

Basically the yield command just gives the esp the opportunity to handle internal stuff. It´s way better than using waits - delay() and I couldn't find a noticeable performance impact.

volker
  • 38
  • 1
  • 7