Is there any way to do this programmatically?
However, the laptop connected to the Arduino is, I think, experiencing power surges from other machines in the laboratory. I'm kind of stuck with a particular spot in the lab, so it's not quite as simple as moving to another power point.
So running it off the laptop battery isn't feasible in this instance.
Then, if the application is important, run a clean mains power supply for the laptops to connect to....R
what sort of Arduino you are using.
And it is not clear from your description whether the Arduino resets? Maybe you could get it to flash an LED in an identifiable sequence in setup() so that you easily tell if it resets even when there is no communication with the PC.
Does the PC program that is communicating with the PC recognize that the communication has stopped? If so maybe it can restart it.
What operating system are you using on the PC? If you are using Windows maybe the COM port changes?
Would it help to power the PC and the transformer from the same (or adjacent) outlets?
but the Arduino is not sending information via serial (the TX light stops flashing and turns off).