Go Down

Topic: Arduino Serial Communication with Python (Read 1 time) previous topic - next topic


I am trying to get serial communication working between my Arduino and Python.  I am new at this, but I have tested several examples, none of which worked.  This was only supposed to be the initial step in a larger project, but I have run into a brick wall.

I know that serial communication is working between my computer and my Arduino as I can upload programs and I can see results from the Arduino in the Arduino Serial Monitor.  So the problem likely lies with Python.   I am running Python 3.2 on Windows 7 (64 bit).  It seems possible that the problem may be in pySerial.

I keep getting the following error:

File "C:\Python32\lib\site-packages\serial\serialwin32.py", line 236, in read
raise SerialException("ReadFile failed (%s)" % ctypes.WinError())
serial.serialutil.SerialException: ReadFile failed ([Error 6] The handle is invalid.)

The same error message occurs with multiple examples. 

Can anyone help?  I'm stuck at this point.   I'd have posted the code, but I really don't believe the problem is in the code, as I have copied exactly some of the examples that purport to show how serial communications works between Arduino and Python. 

I checked many places on the Internet, which pointed me in the direction of a problem with 32bit vs 64bit environment.   I've tried installing a new version of pySerial as well as a new version of win32.py, again, with no joy.

Is this problem specific to Windows 7? Is it Python 3.2? Is it pySerial?   Is it win32.py?  Could it be my setup?

I appreciate any help.



For anyone reading these posts, I believe I have solved the problem and as usual, it was a user(meaning me) problem.  The problem stemmed from not properly installing pySerial.  After I rectified that issue, things seemed to go much more smoothly. 

For any other newbies like me(especially those who are more familiar with Windows than with Unix), if you download a .tar.gz from pyPI, you must take 3 steps. 

1. Uncompress it
2. Extract it.
3. Install(build) it.

You can do the first two steps with 7-zip.  The 3rd step will depend on the package and the requirements for your environment.

Try searching for how to install python packages + windows/linux/osx/etc.

Hope this is helpful.

Go Up