Popiman
Posts: 6
Joined: Tue Jul 24, 2012 3:18 pm

Pi to Arduino comms using Pyserial

Thu Dec 20, 2012 4:50 pm

Hi all
I've already got my arduino mega 2560 talking to my PC using Python 3.2.3 with pyserial installed (had to modify the win32.py and serialutil.py files to get it working though).
I'm now trying to get my Raspberry Pi communicating with the arduino using a modified version of the same Python code used on my PC. When creating the serial port on the PC I use the code:
ser = serial.Serial('COM4',9600,8,'N',1,None,False,False,False)
Does anyone know what needs to be substituted for COM4 in this line of code to get it working with the Pi ? I should probably mention here that the arduino is plugged into a powered 4 port hub which is fed from the lower of the Pi's two USB ports.
The device is listed (using lsusb in a command window) as Bus:001, Device:007 ID:2341:0042.
I've already tried "/dev/bus/usb/001/007" but this kicked out an error when I tried to open the port.
Thanks in advance for any help you may be able to give.
Adrian

gordon77
Posts: 4969
Joined: Sun Aug 05, 2012 3:12 pm

Re: Pi to Arduino comms using Pyserial

Thu Dec 20, 2012 4:56 pm

I use

ser = serial.Serial('/dev/ttyACM0',9600)

on my RPI to talk to a Arduino Uno

bteeter
Posts: 40
Joined: Tue Sep 04, 2012 7:16 pm

Re: Pi to Arduino comms using Pyserial

Thu Dec 20, 2012 6:47 pm

The device that is used for a Arduino Mega is /dev/ttyusb0.

Bob Teeter

Return to “Python”