Go Down

Topic: Max 7219 4in1 DHT11 Temperature and Humidity not update (Read 366 times) previous topic - next topic

mohun74

Hi

I've successfully had made a scrolling text via the MAX7219 4in 1 with my DHT 11 sensor for temperature, Humidity, Heat index and Dew point temperature. But the temperature and humidity do not appear to update itself. See my code in the attachment below.

Contributions most welcomed.

PaulRB

Code: [Select]

}  // end of loop
//------------------------------------------------------------------------------------------
// Read New Values
//------------------------------------------------------------------------------------------
 //
    float h = dht.readHumidity();
  float t = dht.readTemperature();
  float f = dht.readTemperature(true);


  float hif = dht.computeHeatIndex(f, h);
  float hic = dht.computeHeatIndex(t, h, false);

//  ------------------------------------------------------------------------------------------
// -----------------------------------------------------------------------------------------
// ROUTINES TO GET THE BRIGHTNESS AND SPEED FROM ANALOG PORTS A0 & A1 (10K POT)
// Wire up the potentiometers thus: +ve to one end, -ve to other end, analog pin to centre
// Note that the brightness control requires the updated library from Ralph S Bacon to work
// -----------------------------------------------------------------------------------------
void getDelay(unsigned long int *delayVar) {


Your code never updates the temp/humidity. You have cut & pasted code together from different sketches without understanding the C language.

That's happening right now is that the variables h, t, f, hif & hic are declared globally and initialised as the sketch starts to run by calling the dht library methods. This may not work correctly because dht.begin() has not been called yet.

Next, setup() runs and calls dht.begin(). Then it declares h, t, f, hif & hic as local variables (different variables to the global ones, even though they share the same names) and initialises them by calling the dht library methods. It prints the values to serial monitor. Then setup() ends and the local variables and their values are lost.

Nothing in loop() updates the h, t, f, hif and hic variables, so the display never updates.


Go Up