Arduino Nano FreeRTOS Problem

Hi,

I am working on the development of a multi-sensor node. I have DHT22 Noise and Light sensors on my Board connected to Arduino Nano. I am using the standard libraries to access their data. Since DHT22 takes almost 2 seconds to read the data it affects the values of other sensors. I have tried FreeRTOS library to solve the problem but I am still getting the issue. When I print the values of other tasks it waits for a moment and then prints due to the delay of the DHT22 library. I have attached my code below. Currentlly the code is reading from two sensors (DHT22 and Noise) and printing only value of the noise sensor.

Regards
Muhammad Nabeel Tahir

Node_FreeRTOS.ino (1.56 KB)

Forget that FreeRTOS features, it just uses a lot of resources and doesn’t help with your problem.

A DHT22 read should be finished in about 6ms but the library you use (given you use the one available in the library manager) does wait much longer before the read so it sums up to about 300ms per actual read. The library does not always read the sensor. If the last read was less than 2 seconds ago it doesn’t read a new value but returns the last one returned by the sensor. So how do you get these long delays? Are the measured values valid (so is the sensor correctly connected)? During value transfer from the sensor interrupts are disabled so your FreeRTOS won’t work during that time.