arduino-DHT
arduino-DHT copied to clipboard
Why test startTime - lastReadTime < 1999 and not < 2000 for DHT22
Why are you testing for < 1999 rather than < 2000 here:
if ( (unsigned long)(startTime - lastReadTime) < (model == DHT11 ? 999L : 1999L) ) {
return;
}
Are you assuming that the overhead of calling the function will be 1ms, such that the duty cycle of 2000ms is maintained?
Correct. It's actually more a safety check so that you don't poll the sensor too often. Thinking of it, I now would write the code such that you track the actual sample rate and and check it's not being called at a faster pace.