Arduino MKR 1010 wifi OTA

why is this code not working in Arduino iot cloud. I want to broadcast it over the air.

/* 
  Sketch generated by the Arduino IoT Cloud Thing "Untitled"
  https://create.arduino.cc/cloud/things/971ca962-22e2-4336-940a-0668a8cc1d6e 

  Arduino IoT Cloud Variables description

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

  - No variables have been created, add cloud variables on the Thing Setup page
    to see them declared here

  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"

#include <RTCZero.h>
#include <FastLED.h>
#define NUM_LEDS 12
#define DATA_PIN 8
#define COLOR_ORDER GRB
#define CHIPSET WS2812B
#define BRIGHTNESS 50
#define VOLTS 5
#define MAX_AMPS 500
CRGB leds[NUM_LEDS];

int Relay = 4;

RTCZero rtc;

// Removed the const keyword so the variables can be updated
byte seconds = 00;
byte minutes = 29;
byte hours = 5;

byte day = 4;
byte month = 12;
byte year = 23;

int OnTime = 330;
int OnTime2 = 1020;
int OffTime1 = 480;
int OffTime2 = 1380;

//5:30=330 min
//8=480 min
//17=1020 min
//23=1380 min

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);
  rtc.begin();  // initialize RTC

  pinMode(Relay, OUTPUT);
  digitalWrite(Relay, LOW);

  rtc.setHours(hours);
  rtc.setMinutes(minutes);
  rtc.setSeconds(seconds);

  rtc.setDay(day);
  rtc.setMonth(month);
  rtc.setYear(year);

  FastLED.addLeds<CHIPSET, DATA_PIN, COLOR_ORDER>(leds, NUM_LEDS);
  FastLED.setMaxPowerInVoltsAndMilliamps(VOLTS, MAX_AMPS);
  FastLED.setBrightness(BRIGHTNESS);
  FastLED.clear();
  FastLED.show();

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

void loop() {
  ArduinoCloud.update();
  // Your code here
  print2digits(rtc.getDay());
  Serial.print("/");
  print2digits(rtc.getMonth());
  Serial.print("/");
  print2digits(rtc.getYear());
  Serial.print(" ");

  print2digits(hours = rtc.getHours());  // We update the hours variable like this here
  Serial.print(":");
  print2digits(minutes = rtc.getMinutes());  // We update the minutes variable like this here
  Serial.print(":");
  print2digits(rtc.getSeconds());

  Serial.println();

  updateRelay();  // we update the relay here

  delay(1000);
}

void print2digits(int number) {
  if (number < 10) {
    Serial.print("0");  // print a 0 before if the number is < than 10
  }
  Serial.print(number);
}

// moved the relay code to it's own function
void updateRelay() {
  int mOnTime = hours * 60 + minutes;
  if ((mOnTime >= OnTime && mOnTime <= OffTime1) || (mOnTime >= OnTime2 && mOnTime <= OffTime2)) {
    digitalWrite(Relay, HIGH);
    Serial.println("LIGHT ON");
    for (int i = 0; i < NUM_LEDS; i++) {
      leds[i] = CRGB::White;
      FastLED.show();
      delay(50);
    }
  } else {
    digitalWrite(Relay, LOW);
    Serial.println("LIGHT OFF");
  }
}

error:
/tmp/arduino-build-8B624260B310D30CEEC2B0CEA720CE7F/libraries/arduinoiotcloud_1_13_0/utility/time/objs.a(TimeService.cpp.o):/home/builder/Arduino/libraries/arduinoiotcloud_1_13_0/src/utility/time/TimeService.cpp:50: multiple definition of `rtc'

/tmp/arduino-build-8B624260B310D30CEEC2B0CEA720CE7F/sketch/objs.a(M28_dec06a.ino.cpp.o):/tmp/175576726/M28_dec06a/M28_dec06a.ino:33: first defined here

collect2: error: ld returned 1 exit status

Multiple libraries were found for "ArduinoECCX08.h"

Used: /home/builder/opt/libraries/arduinoeccx08_1_3_7

Not used: /home/builder/opt/libraries/rak5814_atecc608a_1_0_0

Multiple libraries were found for "FastLED.h"

Used: /mnt/create-efs/webide/6c/16/6c16139d93af413f0e0af98009fabefd:ulfer/libraries_v2/FastLED

Not used: /home/builder/opt/libraries/fastled_3_6_0

Multiple libraries were found for "SPI.h"

Used: /home/builder/.arduino15/packages/arduino/hardware/samd/1.8.13/libraries/SPI

Not used: /home/builder/opt/libraries/eventethernet_1_0_0

Multiple libraries were found for "WiFiNINA.h"

Used: /home/builder/opt/libraries/wifinina_1_8_14

Not used: /home/builder/opt/libraries/vega_wifinina_1_0_1

Error during build: exit status 1

rename your rtc instance.

how do you mean?

this code works in arduino web, it's almost the same as the one i want to send over the air.

#include <RTCZero.h>
#include <FastLED.h>
#define NUM_LEDS 12
#define DATA_PIN 8
#define COLOR_ORDER GRB
#define CHIPSET WS2812B
#define BRIGHTNESS 40
#define VOLTS 5
#define MAX_AMPS 500
CRGB leds[NUM_LEDS];

int Relay = 4;
int Relay2 = 7;

RTCZero rtc;

// Removed the const keyword so the variables can be updated
byte seconds = 00;
byte minutes = 48;
byte hours = 14;

byte day = 1;
byte month = 12;
byte year = 23;

void setup() {
  Serial.begin(9600);

  rtc.begin();  // initialize RTC

  pinMode(Relay, OUTPUT);
  digitalWrite(Relay, LOW);
  pinMode(Relay2, OUTPUT);
  digitalWrite(Relay2, LOW);

  rtc.setHours(hours);
  rtc.setMinutes(minutes);
  rtc.setSeconds(seconds);

  rtc.setDay(day);
  rtc.setMonth(month);
  rtc.setYear(year);

  FastLED.addLeds<CHIPSET, DATA_PIN, COLOR_ORDER>(leds, NUM_LEDS);
  FastLED.setMaxPowerInVoltsAndMilliamps(VOLTS, MAX_AMPS);
  FastLED.setBrightness(BRIGHTNESS);
  FastLED.clear();
  FastLED.show();
}

void loop() {

  print2digits(rtc.getDay());
  Serial.print("/");
  print2digits(rtc.getMonth());
  Serial.print("/");
  print2digits(rtc.getYear());
  Serial.print(" ");

  print2digits(hours = rtc.getHours());  // We update the hours variable like this here
  Serial.print(":");
  print2digits(minutes = rtc.getMinutes());  // We update the minutes variable like this here
  Serial.print(":");
  print2digits(rtc.getSeconds());

  Serial.println();

  updateRelay();  // we update the relay here

  delay(1000);
}

void print2digits(int number) {
  if (number < 10) {
    Serial.print("0");  // print a 0 before if the number is < than 10
  }
  Serial.print(number);
}

// moved the relay code to it's own function
void updateRelay() {
  if ((hours >= 14 && minutes >= 48) && (hours <= 14 && minutes <= 55) || (hours >= 16 && minutes >= 55) && (hours <= 16 && minutes <= 59)) {
    digitalWrite(Relay, HIGH);
    digitalWrite(Relay2, HIGH);
    Serial.println("LIGHT ON");
    for (int i = 0; i < NUM_LEDS; i++) {
      leds[i] = CRGB::White;
      FastLED.show();
      delay(50);
    }
  } else {
    digitalWrite(Relay, LOW);
    digitalWrite(Relay2, LOW);
    Serial.println("LIGHT OFF");
  }
}

the name rtc is taken by the Cloud library. you have to use a different name for the RTC object

thanks