jorrit
Posts: 23
Joined: Mon Oct 17, 2016 10:48 am

Connecting a PI with two Arduino's

Sun Nov 06, 2016 9:20 am

Hi, I'm trying to connect a PI with two Arduino's (using USB cables) and then communicate to it using Java and the RXTX library.

The java program works and can find one of the two Arduino's. However I'm having issues with the second Arduino'.

First I tried to figure out the ports of the Arduino's. I found out that /dev/ttyUSB0 works for one of the Arduino's. However there doesn't seem to be a /dev/ttyUSB1 or any other port for the other Arduino. I tried /dev/ttyACM0 but that doesn't work.

Here is the output from dmesg after plugging in the non working Arduino:
[ 795.793920] usb 1-1.4: USB disconnect, device number 6
[ 802.688258] usb 1-1.5: new full-speed USB device number 7 using dwc_otg
[ 802.802140] usb 1-1.5: New USB device found, idVendor=2341, idProduct=0043
[ 802.802159] usb 1-1.5: New USB device strings: Mfr=1, Product=2, SerialNumber=220
[ 802.802173] usb 1-1.5: Manufacturer: Arduino (www.arduino.cc)
[ 802.802185] usb 1-1.5: SerialNumber: 95335343036351A001B0
[ 802.803473] cdc_acm 1-1.5:1.0: ttyACM0: USB ACM device
Here is the output of lsusb:
Bus 001 Device 007: ID 2341:0043 Arduino SA Uno R3 (CDC ACM)
Bus 001 Device 005: ID 1a86:7523 QinHeng Electronics HL-340 USB-Serial adapter
Bus 001 Device 004: ID 8888:6666
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. SMSC9512/9514 Fast Ethernet Adapter
Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
The same setup works fine on a regular laptop btw. So I know both Arduino's are fine.

Any clues?

Thanks

richrarobi
Posts: 271
Joined: Sun Feb 08, 2015 1:13 pm

Re: Connecting a PI with two Arduino's

Sun Nov 06, 2016 9:32 am

The serial port (two pins on gpio) should work as a second connection - this post has some info (around nanpy and arduino and serial ports) (but be careful of voltage differences)
viewtopic.php?f=44&t=46881&p=839460&hilit=nanpy#p839460

jorrit
Posts: 23
Joined: Mon Oct 17, 2016 10:48 am

Re: Connecting a PI with two Arduino's

Sun Nov 06, 2016 9:35 am

Ok, but the program is already written with two USB connections in mind (which makes it easier to develop the program on a laptop). Is this not possible? I would prefer to connect it with that

jorrit
Posts: 23
Joined: Mon Oct 17, 2016 10:48 am

Re: Connecting a PI with two Arduino's

Sun Nov 06, 2016 9:44 am

BTW, it seems the port should be /dev/ttyACM0 but for some reason RXTX cannot connect to that.

Note that this arduino is actually a 'real' arduino (official one) while the one that is working is the ATmega Uno R3 Board / ATmega328. So perhaps a compatibility problem somehow?

jorrit
Posts: 23
Joined: Mon Oct 17, 2016 10:48 am

Re: Connecting a PI with two Arduino's

Sun Nov 06, 2016 10:05 am

Ok, I managed to solve it with a bit of a hack:

sudo ln -s /dev/ttyACM0 /dev/ttyUSB1


i.e. RXTX can apparently only connect to a USB port if it is called /dev/tty/USB<x>

Now both Arduino's work fine

User avatar
DougieLawson
Posts: 35560
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Connecting a PI with two Arduino's

Sun Nov 06, 2016 10:20 am

jorrit wrote:Ok, I managed to solve it with a bit of a hack:

sudo ln -s /dev/ttyACM0 /dev/ttyUSB1


i.e. RXTX can apparently only connect to a USB port if it is called /dev/tty/USB<x>

Now both Arduino's work fine
You should do that with a udev rule, otherwise it will disappear when you reboot.

sudo nano /etc/udev/rules.d/80-arduino.rules

Code: Select all

KERNEL=="ttyAMA0",SYMLINK+="ttyS0" GROUP="dialout"
KERNEL=="ttyACM0",SYMLINK+="ttyS1" GROUP="dialout"
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

Return to “Troubleshooting”