RobTillaart / DHTNew

Arduino library for DHT11 and DHT22 with automatic sensor recognition
MIT License
99 stars 15 forks source link

error yield() no se declaró #51

Closed germe-fur closed 3 years ago

germe-fur commented 3 years ago

(spanish)

i tried to use the library and i get this error:

the code:

#include <dhtnew.h>

void setup(){

}
void loop(){

}

compiler:

/home/germe/Documentos/arduino/libraries/DHTNEW042/dhtnew.cpp:112:13: error: ‘yield’ no se declaró en este ámbito
       yield();
             ^
/home/germe/Documentos/arduino/libraries/DHTNEW042/dhtnew.cpp: En la función miembro ‘int DHTNEW::_readSensor()’:
/home/germe/Documentos/arduino/libraries/DHTNEW042/dhtnew.cpp:248:9: error: ‘yield’ no se declaró en este ámbito
   yield();
         ^

the compiler is in spanish because my system is in spanish. it say "error in the member function ‘int DHTNEW::_readSensor()’: yield not declared in this ambit sorry for my english, i speak spanish

my library version is:0.4.2 i'm on arduino ide 2:1.0.5+dfsg2-4.1 the error ocurrs when i import the library. if i put more code the error splashes too

RobTillaart commented 3 years ago

Thanks for using my library and give feedback,

yield() is a function that is used by many operating systems to indicate that now it is a good time to swap processes. On embedded systems like ESP32 it is used to handle background processing like WIFI handling etc that are time critical.

On a standard Arduino UNO the function is implemented as an empty function, that will be optimized away by the compiler. The more recent versions of the "Arduino compilers" should support this function.

Several options:

void yield() {};

I cannot remove it from the library as it is there for a reason as you understand.

Hope this helps,

germe-fur commented 3 years ago

thanks for the response!! it now work! (i added an empty void yield)