I'm using an Arduino Uno and trying to configure three MG-811 sensors to work together.
When I have one or two of the sensors plugged in to the board (pins A1 and A2), the code uploads just fine and works as desired. As soon as I add power to the third sensor, the already-uploaded code stops running and I get the following error when I try to re-upload:
Arduino: 1.8.9 (Windows 10), Board: "Arduino/Genuino Uno"
Sketch uses 5760 bytes (17%) of program storage space. Maximum is 32256 bytes.
Global variables use 286 bytes (13%) of dynamic memory, leaving 1762 bytes for local variables. Maximum is 2048 bytes.
avrdude: ser_open(): can't open device "\\.\COM4": The system cannot find the file specified.
Problem uploading to board. See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.
processing.app.SerialException: Error opening serial port 'COM4'.
at processing.app.Serial.<init>(Serial.java:147)
at processing.app.Serial.<init>(Serial.java:82)
at processing.app.SerialMonitor$4.<init>(SerialMonitor.java:101)
at processing.app.SerialMonitor.open(SerialMonitor.java:101)
at processing.app.AbstractMonitor.resume(AbstractMonitor.java:104)
at processing.app.Editor.resumeOrCloseSerialMonitor(Editor.java:2126)
at processing.app.Editor.access$1300(Editor.java:115)
at processing.app.Editor$UploadHandler.run(Editor.java:2104)
at java.lang.Thread.run(Thread.java:748)
Caused by: jssc.SerialPortException: Port name - COM4; Method name - openPort(); Exception type - Port not found.
at jssc.SerialPort.openPort(SerialPort.java:167)
at processing.app.Serial.<init>(Serial.java:136)
... 8 more
Error opening serial port 'COM4'.
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
I've tried using external power sources, different analog pins, a different Arduino, and an entirely different set of sensors. It doesn't seem to matter where the power is drawn from, which sensors I use, or which pin(s) I'm using. I can even have all three sensors grounded and connected to analog ports, but as soon as I add power to the third sensor it stops running the program and recognizing the serial port.
My best guess is that it has something to do with each sensor attempting to draw 5V; is there a limit regarding voltage and analog inputs? Any suggestions on how to avoid this error?