MKR Wifi 1010 Disconnecting From Network When ArduinoCloud.update() is called.

Hi, I got a MKR WiFi 1010 the other day and I'm having endless issues with it. I want to create an alarm system for my disabled mother incase she falls and is unable to get back up. I have a simple test script to figure out how to connect to my WiFi and ping google, both are working fine.
I then set up my MKR 1010 to work with the Arduino Cloud service, copied the thingProperties.h file that the online editor generated into my project file on my desktop, downloaded the necessary cloud libraries. However every time my script calls ArduinoCloud.update(), the MKR 1010 disconnects from my wifi. If I comment out that line, the MKR 1010 stays connected and contines to ping google without any issues but as soon as the code calls ArduinoCloud.update(), the Wifi connection drops again and it simply wont reconnect unless its commented out. I've tried everything I can think of but I still cant get it to work.

Could someone please have a look through the code below and tell me whats going on and how to fix this.

arduino_cloud_test.ino

#include <SPI.h>
#include <WiFiNINA.h>
#include <ArduinoIoTCloud.h>
#include <WiFiConnectionManager.h>
#include "thingProperties.h"

char ssid[] = "*REMOVED*";
char pass[] = "*REMOVED*";
int status = WL_IDLE_STATUS;

uint8_t WiFiLEDs = 0;
#define BLUE_LED    0b00000100
#define GREEN_LED   0b00000010
#define RED_LED     0b00000001



// Specify IP address or hostname
String hostName = "www.google.com";
int pingResult;



void setup() {
    // Initialize RGB LED
  WiFi.WiFiInitLEDs();
  // Set Red LED
  WiFi.WiFiRedLED(255);

  initProperties();
  ArduinoCloud.begin(ArduinoIoTPreferredConnection);
  setDebugMessageLevel(2);
  ArduinoCloud.printDebugInfo();
  
  //Initialize serial and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }

  // check for the presence of the shield:
  if (WiFi.status() == WL_NO_SHIELD) {
    Serial.println("WiFi shield not present");
    // don't continue:
    while (true);
  }

  String fv = WiFi.firmwareVersion();
  if (fv != "1.1.0") {
    Serial.println("Please upgrade the firmware");
  }
}



void SetWiFiLEDs( uint8_t pattern )
{
  WiFi.WiFiRedLED((pattern & 0b00000001)?HIGH:LOW);
  WiFi.WiFiGreenLED((pattern & 0b00000010)?HIGH:LOW);
  WiFi.WiFiBlueLED((pattern & 0b00000100)?HIGH:LOW);
 
}

void CheckWiFiStatus() {
  if (WiFi.status() == WL_CONNECTED) {
    WiFi.WiFiRedLED(0);
    WiFi.WiFiGreenLED(255);
  }
  else {
    WiFi.WiFiGreenLED(0);
    WiFi.WiFiRedLED(255);
    delay(500);
    WiFi.WiFiRedLED(0);
    delay(500);
    WiFi.WiFiRedLED(255);
    delay(500);
    WiFi.WiFiRedLED(0);
    delay(500);
    WiFi.WiFiRedLED(255);
    delay(500);
    WiFi.WiFiRedLED(0);
    delay(500);
    status = WiFi.begin(ssid, pass);
    //CheckWiFiStatus();
  }
}

void PingGoogle() {
  Serial.print("Pinging ");
  Serial.print(hostName);
  Serial.print(": ");

  pingResult = WiFi.ping(hostName);

  if (pingResult >= 0) {
    Serial.print("SUCCESS! RTT = ");
    Serial.print(pingResult);
    Serial.println(" ms");
  } else {
    Serial.print("FAILED! Error code: ");
    Serial.println(pingResult);
  }
}



void onAlarmPressedChange() {
  // Do something
}

void onAlertPressedChange() {
  
}

void onAcknowledged1Change() {
  // Do something
}

void onAcknowledged2Change() {
  // Do something
}

void onResetChange() {
  // Do something
}



void loop() {
  ArduinoCloud.update();  // this line causes mkr1010 to disconnect from wifi
  CheckWiFiStatus();
  PingGoogle();
  delay(5000);
}

thingProperties.h

#include <ArduinoIoTCloud.h>
#include <WiFiConnectionManager.h>

const char THING_ID[] = "*REMOVE*";

const char SSID[]     = "*REMOVED";    // Network SSID (name)
const char PASS[]     = "*REMOVED*";    // Network password (use for WPA, or use as key for WEP)

void onAlarmPressedChange();
void onAlertPressedChange();
void onAcknowledged1Change();
void onAcknowledged2Change();
void onResetChange();

int alarm_pressed;
int alert_pressed;
int acknowledged_1;
int acknowledged_2;
int reset;

void initProperties(){
  ArduinoCloud.setThingId(THING_ID);
  ArduinoCloud.addProperty(alarm_pressed, READWRITE, 1 * SECONDS, onAlarmPressedChange);
  ArduinoCloud.addProperty(alert_pressed, READWRITE, 1 * SECONDS, onAlertPressedChange);
  ArduinoCloud.addProperty(acknowledged_1, READWRITE, 1 * SECONDS, onAcknowledged1Change);
  ArduinoCloud.addProperty(acknowledged_2, READWRITE, 1 * SECONDS, onAcknowledged2Change);
  ArduinoCloud.addProperty(reset, READWRITE, 1 * SECONDS, onResetChange);
}

ConnectionManager *ArduinoIoTPreferredConnection = new WiFiConnectionManager(SSID, PASS);

I have updated the firmware on the arduino to version 1.2.1 and I'm using the latest version of the IDE. The Arduino is not in the black foam thing and is sitting on my desk, the only thing its connected to is the USB cable to my computer. The MKR1010 is also only about 6 feet away from my router.

Thanks for your time
Morgan

Try commenting out the following lines and see if the device still disconnects.

CheckWiFiStatus();
PingGoogle();

Also, in your set-up, I would move the WiFi lines to after the ArduinoCloud.begin call and add a delay(7000) before your code.
Ex

  ArduinoCloud.begin(ArduinoIoTPreferredConnection);
  delay(7000);
  // Set Red LED
  WiFi.WiFiInitLEDs();
  WiFi.WiFiRedLED(255);

However, the issue might just be a compatibility issue between the calls to WiFi and PingGoogle and the ArduinoCloud code.