Multiple Arduinos on USB

We are setting up a series of sensors throughout the house. Because of cable lengths to the sensors we want to have 3-4 arduinos in centralized locations to the sensors, then use a USB<->Ethernet extension cable for each one. The USB extensions would all be plugged into a USB hub, which would then be plugged into the computer. The problem is that there is no way of knowing which com port will be assigned to which arduino by the computer. We can set up a handshake response on each arduino which will identify it. So how do we dynamically set the com port for each arduino within openhab?

Host operating system?

Windows 7, no Internet connection

Have a look at COM-Port Manager - ComPortMan

1 Like

That looks like it will work, however if the arduinos do not initialize in exactly the same order every time, then they will get different com ports, and so will be scrambled from OpenHab’s viewpoint.

I did come up with a workaround though. I will write a program which will scan the com ports, query the device on that com port for its name, then save the relationship.

The program will write out the OpenHab binding to that arduino, using the OpenHab name along with the com port.

And then start OpenHab.

This adds a little complexity, however the com port allocation is not relevant, yet the mapping is consistent.

You could treat it as a bus. openHAB listens to all ports, a message with “ID=4” embedded is treated as coming from device 4 whatever port it arrives on. openAB broadcasts instructions to all ports with “ID=4” embedded, but only a device 4 takes any notice.

is that the case ? as far as I understand the description of ComPortMan it uses the serial id in the configuration so the Com Port will be fixed independent of the order the arduinos will be initialized.

Ok, we’ll try these out.

BTW, this is all theoretical right now. We are in the mid-planning stages for the layout, and discovered we have longer runs, and more sensors than we originally thought (near 100 right now). So the solution is to add arduinos, then the problem of addressing them showed up.

Once we have a working system, I can post it here, if anyone wants :slight_smile:

Have you considered implement an RS485 serial bus?