[Dprglist] Raspberry pi to Arduino Serial Communications

Doug Paradis paradug at gmail.com
Wed Jan 6 14:03:25 PST 2021


Pat,
   Great information!

Regards,
Doug P.

On Wed, Jan 6, 2021 at 2:24 PM Pat Caron via DPRGlist <
dprglist at lists.dprg.org> wrote:

> During the last RBNV I mentioned that I was having problems communicating
> with an Arduino connected to the RPI due to that nature of the USB bus and
> what device gets connected first ei: /dev/ttyUSB0 vs /dev/ttyUSB1 or
> /dev/ttyACM0...etc when using multiple Arduinos.  To resolve this I used
> some udev rules as below to connect the devices to a symbolic link
> therefore resolving the unknown USB device name.  The same symbolic link
> name will be given to the USB serial device connected to a specific port.
>
> I created */etc/udev/rules.d/99-tty-by-path.rules* with the following
> content on the raspberry pi.
>
> # Rules to create SYMLINK to Arduino device by USB path
> ACTION=="add", SUBSYSTEMS=="usb", KERNELS=="1-1.2.7:1.0",
> SYMLINK+="ttyUSB-motor"
> ACTION=="add", SUBSYSTEMS=="usb", KERNELS=="1-1.2.7:1.1",
> SYMLINK+="ttyUSB-ultrasonic"
>
> I got the path for the KERNELS=="1-1.2.7:1.x" by typing the command below
> in the terminal for each devices connected
> udevadm info -a --name=ttyACM0
>
>       looking at parent device
> '/devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/usb1/1-1/1-1.2/1-1.2.7/1-1.2.7:1.0':
>     *KERNELS=="1-1.2.7:1.0"*
>     SUBSYSTEMS=="usb"
>
> Reload the rules or reboot for them to take effect!!
>
> In python I use:
>
>     try:
>         link = txfer.SerialTransfer('/dev/ttyUSB-motor', 57600)
>
>         link.open()
>         time.sleep(2) # allow some time for the Arduino to completely reset
>         while True:
>             .......
>
> Regards,
> ...Pat
> _______________________________________________
> DPRGlist mailing list
> DPRGlist at lists.dprg.org
> http://lists.dprg.org/listinfo.cgi/dprglist-dprg.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.dprg.org/pipermail/dprglist-dprg.org/attachments/20210106/87a4e4d9/attachment.html>


More information about the DPRGlist mailing list