Arduino Nano Every becomes non-responsive after a couple weeks

I've been using Arduino Nano and Nano Every devices for several years I mainly use them connected to relays to turn 110 volt power on and off. Anyway, after a couple weeks, and sometimes several weeks, the device appears to stop talking. As though it's unplugged. The COM port in Windows appears disconnected or non-responsive. The problem is resolved by just unplugging the Arduino and plugging it back in.

Unfortunately, with Covid, I work remotely and am not able to unplug and plug in my Arduinos.

When working, I send a command via Serial over the COM port to the Arduino and it responds when successful. I am wondering if there is a way for the Arduino do a self diagnostic to detect if it is still connected to the COM port and talking like it should.

Is there some 'loopback' test call I can make every couple hours from the Arduino to detect that it's still able to talk to the computer?

Furthermore, once I detect a failure to communicate, is there a way for the Arduino to power-cycle itself and re-establish connection?

Any assistance here will be greatly appreciated.

Thanks !!

You could connect a hardware watchdog to the reset of the Arduino.

Google watchdog timer

You might be having a problem in software such as a unsigned long variable overflowing.

Maybe you are using String which can cause memory corruption.

Does a second Arduino do the same thing ?

There maybe a noise source nearby that is causing disruption.

Maybe your power supply is iffy.

Curtis63:
When working, I send a command via Serial over the COM port to the Arduino and it responds when successful. I am wondering if there is a way for the Arduino do a self diagnostic to detect if it is still connected to the COM port and talking like it should

Perhaps it is a Windows problem?

...R

As Robin2 said it is likely a Windows issue. Here are a few things you can look at.

Get yourself the schematic of the Arduino Nano Every from the Store under Documentation

https://store.arduino.cc/arduino-nano-every-with-headers

The following page will also be useful

  1. The COM port is handled by a SAMD11. Solder a wire to the D11 RESET pin and pull this to GND for a short while. This should reset you USB connection and therefore the COM port in your PC. You could control that pin from your ATmega. Make sure not to send 5V to the SAMD11 it is 3.3V only.

  1. You could change the firmware of the SAMD11 to reset itself when the USB connection is broken or when you send a special sequence from the ATmega to the SAMD11.

  2. Think about upgrading your system to another Arduino e.g. the Arduino Nano 33 IoT with WiFi. Because network connections are less reliable than UARTs there are all kinds of tricks to detect a faulty connection and reconnect. On top of it, you could control your system from all kinds of devices e.g. your smartphone and not just your PC.