Arduino MKR1010wifi OTA

This code works in the Arduino web editor but when I try to run it in the IoT cloud it doesn't work, I get error code. i want to be able to send the ota to the mkr1010wifi:

#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 = 54;
byte hours = 12;

byte day = 28;
byte month = 11;
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);
}

void updateRelay() {
  if ((hours >= 12 && minutes >= 57) && (hours <= 13 && minutes <= 5) || (hours >= 12 && minutes >= 25) && (hours <= 3 && minutes <= 45)) {
    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");
  }
}

My code in IoT Cloud:
/*
Sketch generated by the Arduino IoT Cloud Thing "Untitled 5"
https://create.arduino.cc/cloud/things/2c17f56f-d5c9-4e7b-a9fd-e552406086cf

Arduino IoT Cloud Variables description

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

bool ny28;

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 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 = 13;
byte hours = 15;

byte day = 28;
byte month = 11;
byte year = 23;

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

// 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()
{
if ((hours >= 15 && minutes >= 15) && (hours <= 15 && minutes <= 25) || (hours >= 15 && minutes >= 35) && (hours <= 15 && minutes <= 45)) {
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");
}
}

/*
Since Ny28 is READ_WRITE variable, onNy28Change() is
executed every time a new value is received from IoT Cloud.
*/
void onNy28Change() {
// Add your code here to act upon Ny28 change
// Add your code here to act upon Ws28 change
if(ny28 == 1){
digitalWrite(Relay2, HIGH);
delay(1000);

} else {

digitalWrite(Relay2, LOW);
delay(1000);
}
}

No information in that. Any error report?

Please post IoT code formatted and in code tags.

error:
/tmp/arduino-build-B2F3DFC32FA7FC7F1059A4D1BDE35D8B/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-B2F3DFC32FA7FC7F1059A4D1BDE35D8B/sketch/objs.a(ny28_nov28a.ino.cpp.o):/tmp/4153815609/ny28_nov28a/ny28_nov28a.ino:33: first defined here

collect2: error: ld returned 1 exit status

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

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 "ArduinoECCX08.h"

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

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

Error during build: exit status 1

/* 
  Sketch generated by the Arduino IoT Cloud Thing "Untitled 5"
  https://create.arduino.cc/cloud/things/2c17f56f-d5c9-4e7b-a9fd-e552406086cf 

  Arduino IoT Cloud Variables description

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

  bool ny28;

  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 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 = 13;
byte hours = 15;

byte day = 28;
byte month = 11;
byte year = 23;



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

  // 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() {
  if ((hours >= 15 && minutes >= 15) && (hours <= 15 && minutes <= 25) || (hours >= 15 && minutes >= 35) && (hours <= 15 && minutes <= 45)) {
    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");
  }
}


/*
  Since Ny28 is READ_WRITE variable, onNy28Change() is
  executed every time a new value is received from IoT Cloud.
*/
void onNy28Change() {
  // Add your code here to act upon Ny28 change
  // Add your code here to act upon Ws28 change
  if (ny28 == 1) {
    digitalWrite(Relay2, HIGH);
    delay(1000);

  } else {

    digitalWrite(Relay2, LOW);
    delay(1000);
  }
}

I guess it's not possible to transfer the code to my Arduino MKR 1010 wifi via iotcloud over the air. Then it's no use paying for a maker plan if you still have to connect it to your computer to load new sketches.

Late response but for anyone else having this issue:

As the error log states iotcloud already implements rtc and you can't define it twice.

You can just define it with an alternative name like this:

RTCZero rtclock;

It is important that you don't initialize it again via rtclock.run() as this will break update functionality.

You can just call the .get function after the definitions to get accurate time readings.