Arduino Nano 33 IoT : WiFi Disconnection Issue

I'm facing an issue with my Arduino Nano 33 IoT and BME280 temperature sensor project. The goal is to collect temperature data every minute and push it to the Arduino Cloud using a WPA2-encrypted Wi-Fi connection. The sketch works initially, but after a certain period (around a day), the Wi-Fi connection automatically disconnects, and the reconnection doesn't occur.

I've checked various forum replies but haven't found a suitable solution. The only way to presently to restore the connection is by power cycling the Arduino. Does anyone have insights into why the Wi-Fi connection drops after a while and how to ensure it reconnects automatically?

Any help or suggestions would be greatly appreciated! Thanks in advance.

Here's a simplified version of my code:

#include "thingProperties.h"
#include "Adafruit_BME280.h"

uint32_t timer = millis();
Adafruit_BME280 bme;

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

  // 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
 */
  unsigned status;
  status = bme.begin(0x77);  
  if (!status) {
    Serial.println("Could not find a valid BME280 sensor, check wiring, address, sensor ID!");
    while (true) {};
  }

  setDebugMessageLevel(2);
  ArduinoCloud.printDebugInfo();
}

void loop() {
  ArduinoCloud.update();
  // Your code here
  if (millis() - timer > 60000)
  {
    timer = millis();
    temp_details();
  }
}

void temp_details() {
  temperature = bme.readTemperature();
  Serial.print("Temperature = ");
  Serial.print(bme.readTemperature());
  Serial.println(" °C");
}

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