Losing connection (bad mains power?)

I have a CR-10 and an Ender 3. Both have worked fine for months with latest Octoprints.

I recently added AC bed heaters. They really heat up fast and high and they draw a lot of power. I've printed a number of small prints with them. I've also built styrofoam enclosures for both of them but they only get up to about 45 degrees C inside. (The electronics are in the enclosures but 45 should be no problem.

The other day I started a long print on each printer and during the night both failed with the exact same error at the exact same time. This is the error from the log.

019-05-29 21:36:36,295 - octoprint.util.comm - ERROR - Unexpected error while reading from serial port
Traceback (most recent call last):
  File "/home/pi/oprint/local/lib/python2.7/site-packages/octoprint/util/comm.py", line 2605, in _readline
    ret = self._serial.readline()
  File "/home/pi/oprint/local/lib/python2.7/site-packages/octoprint/util/comm.py", line 4681, in readline
    c = self.read(1)
  File "/home/pi/oprint/local/lib/python2.7/site-packages/serial/serialposix.py", line 501, in read
    'device reports readiness to read but returned no data '
SerialException: device reports readiness to read but returned no data (device disconnected or multiple access on port?)
2019-05-29 21:36:36,328 - octoprint.util.comm - ERROR - Please see https://faq.octoprint.org/serialerror for possible reasons of this.
2019-05-29 21:36:36,357 - octoprint.util.comm - INFO - Changing monitoring state from "Printing" to "Offline (Error: SerialException: 'device reports readiness to read but returned no data (device disconnected or multiple access on port?)' @ comm.py:_readline:2605)"
2019-05-29 21:36:36,480 - octoprint.plugins.DisplayLayerProgress - INFO - Printing stopped. Detailed progress stopped.

I'm guessing the printers rebooted but I don't know how to find out if they did. It is not like the printers have logs. Is there some way to monitor a printer's health and log it in octoprint?

This has happened again to each printer but not at the same time like the first incident.

The only thing I can think of that is in common is the 110 VAC mains coming into the printers. This is in an old garage that probably has crappy wiring.

So I bought a good 500W battery-backup UPS (uninterruptible power supply). I only plugged the printers and raspis into the UPS and left everything else, including the bed heaters, plugged into the wall.

I started prints on both printers and within 10 minutes one got the error again. I'm returning the UPS.

I know this is probably not an octoprint problem or any other software but I'm desperate since I can't print and my job depends on it.

Any ideas would be greatly appreciated.

If anyone cares, I solved my problem by running an extension cord into the house. So the garage power is flakey and even the UPS didn't fix it. So now I just have to figure out a permanent solution.

I don't believe I've ever used my 3D printer when it wasn't plugged into a UPS. Mine is a 550VA variety, btw. If you believe the power is bad in the garage you should consider having someone qualified troubleshoot that.

I've got a good electronics/electrical background and I'm the type of guy to rip out existing wiring and make new runs to the breaker box. (I also was the electrician for one of those camper sites part-time and had to make repairs to their external boxes.) I've seen every sort of mistake you can possibly imagine. And it's a dangerous situation if there are wires arcing inside a outlet so it's in your best interest to have someone take a look.

I'm an electrical engineer, but we make horrible electricians. I'm always trying to find a short-cut.

Someone on another forum suggested I use USB isolators to remove any ground loops etc. That worked. Both printers worked great with my garage power.

Well now one of my printers is failing constantly again with comm errors. Now even powering it from the house doesn't work.

Interesting... did you include an external 5V adapter for that? ADUM4160

So, your printer doesn't drop the connection with this configuration? (In my own testing, if the 5V line of the USB isn't felt by the printer it won't keep the connection going for my own test rig.)

Interesting idea. I don't need the power from usb at all so removing the 5V wire might help. I do know the power isn't as isolated as the data. I'll give it a try.

In my own testing, if the 5V line of the USB isn't felt by the printer it won't keep the connection going

Removing the power wire is very common. People do it because it bothers them that the raspi keeps the printer electronics going which happens for me also.

Well, yeah... I should know. I wrote the OctoPrint-USBControl plugin for what it's worth.

That looks great. I'm definitely trying it. You should have mentioned that it turns the USB power off in sw.

Read it all the way through. With the 3B, you get to turn off all four Type A connectors at once since that's the bus type that's available on that board. The 3B+ is slightly better.

I'm surprised you went to the trouble of doing the plug-in since killing power didn't work for you. Not that I don't appreciate it.