DHT11 blocks when using read functions

Hello,
I have been using freertos for a project and I’ve done 3 tasks which all worked perfectly except for one which reads the temperature and humidity of dht11. When I call dht.readTemperature() or dht.readHumidity() it block indefinetely. I suspect it is connected to the fact that the library uses the delay() function. Any way I can solve this without remaking the dht11 library?

Code that blocks:

void readSensor( void *pvParameters )
{
(void) pvParameters;

for(;:wink:
{
Serial.println(“Task 1”);

t= dht.readTemperature();
h = dht.readHumidity();
hic = dht.computeHeatIndex(t, h, false);

vTaskDelay(1000 / portTICK_PERIOD_MS);

}

}

If it blocks when you call dht.readTemperature() then presumable the issue is inside that function, and you don’t show the code for that.

Yes that was the case! I already got it to work by using a different library that didn’t block the execution. Thank you!

May know which library fixed this issue?
I’m facing the same issue with the Adafruit DHT library?

I had solved the problem by increasing the stack size to 400 (at least). Check the unused stack and adjust it to your need.
Also, it is better to update the DHT library and (not required) replace the delay() function in it by vTaskDelay().

What is the library that works as expected?

Can you share your library which has been used?
I got the same problem :sob::sob: