Trouble with variable types and integrating DHT11 temperature sensor

I am trying to modify this sketch;

But I have a different temperature sensor, a DHT11, and I am using the libraries from Adafruit.

The DHT11 can't be constantly polled, 1 second intervals is the maximum rate.

I am currently working (fighting) with the portion towards the bottom in the section:

boolean getTemp() {

As my sketch stands, I have "currentTemp" statically assigned to 79 degrees. When I upload, the arduino acts as I would expect it to given that data.

If I change it to 0 (zero) and try to set the temp by reading the sensor in the section starting at line 237 like this;

boolean getTemp() {

  currentTemp = 0;
  long temp = 0;
 
  if ((millis() - TempLastCheck) > 2000) {
    TempLastCheck = millis();
    //  currentTemp = dht.readTemperature(true);
      temp = dht.readTemperature(true);
     Serial.println(dht.readTemperature(true));
  }

The LCD is blank after it restarts, and the arduino triggers the "heat" relay because the temperature is 0 (zero)

I'm sure I'm missing something simple, because the DHT11 outputs floats, or something... I'm too new to this language to know what I'm missing. Any help will be greatly appreciated.

Full sketch;

(I tried to paste it in code blocks but it's too long for the forum)

You probably need to post all of your code, as just posting one function that only prints the temperature if its not printed it in the last 2000ms is not what 99% of your project appears to do.

I did post it via the github gists link. The code is too long to post in a single message. I

Sorry. Didn't notice that link was to code

Anyone? I could use a hand.

Hi

    //  currentTemp = dht.readTemperature(true);
      temp = dht.readTemperature(true);
     Serial.println(dht.readTemperature(true));

What do you see from the Serial.println() statement?

Not sure it matters, but you are printing a second reading of the sensor, not the value you capture in temp.

I guess this was just a test version of the code, because you have commented out the assignment to the global variable currentTemp and temp is a local variable in the function.

Regards

Ray

Here's where I am now: HVAC_Control · GitHub

The LCD updates and the serial output all looks as I would expect it to.

temp:        73
CurrentTemp: 71
OldTemp:     71

temp:        71
CurrentTemp: 73
OldTemp:     73

temp:        71
CurrentTemp: 71
OldTemp:     71

temp:        71
CurrentTemp: 71
OldTemp:     71