My DHT11 Data reading value Temperature, humidity got negatif and AC temp zero in OLED

my project is [Automatic AC Temperature Controller using Arduino, DHT11 and IR Blaster]. The problem is my Temperature, humidity have negative value and cant reading the temperature AC. when I try to use example DHTtester, DHT11 it can read the temperature on serial monitor but when I use in my project, the reading on OLED temperature-997C, Humidity-999%. How to fix this problem. Im new to arduino. Please Help.

My code project

/*
 * Automatic AC Temperature control using Arduino and TSOP
 * Code by: Aswinth Raj B
 * Dated: 25-10-2017
 * Website: www.circuitdigest.com
 * 
       S.No: Component Pin Arduino Pin
    1 OLED – Vcc  5V 
    2 OLED – Gnd  Gnd
    3 OLED- SCK, D0,SCL,CLK 4
    4 OLED- SDA, D1,MOSI, Data  3
    5 OLED- RES, RST,RESET  7
    6 OLED- DC, A0  5
    7 OLED- CS, Chip Select 6
    8 DHT11 – Vcc 5V
    9 DHT11 – Gnd Gnd
    10  DHT11 – Signal  13
    11  TSOP – Vcc  5V
    12  TSOP – Gnd  Gnd
    13  IR Led – Anode  9
    14  IR Led – Cathode  Gnd
 */
 
#include <IRremote.h> //Lib for IT Blaster and TSOP
#include <SPI.h> // Inbuilt Lib
#include <Wire.h> //Inbuilt Lib
#include <Adafruit_GFX.h> //Lib for OLED
#include <Adafruit_SSD1306.h> //Lib for OLED
#include <dht.h> //Library for dht11 Temperature and Humidity sensor (Download from Link in article)
 
 // Assign pins for OLED (Software config.)
#define OLED_MOSI  3
#define OLED_CLK   4
#define OLED_DC    5
#define OLED_CS    6
#define OLED_RESET 7
Adafruit_SSD1306 display(OLED_MOSI, OLED_CLK, OLED_DC, OLED_RESET, OLED_CS);

#define SSD1306_LCDHEIGHT 64 //Change if you are using a Different OLED
#define DHTTYPE DHT11   // DHT 
#define DHT11_PIN 13 //Sensor output pin is connected to pin 13
dht DHT; //Sensor object named as DHT

#define Desired_temperature 27 //The desired temperature is 27*C at any time

//Decoded Remote Signals For my AC ##CHANGE IT FOR YOUR REMOTE
unsigned int ACoff[] = {4600,2500, 400,400, 350,950, 350,950, 350,400, 350,1000, 300,400, 350,400, 350,400, 350,400, 350,950, 350,400, 300,450, 300,1000, 350,400, 300,450, 300,450, 300,400, 350,1000, 300,400, 350,400, 350,950, 350,400, 350,1000, 300,400, 350,1000, 300,400, 350,400, 350,400, 350,400, 350,950, 350,400, 350,400, 350,950, 350,950, 350,400, 350,400, 350,400, 350,950, 350,400, 300,1000, 350,400, 350,400, 300,450, 300,1000, 300,450, 300,450, 300,1000, 300,1000, 350};
unsigned int ACon[] = {4600,2500, 400,400, 300,1000, 350,950, 350,400, 350,950, 350,400, 350,400, 350,400, 300,450, 300,1000, 350,400, 300,450, 300,1000, 300,450, 300,400, 350,400, 350,950, 350,950, 350,450, 300,400, 350,1000, 300,400, 350,1000, 300,450, 300,1000, 300,450, 300,400, 350,400, 350,400, 350,950, 350,400, 350,400, 350,950, 350,900, 400,400, 350,400, 350,400, 350,950, 350,400, 350,950, 350,400, 350,400, 300,450, 300,1000, 350,400, 300,450, 300,1000, 300,1000, 350};
unsigned int Temp23[] = {4600,2500, 400,400, 350,950, 350,1000, 300,400, 350,1000, 300,450, 300,400, 350,400, 350,400, 350,950, 350,400, 350,400, 350,950, 350,400, 350,400, 300,450, 300,450, 300,400, 350,1000, 300,400, 350,1000, 300,400, 350,1000, 300,450, 300,1000, 300,450, 300,400, 350,400, 350,400, 350,950, 350,400, 350,400, 350,950, 350,950, 350,400, 350,400, 350,400, 350,950, 350,400, 350,950, 350,400, 350,400, 350,400, 300,1000, 350,400, 350,400, 300,1000, 350,950, 350};
unsigned int Temp24[] = {4550,2550, 350,450, 300,1000, 300,1000, 350,400, 350,950, 350,400, 350,400, 300,450, 300,450, 300,1000, 300,450, 300,400, 350,1000, 300,400, 350,400, 350,400, 350,400, 350,400, 350,950, 350,400, 300,1000, 350,400, 350,950, 350,400, 350,950, 350,400, 350,400, 300,450, 300,450, 300,1000, 300,450, 300,400, 350,1000, 300,1000, 350,400, 300,450, 300,400, 350,1000, 300,400, 350,1000, 300,450, 300,400, 350,400, 350,950, 350,400, 350,400, 350,950, 350,1000, 300};
unsigned int Temp25[] = {4550,2550, 400,400, 300,1000, 350,950, 350,400, 350,950, 350,400, 350,400, 350,400, 300,450, 300,1000, 350,400, 300,450, 300,1000, 300,450, 300,400, 350,400, 350,1000, 300,400, 350,1000, 300,400, 350,1000, 300,450, 300,1000, 300,450, 300,1000, 300,450, 300,400, 350,400, 350,400, 350,950, 350,400, 350,400, 350,950, 350,950, 350,400, 350,400, 350,400, 350,950, 350,400, 350,950, 350,400, 350,400, 350,400, 300,1000, 350,400, 350,400, 300,1000, 300,1000, 350};
unsigned int Temp26[] = {4550,2550, 400,400, 300,1000, 350,950, 350,400, 350,950, 350,400, 350,400, 350,400, 300,450, 300,1000, 300,450, 300,400, 350,1000, 300,450, 300,400, 350,400, 350,950, 350,400, 350,950, 350,400, 350,1000, 300,400, 350,1000, 300,400, 350,1000, 300,400, 350,400, 350,400, 350,400, 350,950, 350,400, 350,400, 300,1000, 350,950, 350,400, 350,400, 350,400, 300,1000, 350,400, 350,950, 350,400, 350,400, 300,450, 300,1000, 300,450, 300,450, 300,1000, 300,1000, 350};
unsigned int Temp27[] = {4600,2500, 350,450, 300,1000, 350,950, 350,400, 350,950, 350,400, 350,400, 350,400, 350,400, 300,1000, 300,450, 300,450, 300,1000, 300,450, 300,400, 350,400, 350,400, 350,950, 350,1000, 300,400, 350,1000, 300,400, 350,1000, 300,450, 300,1000, 300,450, 300,400, 350,400, 350,400, 350,950, 350,400, 350,400, 350,950, 350,950, 350,400, 350,400, 350,400, 350,950, 350,400, 350,950, 350,400, 350,400, 350,400, 300,1000, 350,400, 300,450, 300,1000, 350,950, 350};
unsigned int Temp28[] = {4550,2550, 350,450, 300,1000, 300,1000, 350,400, 300,1000, 350,400, 350,400, 350,400, 300,450, 300,1000, 300,450, 300,400, 350,1000, 300,400, 350,400, 350,400, 350,400, 350,950, 350,950, 350,400, 350,950, 350,400, 350,1000, 300,400, 350,1000, 300,400, 350,400, 350,400, 350,400, 350,950, 350,400, 350,400, 300,1000, 350,950, 350,400, 350,400, 350,400, 300,1000, 350,400, 300,1000, 350,400, 350,400, 300,450, 300,1000, 300,450, 300,450, 300,1000, 300,1000, 300};
unsigned int Temp29[] = {4550,2550, 350,400, 350,1000, 300,1000, 300,450, 300,1000, 350,400, 350,400, 300,450, 300,400, 350,1000, 300,400, 350,400, 350,950, 350,400, 350,400, 350,400, 350,950, 350,950, 350,1000, 300,400, 350,1000, 300,450, 300,1000, 300,450, 300,1000, 300,450, 300,400, 350,400, 350,400, 350,950, 350,400, 350,400, 350,950, 350,1000, 300,400, 350,400, 350,400, 350,950, 350,400, 350,950, 350,400, 350,400, 350,400, 300,1000, 350,400, 350,400, 300,1000, 300,1000, 350};
unsigned int Temp30[] = {4600,2500, 400,400, 350,1000, 300,1000, 300,450, 300,1000, 300,450, 300,400, 350,400, 350,400, 350,950, 350,400, 350,400, 350,950, 350,400, 350,400, 350,400, 300,1000, 350,950, 350,950, 350,400, 350,1000, 300,400, 350,1000, 300,400, 350,1000, 300,400, 350,400, 350,400, 350,400, 350,950, 350,400, 350,400, 350,950, 350,950, 350,400, 350,400, 350,400, 300,1000, 350,400, 300,1000, 350,400, 350,400, 300,450, 300,1000, 300,450, 300,450, 300,1000, 300,1000, 350};
//Change it for your remote

IRsend irsend;

int Measured_temp;
int Measured_Humi;
int AC_Temp;
char temp_error = 2;
int Pev_value;
boolean AC = false;

int khz = 38; // 38kHz carrier frequency for the NEC protocol

void setup()
{
Serial.begin(9600);
display.begin(SSD1306_SWITCHCAPVCC);
display.clearDisplay();
}

void loop() {
  
  DHT.read11(DHT11_PIN); //Read the Temp and Humidity
  Measured_temp = DHT.temperature + temp_error;
  Measured_Humi = DHT.humidity;

// text display tests
  display.setTextSize(1);
  display.setTextColor(WHITE);
  display.setCursor(0,0);
  display.print("Temperature: "); display.print(Measured_temp);display.println("C");
  display.setCursor(0,10);
  display.print("Humidity: "); display.print(Measured_Humi);display.println("%");
  display.setCursor(0,20);
  display.print("AC Temp: "); display.print(AC_Temp);display.println("C");

  display.display();
  delay(500); 
  display.clearDisplay();
 
 if ((Measured_temp <= (Desired_temperature-3)) && AC == true) //If AC is turned on and temperature is less than 3 degree of Desired value #24 turn off
 {
  irsend.sendRaw(ACoff, sizeof(ACoff) / sizeof(ACoff[0]), khz);  delay(2000);//Send signal to Turn Off the AC
  AC_Temp = 0; AC=false;
 }

 if ((Measured_temp >= Desired_temperature+4) && AC == false) //If AC is off and measured Temp is greater than Desired Temp
 {
  irsend.sendRaw(ACon, sizeof(ACon) / sizeof(ACon[0]), khz); delay(2000); //Send Signal to Turn On the AC 
  delay(2000);
  irsend.sendRaw(Temp27, sizeof(Temp27) / sizeof(Temp27[0]), khz); //Send signal to set 27*C
  AC_Temp = 27; AC=true;
 }

if ( Measured_temp != Pev_value) //Change the temperature only if the measured voltage value changes
{

if (Measured_temp == Desired_temperature+3) //If AC is ON and measured temp is very very high than desired
{
   irsend.sendRaw(Temp24, sizeof(Temp24) / sizeof(Temp24[0]), khz); delay(2000);//Send signal to set 24*C
  AC_Temp = 24; 
}

if (Measured_temp == Desired_temperature+2) //If AC is ON and measured temp is very high than desired
{
   irsend.sendRaw(Temp25, sizeof(Temp25) / sizeof(Temp25[0]), khz); delay(2000);//Send signal to set 25*C
  AC_Temp = 25; 
}

if (Measured_temp == Desired_temperature+1) //If AC is ON and measured temp is very high than desired
{
   irsend.sendRaw(Temp26, sizeof(Temp26) / sizeof(Temp26[0]), khz); delay(2000);//Send signal to set 26*C
  AC_Temp = 26; 
}

if (Measured_temp == 27 ) //If AC is ON and measured temp is desired value
{
  irsend.sendRaw(Temp27, sizeof(Temp27) / sizeof(Temp27[0]), khz); //Send signal to set 27*C
  AC_Temp = 27; 
}

if (Measured_temp == Desired_temperature-1) //If AC is ON and measured temp is low than desired value
{
  irsend.sendRaw(Temp28, sizeof(Temp28) / sizeof(Temp28[0]), khz); delay(2000);//Send signal to set 28*C
  AC_Temp = 28; 
}

if (Measured_temp == Desired_temperature-2 ) //If AC is ON and measured temp is very low than desired value
{
  irsend.sendRaw(Temp29, sizeof(Temp29) / sizeof(Temp29[0]), khz); delay(2000);//Send signal to set 29*C
  AC_Temp = 29; 
}

if (Measured_temp == Desired_temperature-3 ) //If AC is ON and measured temp is very very low desired value
{
  irsend.sendRaw(Temp30, sizeof(Temp30) / sizeof(Temp30[0]), khz); delay(2000);//Send signal to set 30*C
  AC_Temp = 30; 
}

}
Pev_value = Measured_temp;
}

image

Hey, you asked for your martini dry... :slight_smile:

Thanks for the code tags. It is hard to decipher the code blocks without standard indentation:

/*
   Automatic AC Temperature control using Arduino and TSOP
   Code by: Aswinth Raj B
   Dated: 25-10-2017
   Website: www.circuitdigest.com

       S.No: Component Pin Arduino Pin
    1 OLED – Vcc  5V
    2 OLED – Gnd  Gnd
    3 OLED- SCK, D0,SCL,CLK 4
    4 OLED- SDA, D1,MOSI, Data  3
    5 OLED- RES, RST,RESET  7
    6 OLED- DC, A0  5
    7 OLED- CS, Chip Select 6
    8 DHT11 – Vcc 5V
    9 DHT11 – Gnd Gnd
    10  DHT11 – Signal  13
    11  TSOP – Vcc  5V
    12  TSOP – Gnd  Gnd
    13  IR Led – Anode  9
    14  IR Led – Cathode  Gnd
*/

#include <IRremote.h> //Lib for IT Blaster and TSOP
#include <SPI.h> // Inbuilt Lib
#include <Wire.h> //Inbuilt Lib
#include <Adafruit_GFX.h> //Lib for OLED
#include <Adafruit_SSD1306.h> //Lib for OLED
#include <dht.h> //Library for dht11 Temperature and Humidity sensor (Download from Link in article)

// Assign pins for OLED (Software config.)
#define OLED_MOSI  3
#define OLED_CLK   4
#define OLED_DC    5
#define OLED_CS    6
#define OLED_RESET 7
Adafruit_SSD1306 display(OLED_MOSI, OLED_CLK, OLED_DC, OLED_RESET, OLED_CS);

#define SSD1306_LCDHEIGHT 64 //Change if you are using a Different OLED
#define DHTTYPE DHT11   // DHT 
#define DHT11_PIN 13 //Sensor output pin is connected to pin 13
dht DHT; //Sensor object named as DHT

#define Desired_temperature 27 //The desired temperature is 27*C at any time

//Decoded Remote Signals For my AC ##CHANGE IT FOR YOUR REMOTE
unsigned int ACoff[] = {4600, 2500, 400, 400, 350, 950, 350, 950, 350, 400, 350, 1000, 300, 400, 350, 400, 350, 400, 350, 400, 350, 950, 350, 400, 300, 450, 300, 1000, 350, 400, 300, 450, 300, 450, 300, 400, 350, 1000, 300, 400, 350, 400, 350, 950, 350, 400, 350, 1000, 300, 400, 350, 1000, 300, 400, 350, 400, 350, 400, 350, 400, 350, 950, 350, 400, 350, 400, 350, 950, 350, 950, 350, 400, 350, 400, 350, 400, 350, 950, 350, 400, 300, 1000, 350, 400, 350, 400, 300, 450, 300, 1000, 300, 450, 300, 450, 300, 1000, 300, 1000, 350};
unsigned int ACon[] = {4600, 2500, 400, 400, 300, 1000, 350, 950, 350, 400, 350, 950, 350, 400, 350, 400, 350, 400, 300, 450, 300, 1000, 350, 400, 300, 450, 300, 1000, 300, 450, 300, 400, 350, 400, 350, 950, 350, 950, 350, 450, 300, 400, 350, 1000, 300, 400, 350, 1000, 300, 450, 300, 1000, 300, 450, 300, 400, 350, 400, 350, 400, 350, 950, 350, 400, 350, 400, 350, 950, 350, 900, 400, 400, 350, 400, 350, 400, 350, 950, 350, 400, 350, 950, 350, 400, 350, 400, 300, 450, 300, 1000, 350, 400, 300, 450, 300, 1000, 300, 1000, 350};
unsigned int Temp23[] = {4600, 2500, 400, 400, 350, 950, 350, 1000, 300, 400, 350, 1000, 300, 450, 300, 400, 350, 400, 350, 400, 350, 950, 350, 400, 350, 400, 350, 950, 350, 400, 350, 400, 300, 450, 300, 450, 300, 400, 350, 1000, 300, 400, 350, 1000, 300, 400, 350, 1000, 300, 450, 300, 1000, 300, 450, 300, 400, 350, 400, 350, 400, 350, 950, 350, 400, 350, 400, 350, 950, 350, 950, 350, 400, 350, 400, 350, 400, 350, 950, 350, 400, 350, 950, 350, 400, 350, 400, 350, 400, 300, 1000, 350, 400, 350, 400, 300, 1000, 350, 950, 350};
unsigned int Temp24[] = {4550, 2550, 350, 450, 300, 1000, 300, 1000, 350, 400, 350, 950, 350, 400, 350, 400, 300, 450, 300, 450, 300, 1000, 300, 450, 300, 400, 350, 1000, 300, 400, 350, 400, 350, 400, 350, 400, 350, 400, 350, 950, 350, 400, 300, 1000, 350, 400, 350, 950, 350, 400, 350, 950, 350, 400, 350, 400, 300, 450, 300, 450, 300, 1000, 300, 450, 300, 400, 350, 1000, 300, 1000, 350, 400, 300, 450, 300, 400, 350, 1000, 300, 400, 350, 1000, 300, 450, 300, 400, 350, 400, 350, 950, 350, 400, 350, 400, 350, 950, 350, 1000, 300};
unsigned int Temp25[] = {4550, 2550, 400, 400, 300, 1000, 350, 950, 350, 400, 350, 950, 350, 400, 350, 400, 350, 400, 300, 450, 300, 1000, 350, 400, 300, 450, 300, 1000, 300, 450, 300, 400, 350, 400, 350, 1000, 300, 400, 350, 1000, 300, 400, 350, 1000, 300, 450, 300, 1000, 300, 450, 300, 1000, 300, 450, 300, 400, 350, 400, 350, 400, 350, 950, 350, 400, 350, 400, 350, 950, 350, 950, 350, 400, 350, 400, 350, 400, 350, 950, 350, 400, 350, 950, 350, 400, 350, 400, 350, 400, 300, 1000, 350, 400, 350, 400, 300, 1000, 300, 1000, 350};
unsigned int Temp26[] = {4550, 2550, 400, 400, 300, 1000, 350, 950, 350, 400, 350, 950, 350, 400, 350, 400, 350, 400, 300, 450, 300, 1000, 300, 450, 300, 400, 350, 1000, 300, 450, 300, 400, 350, 400, 350, 950, 350, 400, 350, 950, 350, 400, 350, 1000, 300, 400, 350, 1000, 300, 400, 350, 1000, 300, 400, 350, 400, 350, 400, 350, 400, 350, 950, 350, 400, 350, 400, 300, 1000, 350, 950, 350, 400, 350, 400, 350, 400, 300, 1000, 350, 400, 350, 950, 350, 400, 350, 400, 300, 450, 300, 1000, 300, 450, 300, 450, 300, 1000, 300, 1000, 350};
unsigned int Temp27[] = {4600, 2500, 350, 450, 300, 1000, 350, 950, 350, 400, 350, 950, 350, 400, 350, 400, 350, 400, 350, 400, 300, 1000, 300, 450, 300, 450, 300, 1000, 300, 450, 300, 400, 350, 400, 350, 400, 350, 950, 350, 1000, 300, 400, 350, 1000, 300, 400, 350, 1000, 300, 450, 300, 1000, 300, 450, 300, 400, 350, 400, 350, 400, 350, 950, 350, 400, 350, 400, 350, 950, 350, 950, 350, 400, 350, 400, 350, 400, 350, 950, 350, 400, 350, 950, 350, 400, 350, 400, 350, 400, 300, 1000, 350, 400, 300, 450, 300, 1000, 350, 950, 350};
unsigned int Temp28[] = {4550, 2550, 350, 450, 300, 1000, 300, 1000, 350, 400, 300, 1000, 350, 400, 350, 400, 350, 400, 300, 450, 300, 1000, 300, 450, 300, 400, 350, 1000, 300, 400, 350, 400, 350, 400, 350, 400, 350, 950, 350, 950, 350, 400, 350, 950, 350, 400, 350, 1000, 300, 400, 350, 1000, 300, 400, 350, 400, 350, 400, 350, 400, 350, 950, 350, 400, 350, 400, 300, 1000, 350, 950, 350, 400, 350, 400, 350, 400, 300, 1000, 350, 400, 300, 1000, 350, 400, 350, 400, 300, 450, 300, 1000, 300, 450, 300, 450, 300, 1000, 300, 1000, 300};
unsigned int Temp29[] = {4550, 2550, 350, 400, 350, 1000, 300, 1000, 300, 450, 300, 1000, 350, 400, 350, 400, 300, 450, 300, 400, 350, 1000, 300, 400, 350, 400, 350, 950, 350, 400, 350, 400, 350, 400, 350, 950, 350, 950, 350, 1000, 300, 400, 350, 1000, 300, 450, 300, 1000, 300, 450, 300, 1000, 300, 450, 300, 400, 350, 400, 350, 400, 350, 950, 350, 400, 350, 400, 350, 950, 350, 1000, 300, 400, 350, 400, 350, 400, 350, 950, 350, 400, 350, 950, 350, 400, 350, 400, 350, 400, 300, 1000, 350, 400, 350, 400, 300, 1000, 300, 1000, 350};
unsigned int Temp30[] = {4600, 2500, 400, 400, 350, 1000, 300, 1000, 300, 450, 300, 1000, 300, 450, 300, 400, 350, 400, 350, 400, 350, 950, 350, 400, 350, 400, 350, 950, 350, 400, 350, 400, 350, 400, 300, 1000, 350, 950, 350, 950, 350, 400, 350, 1000, 300, 400, 350, 1000, 300, 400, 350, 1000, 300, 400, 350, 400, 350, 400, 350, 400, 350, 950, 350, 400, 350, 400, 350, 950, 350, 950, 350, 400, 350, 400, 350, 400, 300, 1000, 350, 400, 300, 1000, 350, 400, 350, 400, 300, 450, 300, 1000, 300, 450, 300, 450, 300, 1000, 300, 1000, 350};
//Change it for your remote

IRsend irsend;

int Measured_temp;
int Measured_Humi;
int AC_Temp;
char temp_error = 2;
int Pev_value;
boolean AC = false;

int khz = 38; // 38kHz carrier frequency for the NEC protocol

void setup()
{
  Serial.begin(9600);
  display.begin(SSD1306_SWITCHCAPVCC);
  display.clearDisplay();
}

void loop() {

  DHT.read11(DHT11_PIN); //Read the Temp and Humidity
  Measured_temp = DHT.temperature + temp_error;
  Measured_Humi = DHT.humidity;

  // text display tests
  display.setTextSize(1);
  display.setTextColor(WHITE);
  display.setCursor(0, 0);
  display.print("Temperature: "); display.print(Measured_temp); display.println("C");
  display.setCursor(0, 10);
  display.print("Humidity: "); display.print(Measured_Humi); display.println("%");
  display.setCursor(0, 20);
  display.print("AC Temp: "); display.print(AC_Temp); display.println("C");

  display.display();
  delay(500);
  display.clearDisplay();

  if ((Measured_temp <= (Desired_temperature - 3)) && AC == true) //If AC is turned on and temperature is less than 3 degree of Desired value #24 turn off
  {
    irsend.sendRaw(ACoff, sizeof(ACoff) / sizeof(ACoff[0]), khz);  delay(2000);//Send signal to Turn Off the AC
    AC_Temp = 0; AC = false;
  }

  if ((Measured_temp >= Desired_temperature + 4) && AC == false) //If AC is off and measured Temp is greater than Desired Temp
  {
    irsend.sendRaw(ACon, sizeof(ACon) / sizeof(ACon[0]), khz); delay(2000); //Send Signal to Turn On the AC
    delay(2000);
    irsend.sendRaw(Temp27, sizeof(Temp27) / sizeof(Temp27[0]), khz); //Send signal to set 27*C
    AC_Temp = 27; AC = true;
  }

  if ( Measured_temp != Pev_value) //Change the temperature only if the measured voltage value changes
  {

    if (Measured_temp == Desired_temperature + 3) //If AC is ON and measured temp is very very high than desired
    {
      irsend.sendRaw(Temp24, sizeof(Temp24) / sizeof(Temp24[0]), khz); delay(2000);//Send signal to set 24*C
      AC_Temp = 24;
    }

    if (Measured_temp == Desired_temperature + 2) //If AC is ON and measured temp is very high than desired
    {
      irsend.sendRaw(Temp25, sizeof(Temp25) / sizeof(Temp25[0]), khz); delay(2000);//Send signal to set 25*C
      AC_Temp = 25;
    }

    if (Measured_temp == Desired_temperature + 1) //If AC is ON and measured temp is very high than desired
    {
      irsend.sendRaw(Temp26, sizeof(Temp26) / sizeof(Temp26[0]), khz); delay(2000);//Send signal to set 26*C
      AC_Temp = 26;
    }

    if (Measured_temp == 27 ) //If AC is ON and measured temp is desired value
    {
      irsend.sendRaw(Temp27, sizeof(Temp27) / sizeof(Temp27[0]), khz); //Send signal to set 27*C
      AC_Temp = 27;
    }

    if (Measured_temp == Desired_temperature - 1) //If AC is ON and measured temp is low than desired value
    {
      irsend.sendRaw(Temp28, sizeof(Temp28) / sizeof(Temp28[0]), khz); delay(2000);//Send signal to set 28*C
      AC_Temp = 28;
    }

    if (Measured_temp == Desired_temperature - 2 ) //If AC is ON and measured temp is very low than desired value
    {
      irsend.sendRaw(Temp29, sizeof(Temp29) / sizeof(Temp29[0]), khz); delay(2000);//Send signal to set 29*C
      AC_Temp = 29;
    }

    if (Measured_temp == Desired_temperature - 3 ) //If AC is ON and measured temp is very very low desired value
    {
      irsend.sendRaw(Temp30, sizeof(Temp30) / sizeof(Temp30[0]), khz); delay(2000);//Send signal to set 30*C
      AC_Temp = 30;
    }

  }
  Pev_value = Measured_temp;
}

With those in place, maybe you can see the problem, I can make a good guess...

Thanks for that and thanks for replying to my message but I still don't know what the problem is. any idea why I can get temperature (-997C) and humidity (-999%) But when I try to check DHT11 using example DHTtester, the reading is different not like my project display temperature -997C and humidity -999C

DHTtester

// Example testing sketch for various DHT humidity/temperature sensors
// Written by ladyada, public domain

// REQUIRES the following Arduino libraries:
// - DHT Sensor Library: https://github.com/adafruit/DHT-sensor-library
// - Adafruit Unified Sensor Lib: https://github.com/adafruit/Adafruit_Sensor

#include "DHT.h"

#define DHTPIN 2     // Digital pin connected to the DHT sensor
// Feather HUZZAH ESP8266 note: use pins 3, 4, 5, 12, 13 or 14 --
// Pin 15 can work but DHT must be disconnected during program upload.

// Uncomment whatever type you're using!
#define DHTTYPE DHT11   // DHT 11
//#define DHTTYPE DHT22   // DHT 22  (AM2302), AM2321
//#define DHTTYPE DHT21   // DHT 21 (AM2301)

// Connect pin 1 (on the left) of the sensor to +5V
// NOTE: If using a board with 3.3V logic like an Arduino Due connect pin 1
// to 3.3V instead of 5V!
// Connect pin 2 of the sensor to whatever your DHTPIN is
// Connect pin 3 (on the right) of the sensor to GROUND (if your sensor has 3 pins)
// Connect pin 4 (on the right) of the sensor to GROUND and leave the pin 3 EMPTY (if your sensor has 4 pins)
// Connect a 10K resistor from pin 2 (data) to pin 1 (power) of the sensor

// Initialize DHT sensor.
// Note that older versions of this library took an optional third parameter to
// tweak the timings for faster processors.  This parameter is no longer needed
// as the current DHT reading algorithm adjusts itself to work on faster procs.
DHT dht(DHTPIN, DHTTYPE);

void setup() {
  Serial.begin(9600);
  Serial.println(F("DHTxx test!"));

  dht.begin();
}

void loop() {
  // Wait a few seconds between measurements.
  delay(2000);

  // Reading temperature or humidity takes about 250 milliseconds!
  // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
  float h = dht.readHumidity();
  // Read temperature as Celsius (the default)
  float t = dht.readTemperature();
  // Read temperature as Fahrenheit (isFahrenheit = true)
  float f = dht.readTemperature(true);

  // Check if any reads failed and exit early (to try again).
  if (isnan(h) || isnan(t) || isnan(f)) {
    Serial.println(F("Failed to read from DHT sensor!"));
    return;
  }

  // Compute heat index in Fahrenheit (the default)
  float hif = dht.computeHeatIndex(f, h);
  // Compute heat index in Celsius (isFahreheit = false)
  float hic = dht.computeHeatIndex(t, h, false);

  Serial.print(F("Humidity: "));
  Serial.print(h);
  Serial.print(F("%  Temperature: "));
  Serial.print(t);
  Serial.print(F("°C "));
  Serial.print(f);
  Serial.print(F("°F  Heat index: "));
  Serial.print(hic);
  Serial.print(F("°C "));
  Serial.print(hif);
  Serial.println(F("°F"));
}

Well, are you sure you want to do this every time through the loop() function?

actually I used coding from someone, Im new to arduino. thanks for correcting my mistake. do you have any idea what i need to type to fix it. I really appreciate your help. This is my last semester before my internship. Thank you reply to my message

That is disappointing. You passed up a good opportunity to learn important skills.

Look very carefully at the DHTtester code, which works.

Then look very carefully at the code which does not work, and by comparing the two, you might notice some important statements that were left out of the non-working code.

i forgot to fix before upload at forum but actually i already uncomment dht11 and comment dht22. sorry i put wrong code