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

DHT11 wont read below 0 degree celsius #181

Open
beicnet opened this issue Feb 11, 2021 · 1 comment
Open

DHT11 wont read below 0 degree celsius #181

beicnet opened this issue Feb 11, 2021 · 1 comment

Comments

@beicnet
Copy link

beicnet commented Feb 11, 2021

Hi there,

I'm using Arduino UNO and the new variant of the Asair DHT11 (not the Aosong) sensor over 3.3v.

image

Everything is working just fine until the sensor reading get to 0 degree celsius and it just wont go below.

Outside right now is -3c

btw. I'm using library version 1.3.0

Thank you for your support!

@dl2sba
Copy link

dl2sba commented Feb 16, 2021

I have fixed this code in DHT.cpp.

My sensor also has the "feature" that it reports 0x0000 for 0°C as well as 0x8000 for 0°C.
Following the logic this is -327.7°C ...

 case DHT22:
    case DHT21:
      int16_t d = ((int16_t)data[2]) << 8 | data[3];
	  //	msb set == negativ
	  if (d & 0x8000) {
		  d &= 0x7fff;
		  //	0x8000 == 0x0000 == 0)
		  if ( d == 0 ) d = 0x7fff;
		  d = 0x7fff - d;
		  d *= -1;
	  }
	  f = d * 0.1f;

      if (S) {
        f = convertCtoF(f);
      }
      break;

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