No values seen in IoT cloud

The problem is that the h and t variables that are associated with the properties on your Arduino IoT Cloud dashboard are globals declared in the thingProperties.h tab. But the variables you are updating in your sketch are local variables named h and t that you declared in your loop function:

  float h = dht.readHumidity();
  float t = dht.readTemperature();

You are updating those variables, but they are not connected to your Arduino IoT Cloud dashboard, so you don't see anything happening there, because the global variables stay at their initial values of 0.00.

Although the two sets of variables have the same names, they are different. This is known as "variable shadowing", and is the cause of many a headache.

The solution is to not declare local variables h and t in loop(). Instead, just define the values of the global h and t variables:

  h = dht.readHumidity();
  t = dht.readTemperature();
4 Likes