Connected to Arduino IoT Cloud sequencing

Is there any way to easily track what ArduinoCloud.update(); is going in a void loop, and determine why code is executed in a strange priority? I want code to run only after the device has received the "Connected to Arduino IoT Cloud" message. But cannot seem to work out how.

The following code seems to do a check for 'connected' status' , but also runs before I receive the "Connected to Arduino IoT Cloud" message in the serial monitor. I need to trigger stop triggers to a roller shutter that is set to 'close' when the unit is reset/looses connection to the IoT cloud.

void loop() {
  ArduinoCloud.update();
  if ((ArduinoCloud.connected() == 0) && (cloud_check=true)) {
    digitalWrite(BUILTIN_LED, !digitalRead(LED_BUILTIN));
    digitalWrite(RS_STOP, HIGH);
    delay(500);
    digitalWrite(RS_STOP, LOW);
  } else {
    
  }
  if ((ArduinoCloud.connected() == 1) && initializestop == false) {
      Serial.print("Delay 4 sec");
      delay(4000);
      digitalWrite(RS_STOP, HIGH);
      delay(1000);
      digitalWrite(RS_STOP, HIGH);
      delay(1000);
      digitalWrite(RS_STOP, HIGH);
      delay(1000);
      digitalWrite(RS_STOP, LOW);
      Serial.print("Set to true");
      initializestop = true;
    }
  
}

I've tried setting things to delay, but that delay just makes the "Connected to Arduino IoT Cloud" part of the initialization take longer and I get the following:

******** Arduino IoT Cloud - configuration info *****
Device ID: **********-8086-4ba8-adc1-88888888
Thing ID: *********-40ee-bd56-8888888888
MQTT Broker: mqtts-up.iot.arduino.cc:8884
WiFi status ESP: 3
Connection to "WiFi" failed
Retrying in  "500" milliseconds
Connection to "WiFi" failed
Retrying in  "500" milliseconds
Connected to "WiFi"
Delay 4 secSet to trueConnected to Arduino IoT Cloud

I'm not sure if it's the reason, but how do I get the once off triggers to run after that "Connected to .. " message?

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.