Serial communication with arduino breaks when turning USB port power on/off

userHead overdrive 2019-05-22 17:01:34 2525 Views2 Replies
Hello,

To give you some context, I'm running the Firmata sketch on the onboard Arduino and my program communicates with it through Serial.
This works quite well, BUT, I recently had to adapt the electronics circuit so that I can power one of the USB ports on and off using an external relay.
I basically run a USB cable's +5V wire through a relay and when I need to switch the power on or off I send a signal through one of the Arduino pins. This works
as expected (in fact my circuit has another relay controlled by the Arduino and that has been working for months now), EXCEPT, every once in a while the Serial communication breaks, after which my program needs to restart and, in some rare occasions the COM port is no longer detected so a reboot of the LattePanda is required.

The error I'm getting is reported by PyMata3 (the python client for the Firmata Arduino program):

Code: Select all

[Errno 5] Input/output error Write exception Shutting down ... This may be an issue with my electronics circuit, but it also may be due to something Latte-related - could the COM port be affected by my relay switching a USB cable?
I've been struggling with this issue for quite some time and I've tried modifying my circuit but I can't seem to find a solution. Any help would be appreciated.

[Edit]: I failed to mention that I'm running Linux on the LattePanda - Ubuntu 16.04.2 LTS