MKR NB 1500 Cloud, Main Loop executes only 3 times

I had most of my program and dashboard working great. Then something happened to cause the main loop to execute exactly three times, pause, and reboot. In addition, ArduinoCloud.connected() is always zero even though I see the message "Connected to GPRS Network" printed on the serial monitor. I have stripped down the program to the minimum and the same behavior exists.

Also, it is almost impossible to make changes and download the changed sketch because the board is constantly rebooting while the programming is taking place.

Any ideas? This is driving me crazy... Here is the stripped down code that does the same as my full code did:

/*
  Sketch generated by the Arduino IoT Cloud Thing "GreenWater1"
  https://create.arduino.cc/cloud/things/ce2b5a40-be10-4f62-a207-d3bc5e5058ef

  Arduino IoT Cloud Variables description

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

  String status;
  int area1;
  int area2;
  int area3;
  int boardO3analog;
  int number1;
  int number2;
  int number3;
  int prefix1;
  int prefix2;
  int prefix3;
  int pressureOut;
  int pressureVgas;
  int pressureVin;
  int pressureVout;
  bool boardO3alarm;
  bool savenumbers;
  bool sendtesttextnow;
  bool sendtext1;
  bool sendtext2;
  bool sendtext3;

  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"
int i = 0;

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

}

void loop() {
  ArduinoCloud.update();
  // Your code here
  Serial.print("\n(");
  Serial.print(i);
  Serial.print(") loopConnected= ");
  Serial.print(ArduinoCloud.connected());
  i++;
  delay(500);
}

/*
  Since Status is READ_WRITE variable, onStatusChange() is
  executed every time a new value is received from IoT Cloud.
*/
void onStatusChange()  {
  // Add your code here to act upon Status change
  Serial.print("Status=");
  Serial.println(status);
}
/*
  Since Area1 is READ_WRITE variable, onArea1Change() is
  executed every time a new value is received from IoT Cloud.
*/
void onArea1Change()  {
  // Add your code here to act upon Area1 change
}
/*
  Since Area2 is READ_WRITE variable, onArea2Change() is
  executed every time a new value is received from IoT Cloud.
*/
void onArea2Change()  {
  // Add your code here to act upon Area2 change
}
/*
  Since Area3 is READ_WRITE variable, onArea3Change() is
  executed every time a new value is received from IoT Cloud.
*/
void onArea3Change()  {
  // Add your code here to act upon Area3 change
}
/*
  Since Number1 is READ_WRITE variable, onNumber1Change() is
  executed every time a new value is received from IoT Cloud.
*/
void onNumber1Change()  {
  // Add your code here to act upon Number1 change
}
/*
  Since Number2 is READ_WRITE variable, onNumber2Change() is
  executed every time a new value is received from IoT Cloud.
*/
void onNumber2Change()  {
  // Add your code here to act upon Number2 change
}
/*
  Since Number3 is READ_WRITE variable, onNumber3Change() is
  executed every time a new value is received from IoT Cloud.
*/
void onNumber3Change()  {
  // Add your code here to act upon Number3 change
}
/*
  Since Prefix1 is READ_WRITE variable, onPrefix1Change() is
  executed every time a new value is received from IoT Cloud.
*/
void onPrefix1Change()  {
  // Add your code here to act upon Prefix1 change
}
/*
  Since Prefix2 is READ_WRITE variable, onPrefix2Change() is
  executed every time a new value is received from IoT Cloud.
*/
void onPrefix2Change()  {
  // Add your code here to act upon Prefix2 change
}
/*
  Since Prefix3 is READ_WRITE variable, onPrefix3Change() is
  executed every time a new value is received from IoT Cloud.
*/
void onPrefix3Change()  {
  // Add your code here to act upon Prefix3 change
}
/*
  Since Savenumbers is READ_WRITE variable, onSavenumbersChange() is
  executed every time a new value is received from IoT Cloud.
*/
void onSavenumbersChange()  {
  // Add your code here to act upon Savenumbers change
}
/*
  Since Sendtesttextnow is READ_WRITE variable, onSendtesttextnowChange() is
  executed every time a new value is received from IoT Cloud.
*/
void onSendtesttextnowChange()  {
  // Add your code here to act upon Sendtesttextnow change
}
/*
  Since Sendtext1 is READ_WRITE variable, onSendtext1Change() is
  executed every time a new value is received from IoT Cloud.
*/
void onSendtext1Change()  {
  // Add your code here to act upon Sendtext1 change
}
/*
  Since Sendtext2 is READ_WRITE variable, onSendtext2Change() is
  executed every time a new value is received from IoT Cloud.
*/
void onSendtext2Change()  {
  // Add your code here to act upon Sendtext2 change
}
/*
  Since Sendtext3 is READ_WRITE variable, onSendtext3Change() is
  executed every time a new value is received from IoT Cloud.
*/
void onSendtext3Change()  {
  // Add your code here to act upon Sendtext3 change
}

Forgot to add the serial monitor output to the above post:

***** Arduino IoT Cloud - configuration info *****
Device ID: 8854896f-295a-4b18-808a-1b92XXXXc24
MQTT Broker: mqtts-sa.iot.arduino.cc:8883
SIM card ok

(0) loopConnected= 0Connected to GPRS Network

(1) loopConnected= 0
(2) loopConnected= 0

It has been rebooting/trying for a while now and I caught it going beyond 3 loops. It actually connected to the cloud for a while, then rebooted again. This may help in figuring out what is going on. See serial monitor output below: (It's used 5MB of data just doing this according to Hologram)
SIM card ok

(0) loopConnected= 0Connected to GPRS Network

(1) loopConnected= 0
(2) loopConnected= 0ArduinoIoTCloudTCP::handle_ConnectMqttBroker could not connect to mqtts-sa.iot.arduino.cc:8883
ArduinoIoTCloudTCP::handle_ConnectMqttBroker 1 connection attempt at tick time 23276

(3) loopConnected= 0
(4) loopConnected= 0
(5) loopConnected= 0
(6) loopConnected= 0
(7) loopConnected= 0
(8) loopConnected= 0
(9) loopConnected= 1
(10) loopConnected= 1
(11) loopConnected= 1
(12) loopConnected= 1
(13) loopConnected= 1
(14) loopConnected= 1Connected to Arduino IoT Cloud
Thing ID: ce2b5a40-be10-4f62-a207-d3bXXXX8ef

(15) loopConnected= 1
(16) loopConnected= 1
(17) loopConnected= 1
(18) loopConnected= 1

Hi!
check this out.
And try this: ArduinoCloud.begin(ArduinoIoTPreferredConnection, false);

I did try the false parameter. If I remember it didn't help. I have done a lot of tests, including a clean Win10 install on another computer. Same exact problems. (there were a lot of other weird things too).
It boiled down to this as soon as I added more than 12 Thing variables it stopped working. Take the 13th variable out, everything works again. I have the paid "Maker" plan that says unlimited variables are allowed.
There is nothing wrong with my code, works fine with 12 Thing variables. Add the thirteenth and no go.

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