Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why test startTime - lastReadTime < 1999 and not < 2000 for DHT22 #17

Open
HaleTom opened this issue Feb 11, 2019 · 1 comment
Open

Comments

@HaleTom
Copy link

HaleTom commented Feb 11, 2019

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?

@markruys
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants