froggy2684
Posts: 4
Joined: Mon Jul 08, 2013 10:19 am

using both USB's for input

Thu Jan 09, 2014 8:32 pm

Is it possible to have both USB's connected at the same time and accept data from them

1 usb is a weather station and the other an energy monitor, if it is possible how do i distinguish between them as they are both referenced as TTYUSB0 (I think) see attached screen shot of lsusb
Attachments
Capture.PNG
Capture.PNG (30.6 KiB) Viewed 1552 times

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 26660
Joined: Sat Jul 30, 2011 7:41 pm

Re: using both USB's for input

Thu Jan 09, 2014 8:57 pm

I see no reason why not - have you tried it? Do they get assigned different devices if both plugged in (USB0, USB1)
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed.
I've been saying "Mucho" to my Spanish friend a lot more lately. It means a lot to him.

froggy2684
Posts: 4
Joined: Mon Jul 08, 2013 10:19 am

Re: using both USB's for input

Thu Jan 09, 2014 10:19 pm

I'm not sure how to check if they have been assigned different values - any idea how to do it?

sdjf
Posts: 1395
Joined: Fri Mar 16, 2012 5:20 am
Location: California
Contact: Website

Re: using both USB's for input

Fri Jan 10, 2014 4:16 am

I am using a text browser so cannot view your screenshot, but the way to see what devices are is the ls command I think, not lsusb.

Try the following:

ls /dev/*usb* /dev/*USB*

That will turn up any devices with USB in the name, but if they are tty's, you could also try:

ls /dev/tty*

You can also see the devices listed with following, but command does not say what device name is:

cat /proc/bus/input/devices

Please explain why you need to know how to distinguish between the two devices when they are attached, it will help in figuring out how to guide you.

And I agree with JamesH, certainly you can have more than one input device attached. I think it is more a matter of what software you are using to deal with or route or save the output from them, and being able to code which output comes from which.

I know when I want to know which usb device was assigned which name, I plug one in, look at my log to see the name it was given, then plug the other one in. You could do something similar, either looking at the ls /dev/ command or output of dmesg command. I have detailed system logs I look at, but have heard those are disabled in more recent versions of the Pi OS's.
FORUM TIP: To view someone's posting history, sign in, click on their user name, then on "Search User's Posts." || Running ArchLinuxArm on Model 2B and 512MB Model B

User avatar
rpdom
Posts: 17174
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: using both USB's for input

Fri Jan 10, 2014 7:38 am

The names will depend on which order the devices are connected or detected in.

The first device will become ttyUSB0 (or something similar) and the second will be assigned ttyUSB1.

If they have any unique internal serial or something then it should be possible to write a udev rule file that will assign a meaningful name to each, like "energymon" and "weather" instead of the ttyUSB names.

I think I have a PL2303 based serial adapter somewhere. I'll have a look for it later and see what attributes it has.

jdb
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 2393
Joined: Thu Jul 11, 2013 2:37 pm

Re: using both USB's for input

Fri Jan 10, 2014 12:19 pm

The PL2303 should have a serial number programmed into it. This would allow you to create a udev rule to distinguish between the devices based on a unique attribute.

The serial number should be part of the dmesg spam that appears when the device is first enumerated.

If the serial number is blank (quite likely) then you could use a more weak rule to assign a device name to a device plugged into a particular USB port.
Rockets are loud.
https://astro-pi.org

froggy2684
Posts: 4
Joined: Mon Jul 08, 2013 10:19 am

Re: using both USB's for input

Fri Jan 10, 2014 7:31 pm

Just to clarify, I am not using keyboard,mouse or monitor I am using SSH.

I want to connect a weather station and and energy monitor, but i presume that the software WEEWX (weather station) and measureit (energy monitor) will need to know which port to read from. I will try " ls /dev/*usb* /dev/*USB*" this suggestion shortly, as i have to power both pi's off to change the usb's as i am afraid of corrupting the data. incidently if i plug the energy monitor in while the pi is up and running it loses connection off of the network for a few minutes.

froggy2684
Posts: 4
Joined: Mon Jul 08, 2013 10:19 am

Re: using both USB's for input

Fri Jan 10, 2014 7:34 pm

Yep looks like it is as simple as ttyUSB0 & ttyUSB1

sdjf
Posts: 1395
Joined: Fri Mar 16, 2012 5:20 am
Location: California
Contact: Website

Re: using both USB's for input

Fri Jan 10, 2014 9:41 pm

That loss of connection could be temporary dip in power. Or, a loose USB socket? One of my sockets, if I change any of the USB peripherals, everything resets. I solved that by putting tape around the usb connector going into the socket, to make it less loose, and sticking a flat toothpick in to make it more stable. A bit funky, but it works. That socket I use to plug a usb hub into, so that does not get plugged/unplugged now, but before, if I accidentally touched anything near, everything would disconnect because the connectors inside lost contact. I suppose it is a faulty Pi here, but I did not want to go through the hassle of exchange when this stabilized things.
FORUM TIP: To view someone's posting history, sign in, click on their user name, then on "Search User's Posts." || Running ArchLinuxArm on Model 2B and 512MB Model B

Return to “Beginners”