multiple devices on one serial port?

Hey everybody,

is it possible to connect multiple Serial devices to one Serial port. I have 10 Serial devices, that send data once per second, so I was thinking about connecting them all to the same Serial port (hardware or software) of the Arduino and let them send with a delay of 100ms. Is that possible? Maybe with diodes, to make sure the signal "doesn't go the wrong way"?

thanks in advance for your help

is it possible to connect multiple Serial devices to one Serial port.

Possible, yes. Advisable, no.

I have 10 Serial devices, that send data once per second, so I was thinking about connecting them all to the same Serial port (hardware or software) of the Arduino and let them send with a delay of 100ms.

How will you sync the clocks, and ensure that no device sends data out of sequence?

Using 10 software serial ports seems like a better idea. Since that is a bit difficult, with only one instance able to listen at once, perhaps you need to rethink your idea.

If we knew what the devices sending the data were, we could offer ideas.

If we knew what the devices sending the data were, we could offer ideas.

the devices send data like this "### ####### #### ### \r\n" (# is a decimal number) the stream is not always the same size. the second block varys between 3-7 digits and the fourth block varys between 2-3 digits. the devices are all the same and send their data once every second at 9600baud. i have no influence on these devices except for powering them on and off. I'm now using the Arduino Micro, with the problem that I can only use Pins 10-14 as RX for SoftwareSerial (due to it's specifications - or am I wrong here?)

the problem with multiple SoftwareSerials is, that

while(anySoftwareSerial.available()){
   int x = anySoftwareSerial.read();
   ...
}

doesn't work for some reason.

the devices are all the same and send their data once every second at 9600baud. i have no influence on these devices except for powering them on and off.

Then you are out of luck, there are many ways to do this with a single serial port but they all require you to write a protocol that runs on all connected devices, as you have no control over most of them there's little you can do except have a heap of serial connections or control the power to each device and cycle through them.

As for using software serial, I don't think it works well (at all?) with 10 inputs.


Rob

do you know any example where someone is/was using multiple SoftwareSerials to read data? I can't find any.

igordashaar: do you know any example where someone is/was using multiple SoftwareSerials to read data? I can't find any.

I don't think the SoftwareSerial library supports that - when there are multiple instances of SoftwareSerial, you can only enable one at a time for receiving.

Given that you don't have control of the devices that are originating these messages, I'd approach this by connecting each device to a local Arduino which stored and forwarded the messages to your central collecting point. If all the devices are close together that could be done by the sort of multi-drop serial connection you described with the communication controlled by a central master unit.

Do you need every packet from every device?

If not, you could indeed use multiple instances of softwareSerial and listen on each of them in turn.

If you need all the packets, a couple of Megas would give you enough serial ports (using one software port on each) to cover ten of your devices.

How about a "shield" with an octal uart http://www.nxp.com/documents/application_note/AN410B.pdf

Or 2, 3 quad UARTs http://www.nxp.com/documents/data_sheet/SC16C754.pdf

The Arduino Due's USARTS have RS485 capability. This mode allows multiple devices on one port, however a software driver and transceiver IC's are needed.

What about using something like a 74HC4051 (or perhaps a few of them) to select which of the serial devices is connected to your single USART at any one time?

...R