Search code examples
arduinowindows-10serial-portusbcom-port

How do I recover when Arduino USB Port randomly disappears?


I'm using my computer remotely and have an Arduino Every attached to a powered USB 3.0 hub. Anyway, the Arduino is part of a hardware tool that does some nice things for me. I communicate with it through the COM port.

The problem is that sometimes, after several days or even weeks, the Arduino's COM port just disappears. Is there some way to recover that COM port without physically unplugging it?

Sometimes restarting the computer works, but since the Arduino is plugged into a Powered USB Hub, it doesn't lose its power during a computer reset, so it doesn't reset itself and the COM port doesn't show up.

This used to happen frequently when I was using Arduino Nano knock-offs. I changed over to using Genuine Arduino Every devices and it hasn't been a problem for the last couple months. However, I'm now seeing it happen again.

Does anybody have a solution for this problem, or is this just something that happens from time to time with an Arduino when its connected for weeks/months at a time?


Solution

  • So, I replaced all usages of String with char[] and the problem still persisted.

    I finally went online and purchased an internal PCI-E USB expansion card with 7 ports. I started using that 2 weeks ago and haven't seen the problem since. The other benefit to the internal card is that when I reboot the computer, the card reboots and forces a disconnect/reconnect of all COM ports.

    I guess there was just something about having an external USB Hub that was causing the problems in the first place and the internal card was much more stable.

    UPDATE - After week 3, I lost communication with a couple of my Nano Every devices. Unplugging and replugging them in fixes the problem, but I need them to NOT have that problem again. I guess the internal PCI-E Usb Hub didn't solve the problem. Maybe if I plug the Every's directly into the Computers standard USB ports that might help. I'll give that a try...

    UPDATE 2 - I ended up purchasing a couple wifi wall plugs. Now, I can remotely unplug my computer and remotely unplug the USB Hub Power. I just 'Shut Down' my computer remotely and then remotely power it off for a few minutes and power off the USB hub for a few minutes. I then power up the computer (I have it's BIOS set to auto boot on power-cycle) and after it boots up, I power up the USB HUB and get all devices recognized again. Sometimes, I can just power-cycle the USB HUB to get the COM Ports visible again. It's a pain, but unless somebody comes up with a better idea, that's what I'm goin' with...