3
votes

I'm still new at Python and I'm trying to create a plant Monitor of sorts using an Arduino. The issue though is that my program cannot connect to the COM4 serial port.

from pyfirmata import Arduino
from pyfirmata import util
board = Arduino("COM4")
it = util.Iterator(board)
it.start()

from Sensors.sensor import sensorBase
soilSensor = sensorBase('a:0:o')

It errors out on the Arduino part with this error:

SerialException("could not open port 'COM4': PermissionError(13, 'Access is denied.', None, 5)")
  • I've gone to the device manager and disabled the port and then re-enabled it.
  • I've also shut down and rebooted my PC, that also doesn't help.
  • I've tried running Visual Studio 2017 with administrative privileges.
  • I'm able to type in the python terminal and that works fine, the problem I think lies with Visual Studio 2017.
1

1 Answers

0
votes

Answering this question since I was running into a s similar issue. Are you by any chance using Jupyter Notebook? I was having a similar error today and managed to solve it by opening Jupyter Notebook through Anaconda Navigator instead of opening it through Anaconda Prompt.