What does cloud code look like?

Ard nano esp32
following code is the template to the Cloud Blink
I can't understand it, it doesn't seem to direct the board to blink by using the switch

/* 
  Sketch generated by the Arduino IoT Cloud Thing "Cloud Blink"
  
  Arduino IoT Cloud Variables description

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

  bool led;

  Variables 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"

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);
  
  /*
     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();
  pinMode(LED_BUILTIN, OUTPUT);
}

void loop() {
  ArduinoCloud.update();
  digitalWrite(LED_BUILTIN, led);
}

/*
  Since Led is READ_WRITE variable, onLedChange() is
  executed every time a new value is received from IoT Cloud.
*/
void onLedChange()  {
  Serial.print("Led status changed:");
  Serial.println(led);
}

I don't see any switch. If the sketch works, then the 'magic' is in the ArduinoCloud.update();

The switch is in the cloud:

Does it work?

Yes, if I click on that switch, the built in LED on my Uno R4 WiFi turns on or off.

I also get a message on the serial monitor to tell me that the state has changed.

PERFECT, glad to see it works.

in the Serial Monitor:
ArduinoIoTCloudTCP::handle_ConnectMqttBroker could not connect to iot.arduino.cc:8884 Error: 5

So did you upload the exact same template I posted???

I tried loading the code that you posted.
When I tried to upload it , i got an error message saying that thingProperties.h could not be found.

After that I went to the cloud, and found the template called Cloud Blink. I used that to generate the code for me.
That code had tabs for "thingProperties.h" and "Sketch Secrets".

I used that to connect to the cloud.

I've just realised that I have an Arduino Nano ESP32, that has not been connected to the cloud before.
I'm just trying to connect it and upload the Cloud Blink template.

hi, yes that is the cloud generated template! It does have the secret code page and the .h file. It uploads ok but nothing is happening when i throw the switch. I am only getting an OFFLINE msg all the time

2 weeks ago i bought a ESP32-S3-DevKitC-1-N16R8 ESP32 S3 Development Board WiFi and nothing will recognize that not the IDE or the cloud, so i bought the arduino brand to make it easy, ha ha

I've just set up and connected my Nano ESP32 to the cloud, and used the same template.
It connected first time.

I've unplugged it from my PC, and reconnected it several times. Each time it re-connects to the cloud after I open the serial monitor.

It usually connects first time, but occasionally I get a message saying it hasn't connected and will retry in 4000ms. In that case, it has always connected on the second time.

I'm using my phone's WiFi to connect to the cloud. The Nano ESP32 is only about one metre away from the phone, so it gets a good signal.

ok, tnx, I'll start working on it as a connection problem.

ahhhh got it. deleted it all and reloaded a few time. working, thanks

Good to hear you've got it working, well done.