Skip to content

DHT11 wont read below 0 degree celsius #181

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

Open
beicnet opened this issue Feb 11, 2021 · 4 comments
Open

DHT11 wont read below 0 degree celsius #181

beicnet opened this issue Feb 11, 2021 · 4 comments

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;

@Daryavahus
Copy link

Daryavahus commented Feb 11, 2025

It won't work. DHT Asair shows abnormal temperatures above 0 degree. Instead 23 it shows 260 degree.

@MaderDash
Copy link

Has this issue been resolved at this time? If so, it can be closed; if not, please let me know.

@Daryavahus
Copy link

I tried many possibilities. And now my code looks like this:
header:
#define ADJUST 3
.....
f = (data[2] & 0xFF) + ((data[3] & 0x7F) * 0.1F);
if(data[3] & 0x80){
f = -1.F - f;
}
f -= ADJUST; // temp. correction
if (S) {
f = convertCtoF(f);
}

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

4 participants