DHT11 temperature/humidity sensor not updating on Arduino Uno

Trying to program a way to turn my thermostat smarter by interfacing it with my Arduino Uno. I am using a DHT11 to read temperatures and humidity. However, after making its first reading, it is not updating after that. I have included the reading in a loop that waits 2.5 seconds between readings to give the sensor time. However, its not updating. I tested the DHT11 with the example code that came with the library and it is in itself functioning.

I have included the code below. Any help greatly appreciated! (sorry if the code is a bit messy, I am a novice programmer)

#include <LiquidCrystal.h>
#include <dht.h>

dht DHT;

#define DHT11_PIN 8
#define BOUNCE_DURATION 400
unsigned long checkLCD = 0;
volatile unsigned long bounceTime = 0;
unsigned long refreshBut = millis();
volatile int desiredTemp = 21;
boolean AC_on = true;
unsigned long checkBut = 0;
int temp = 0;
int humi = 0;
unsigned long lastTime = 0;
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 10, 9);


void setup() {
  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
  Serial.begin(9600);
  // Print a message to the LCD.
  lcd.print("DHT test");
  Serial.println("DHT TEST Type,\tstatus,\tHumidity (%),\tTemperature (C)");
  pinMode(3, INPUT_PULLUP);
  pinMode(2, INPUT_PULLUP);
  pinMode(13, OUTPUT);
  pinMode(A1, INPUT_PULLUP);
  testDHT(); // testing DHT sensor

}


void loop() {
   if (millis() > lastTime)
  {
    temp = DHT.temperature;
    humi = DHT.humidity;
    lastTime = millis() + 2500;
    Serial.println(temp);
  }
  
  
  
  int luxSEND = -0.066433 * analogRead(A0) + 81.467234; //lux reading
  unsigned long refreshLCD = millis();
  int upBut = digitalRead(2); //up button
  int downBut = digitalRead(3); //down button
  int changeAC_send = digitalRead(A1);//read button for change between heating and AC
  unsigned long refreshBut = millis(); //for button for change between heating and AC

  displayReadings(humi, temp, luxSEND, refreshLCD, desiredTemp); //display on LCD - humidity, temperature, lux

  attachInterrupt(digitalPinToInterrupt(2), upButtonOn, FALLING);//Up in desired temp
  attachInterrupt(digitalPinToInterrupt(3), downButtonOn, FALLING);//Down in desired temp

  changeAC_on (changeAC_send, refreshBut); //change between heating and AC

  if ((temp > desiredTemp) && (AC_on == true)) { //AC structure
    digitalWrite(13, HIGH);

  }
  else if ((temp < desiredTemp) && (AC_on == false)) { //Heat Structure
    digitalWrite(13, HIGH);

  }
  else {
    digitalWrite(13, LOW);

  }
}

void displayReadings (int h, int t, int lux, unsigned long refreshL, int desiT) {
  if (refreshL >= (1000 + checkLCD)) {
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("T:");
    lcd.print(t);
    lcd.print("C  ");
    lcd.print("H:");
    lcd.print(h);
    lcd.print("%");
    Serial.print(h, 1);
    Serial.print(",\t");
    Serial.print(t, 1);
    Serial.print(",\t");
    lcd.setCursor(0, 1);
    lcd.print("L:");
    lcd.print(lux);
    lcd.print("   ");
    Serial.println(lux);
    Serial.print(",\t");
    lcd.print("Des.T:");
    lcd.print(desiT);
    lcd.print("C");
    checkLCD = refreshL;
  }

}

void testDHT () {
  // READ DATA
  lcd.clear();
  Serial.print("DHT11, \t");
  int chk = DHT.read11(DHT11_PIN);
  switch (chk)
  {
    case DHTLIB_OK:
      Serial.print("OK,\t");
      break;
    case DHTLIB_ERROR_CHECKSUM:
      Serial.print("Checksum error,\t");
      lcd.clear();
      lcd.setCursor(0, 0);
      lcd.print("Can't get reading");
      lcd.setCursor(0, 1);
      lcd.print("from DHT");
      while (1);
      break;
    case DHTLIB_ERROR_TIMEOUT:
      Serial.print("Time out error,\t");
      lcd.clear();
      lcd.setCursor(0, 0);
      lcd.print("Can't get reading");
      lcd.setCursor(0, 1);
      lcd.print("from DHT");
      while (1);
      break;
    default:
      Serial.print("Unknown error,\t");
      lcd.clear();
      lcd.setCursor(0, 0);
      lcd.print("Can't get reading");
      lcd.setCursor(0, 1);
      lcd.print("from DHT");
      while (1);
      break;
  }
}

void upButtonOn () {
  if (millis() > bounceTime) {
    Serial.println("Up Pressed");
    desiredTemp = desiredTemp + 1;
    bounceTime = millis() + BOUNCE_DURATION;
  }
}

void downButtonOn () {
  if (millis() > bounceTime) {
    Serial.println("Down Pressed");
    desiredTemp = desiredTemp - 1;
    bounceTime = millis() + BOUNCE_DURATION;
  }

}

void changeAC_on (int changeAC, unsigned long refL) {
  if (refL >= (200 + checkBut)) {

    if ((changeAC == LOW) && (AC_on == true)) {
      lcd.clear();
      lcd.setCursor(0, 0);
      lcd.print("HEATING MODE");
      Serial.println("Heat On");
      AC_on = false;
      checkBut = refL;
    }

    else if ((changeAC == LOW) && (AC_on == false)) {
      lcd.clear();
      lcd.setCursor(0, 0);
      lcd.print("A/C MODE");
      Serial.println("AC On");
      AC_on = true;
      checkBut = refL;
    }
    else {
      checkBut = refL;
    }
  }
}
while (1);

You know what this line does? It "freezes" your Arduino. It's an endless empty loop. Remove all these lines and try again. If it still does not work, post the new code again and the also the output it produces.

Thanks for the reply.

The while (1) loops are only in the error checking routine and only run when there is an error with the DHT module. Either way, I have removed them and the same problem persists, the system will not update the temperature or humidity after an initial reading. As another point I forgot to mention, the photoresistor in the system will update its lux readings the whole time.

To test it I have directed a warm hairdryer to the DHT sensor, but the readings dont change. However, when I reset it, the sensor will then show the higher reading initially but then wont update like before.

Here is the updated code without the while(1) loops:

#include <LiquidCrystal.h>
#include <dht.h>

dht DHT;

#define DHT11_PIN 8
#define BOUNCE_DURATION 400
unsigned long checkLCD = 0;
volatile unsigned long bounceTime = 0;
unsigned long refreshBut = millis();
volatile int desiredTemp = 21;
boolean AC_on = true;
unsigned long checkBut = 0;
int temp = 0;
int humi = 0;
unsigned long lastTime = 0;
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 10, 9);


void setup() {
  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
  Serial.begin(9600);
  // Print a message to the LCD.
  lcd.print("DHT test");
  Serial.println("DHT TEST Type,\tstatus,\tHumidity (%),\tTemperature (C)");
  pinMode(3, INPUT_PULLUP);
  pinMode(2, INPUT_PULLUP);
  pinMode(13, OUTPUT);
  pinMode(A1, INPUT_PULLUP);
  testDHT(); // testing DHT sensor

}


void loop() {
   if (millis() > lastTime)
  {
    temp = DHT.temperature;
    humi = DHT.humidity;
    lastTime = millis() + 2500;
    Serial.print("Current read temperature is: ");
    Serial.println(temp);
  }
  
  
  
  int luxSEND = -0.066433 * analogRead(A0) + 81.467234; //lux reading
  unsigned long refreshLCD = millis();
  int upBut = digitalRead(2); //up button
  int downBut = digitalRead(3); //down button
  int changeAC_send = digitalRead(A1);//read button for change between heating and AC
  unsigned long refreshBut = millis(); //for button for change between heating and AC

  displayReadings(humi, temp, luxSEND, refreshLCD, desiredTemp); //display on LCD - humidity, temperature, lux

  attachInterrupt(digitalPinToInterrupt(2), upButtonOn, FALLING);//Up in desired temp
  attachInterrupt(digitalPinToInterrupt(3), downButtonOn, FALLING);//Down in desired temp

  changeAC_on (changeAC_send, refreshBut); //change between heating and AC

  if ((temp > desiredTemp) && (AC_on == true)) { //AC structure
    digitalWrite(13, HIGH);

  }
  else if ((temp < desiredTemp) && (AC_on == false)) { //Heat Structure
    digitalWrite(13, HIGH);

  }
  else {
    digitalWrite(13, LOW);

  }
}

void displayReadings (int h, int t, int lux, unsigned long refreshL, int desiT) {
  if (refreshL >= (1000 + checkLCD)) {
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("T:");
    lcd.print(t);
    lcd.print("C  ");
    lcd.print("H:");
    lcd.print(h);
    lcd.print("%");
    Serial.print(h, 1);
    Serial.print(",\t");
    Serial.print(t, 1);
    Serial.print(",\t");
    lcd.setCursor(0, 1);
    lcd.print("L:");
    lcd.print(lux);
    lcd.print("   ");
    Serial.println(lux);
    Serial.print(",\t");
    lcd.print("Des.T:");
    lcd.print(desiT);
    lcd.print("C");
    checkLCD = refreshL;
  }

}

void testDHT () {
  // READ DATA
  lcd.clear();
  Serial.print("DHT11, \t");
  int chk = DHT.read11(DHT11_PIN);
  switch (chk)
  {
    case DHTLIB_OK:
      Serial.print("OK,\t");
      break;
    case DHTLIB_ERROR_CHECKSUM:
      Serial.print("Checksum error,\t");
      lcd.clear();
      lcd.setCursor(0, 0);
      lcd.print("Can't get reading");
      lcd.setCursor(0, 1);
      lcd.print("from DHT");
      break;
    case DHTLIB_ERROR_TIMEOUT:
      Serial.print("Time out error,\t");
      lcd.clear();
      lcd.setCursor(0, 0);
      lcd.print("Can't get reading");
      lcd.setCursor(0, 1);
      lcd.print("from DHT");
      break;
    default:
      Serial.print("Unknown error,\t");
      lcd.clear();
      lcd.setCursor(0, 0);
      lcd.print("Can't get reading");
      lcd.setCursor(0, 1);
      lcd.print("from DHT");
      break;
  }
}

void upButtonOn () {
  if (millis() > bounceTime) {
    Serial.println("Up Pressed");
    desiredTemp = desiredTemp + 1;
    bounceTime = millis() + BOUNCE_DURATION;
  }
}

void downButtonOn () {
  if (millis() > bounceTime) {
    Serial.println("Down Pressed");
    desiredTemp = desiredTemp - 1;
    bounceTime = millis() + BOUNCE_DURATION;
  }

}

void changeAC_on (int changeAC, unsigned long refL) {
  if (refL >= (200 + checkBut)) {

    if ((changeAC == LOW) && (AC_on == true)) {
      lcd.clear();
      lcd.setCursor(0, 0);
      lcd.print("HEATING MODE");
      Serial.println("Heat On");
      AC_on = false;
      checkBut = refL;
    }

    else if ((changeAC == LOW) && (AC_on == false)) {
      lcd.clear();
      lcd.setCursor(0, 0);
      lcd.print("A/C MODE");
      Serial.println("AC On");
      AC_on = true;
      checkBut = refL;
    }
    else {
      checkBut = refL;
    }
  }
}

As well here is the output from the serial monitor, while a hairdryer is being directed at it:

DHT TEST Type,	status,	Humidity (%),	Temperature (C)
DHT11, 	OK,	Current read temperature is: 29
40,	29,	53
,	40,	29,	53
,	Current read temperature is: 29
40,	29,	53
,	40,	29,	53
,	40,	29,	53
,	Current read temperature is: 29
40,	29,	54
,	40,	29,	54
,	Current read temperature is: 29
40,	29,	52
,	40,	29,	53
,	40,	29,	53
,	Current read temperature is: 29
40,	29,	53
,	40,	29,	53
,	Current read temperature is: 29
40,	29,	53
,	40,	29,	53
,	40,	29,	53
,	Current read temperature is: 29
40,	29,	53
,	40,	29,	53
,	Current read temperature is: 29
40,	29,	53
,	40,	29,	51
,	40,	29,	52
,	Current read temperature is: 29
40,	29,	52
,	40,	29,	52
,	Current read temperature is: 29
40,	29,	54
,	40,	29,	54
,	40,	29,	54
,	Current read temperature is: 29
40,	29,	53
,	40,	29,	54
,	Current read temperature is: 29
40,	29,	53
,	40,	29,	53
,	40,	29,	54
,	Current read temperature is: 29
40,	29,	54
,	40,	29,	54
,	Current read temperature is: 29
40,	29,	54
,	40,	29,	54
,	40,	29,	54
,	Current read temperature is: 29
40,	29,	54
,	40,	29,	54

No I understand the problem. BTW the link to the used library is missing, but I guess your problem exists because you do the measurement only once, here:

  int chk = DHT.read11(DHT11_PIN);

That code is called at the end of the setup() routine and never again in the loop().