0

I'm trying to get Python to read connect to an Arduino Uno on Serial port 3 so that would be COM3 in the python code. I am using Python33, The latest version on Arduino and pySerial 2.7. This is the code for the Arduino:

void setup() {
Serial.begin(9600); // set the baud rate
Serial.println("Ready"); // print "Ready" once
}
void loop() {
char inByte = ' ';
if(Serial.available()){ // only send data back if data has been sent
char inByte = Serial.read(); // read the incoming data
Serial.println(inByte); // send the data back in a new line so that it is not all one long line
}
delay(100); // delay for 1/10 of a second
}

And this is the python code:

import serial
ser = serial.Serial("COM3", 9600)

then I get this error:

Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
ser = serial.Serial("COM3", 9600)
File "C:\Python33\lib\site-packages\serial\serialwin32.py", line 38, in __init__
SerialBase.__init__(self, *args, **kwargs)
File "C:\Python33\lib\site-packages\serial\serialutil.py", line 282, in __init__
self.open()
File "C:\Python33\lib\site-packages\serial\serialwin32.py", line 66, in open
raise SerialException("could not open port %r: %r" % (self.portstr, ctypes.WinError()))
serial.serialutil.SerialException: could not open port 'COM3': FileNotFoundError(2,   'The system cannot find the file specified.', None, 2)

This is probably something easy to fix and I have looked pretty much everywhere and I still can't seem to find the answer to the problem.

1
  • Adding what your device manager shows might help more Commented Jan 1, 2014 at 15:34

2 Answers 2

1

Why are you trying to use "COM3" on a Linux machine? That's a Windows port name. Linux/Unix port names are of the form /dev/ttyUSB0.

But, as the docs show, you can probably just use the port number directly - they start at 0, so you can do ser = serial.Serial(2, 9600).

Sign up to request clarification or add additional context in comments.

1 Comment

I'm not using a Linux machine, I'm using Windows 8 and when I put ser = serial.Serial(2, 9600) I get Access is denied. @DanielRoseman
0

If you have the arduino ide open, then python may not be able to access the port. Ive hade this problem as well using Processing.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.