Code freezes when no wifi connection is found

I have my Uno R4 connected to the cloud with no issues and working fine in my office.
However, when i take the unit home where the SSID and PASS are obviously different, the code just keeps trying to connect and reporting "Connection to "XXXXXX" failed".
It will not give up and allow the code to run any further.

I want the code to continue if for some reason the Wifi at the location where the unit is installed is not available.

Have been searching to try and find some explanation for this and fix, but not finding anything.

Any help greatly appreciated as pulling hair out now !

Looking at the code you did not post I see a do while that is hot releasing your code.

Sorry gilshultz, it being the IoT section of the forum, i assumed no one would be interested in seeing a standard bit of Arduino generated code that most if not all probably use !

And also not seeing how to post code in correct format when using the cloud editor.

The attempt to constantly keep trying to reconnect, slows the void loop to a 10 sec loop.

Need to make if give up till next restart if it can't connect instead of rescanning all the time.

/* 
  Sketch generated by the Arduino IoT Cloud Thing "Untitled"
  https://create.arduino.cc/cloud/things/1be02642-eed0-4167-8873-XXXXXXXXXXXX 

  Arduino IoT Cloud Variables description

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

  float lifeTimeMaxPressure;
  float maxSetPressure;
  float minSetPressure;
  float pumpStarts;
  float setPressure;
  int countStarts;
  int onTime;
  bool isBleeding;
  bool status;
  CloudTime pumpRunTime;

  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"

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();
  runCount = 0;

  // Connect to Arduino IoT Cloud
  ArduinoCloud.begin(ArduinoIoTPreferredConnection);
  
  setDebugMessageLevel(2);
  ArduinoCloud.printDebugInfo();
}

void loop() {
  ArduinoCloud.update();
  // Your code here 
  runCount = runCount + 1;
  delay(2000);
  
  //Any code placed here runs very slowly as with each loop the connection is tried again, and fails 
  
  Serial.println ("Printing very slowly");
  
}

Sorry I do not have an R4 to test and see what is happening. I believe you are correct on the SSID and Password but I do not have a clue as how to set or change them or how to display the appropriate error.

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