No values seen in IoT cloud

Hi, I made a simple project and connected a temperature and humidity sensor (DHT11) to myWifi 1010. The serial monitor shows that the Wifi 1010 is connected to my router and to IoT cloud and it shows both values updated every 2 seconds. So far so good. But after configuration of the thing and properties nothing happened on the IoT cloud. It shows always 0 as a value for both. I am a bit desperate and don´t know what to do now. :confused: Could be the firewall a problem? Can someone please helt me!

Here my link https://create.arduino.cc/editor/Peter_Stuhr/a3ccf7a7-18b8-4ff1-b75d-a86f9cec6b66/preview

Warm regards Peter

Hi @Peter_Stuhr. Would you mind sharing your sketch so I can investigate this? If you click on the button with the three dots at the top of the Arduino Web Editor window, then click "Share Sketch", it will provide you with a link you can post here. It won't be possible for anyone to see the data you have in your Secret tab from the shared sketch.

/*
  Sketch generated by the Arduino IoT Cloud Thing "BeeControl"
  https://create.arduino.cc/cloud/things/80c3d7dd-2fcd-4d7d-947b-ada8a7616f52

  Arduino IoT Cloud Properties description

  The following variables are automatically generated and updated when changes are made to the Thing properties

  float t;
  float h;

  Properties which are marked as READ/WRITE in the Cloud Thing will also have functions
  which are called when their values are changed from the Dashboard.
  These functions are generated with the Thing and added at the end of this sketch.
*/

#include "thingProperties.h"
#include "DHT.h"
#define DHTPIN 2
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);



void setup() {
  // Initialize serial and wait for port to open:
  Serial.begin(9600);
  // This delay gives the chance to wait for a Serial Monitor without blocking if none is found
  delay(1500);

  // Defined in thingProperties.h
  initProperties();

  // Connect to Arduino IoT Cloud
  ArduinoCloud.begin(ArduinoIoTPreferredConnection);

  pinMode(LED_BUILTIN, OUTPUT);
  dht.begin();

  /*
     The following function allows you to obtain more information
     related to the state of network and IoT Cloud connection and errors
     the higher number the more granular information you’ll get.
     The default is 0 (only errors).
     Maximum is 4
  */
  setDebugMessageLevel(2);
  ArduinoCloud.printDebugInfo();
}

void loop() {
  ArduinoCloud.update();
  // Your code here

   digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);                       // wait for a second
  digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);                       // wait for a second

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

  Serial.print("Luftfeuchte: ");
  Serial.print(h);
  Serial.print("%  Temperatur: ");
  Serial.print(t);
  Serial.println("°C ");
}

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();

Thnaks a lot!!!! That was the fault. I would never have solved it on my own. You made my day :-)

You're welcome. I'm glad if I was able to be of assistance. Enjoy! Per