MKR1500 wont reconnect after switching cell towers

I've used two different MKR1500 boards, with battery and without, three different antennas, a sim card from soracom and one from hologram, to rule out any hardware problems but the issue remains the same. As long as the board stays in one place, it will stay connected to the arduino iot cloud but as soon as I drive from work to home it will loose connection and not try to reconnect. This happens in either direction: if I power cycle the board at work then drive home, or start from home and drive to work. Any help is greatly appreciated as I don't know where to go from here.
I'm using the most basic code I can use to test to keep it simple.

/* 
  Sketch generated by the Arduino IoT Cloud Thing "Untitled"
  https://create.arduino.cc/cloud/things/160cc0f5-2ece-41eb-86a5-373f1f10e69e 

  Arduino IoT Cloud Variables description

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

  bool lockStatus;

  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"

String serialMessage;


void setup() {
  // Initialize serial and wait for port to open:
  Serial.begin(115200);
  Serial1.begin(115200);

  // 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 
    while (Serial1.available()) {
    delay(1);
    serialMessage = Serial1.readString();
    serialMessage.trim();
  }
  if(serialMessage == "doorsUnlocked"){
    lockStatus = false;
  }
    if(serialMessage == "doorsLocked"){
    lockStatus = true;
  }
}
1 Like

It's up to you to write code that detects that it is no longer connected and then tell it to reconnect.

// Pseudo code in loop()
if(notConnected) {
   ArduinoCloud.begin(ArduinoIoTPreferredConnection);
}

EDIT: Gave a like for a well formatted first post using code tags :ok_hand:

I hope its that simple, I had assumed that re-connection was taken care of by "NBConnectionHandler" located in thingProperties.h. I'll try this this weekend.

Looks like that solved the re-connection problem, thank you. Now to troubleshoot all the new problems.

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