DHT 22 negative temperature results

Hi everyone

I wrote code to get temperatures from DHT22 sensor, when the temperature is positive , everything is OK , but when i put the sensor in freezer i got wondrous results like 3276 i think the problem in the library , but every libraries i downloaded from internet get me same problem can anyone give me a solution please ?

thanks

Amr_ak: i think the problem in the library

It seems unlikely. Many many people have managed to get that sensor to work for them.

Post your code.

Amr_ak:
i think the problem in the library , but every libraries i downloaded from internet get me same problem

Then why do you think it’s in the library, if all those libraries give you the same result?

More likely it’s somewhere in your code, or your wiring, or in some of the other parts of your project that you forgot to post.

Not having seen the code all i can do is give you the part that deals with negative dht22 temperatures in the code i use (that are working)

      if ( rawTemperature & 0x8000 ) {
      rawTemperature = -(int16_t)(rawTemperature & 0x7FFF);
    }
    
  float temp_dht = ((int16_t)rawTemperature) * 0.1;

when dht temp are negative bit 16 is set B1000000000000000

Best of luck

include "DHT.h"

DHT dht1(A0, DHT11);

void setup(){ Serial.begin(9600); }

void loop() {

dht1.read();

Serial.println(dht1.temperature);

delay (2000); }

Do you have a DHT11 (as you use in code) or a DHT22 (as you say in #0)?